Make Octopus merge message a bit nicer.
Linus says that 'of .' to mean the commits came from the local repository was too confusing and ugly -- I tend to agree with him. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Sep 19, 2005 at 00:03 UTC
63f1aa6c72c46928f1b6959437aed4becbc42ff3
2 files changed
+86
-11
git-fetch.sh
+10
-6
@@ -58,21 +58,25 @@ append_fetch_head () {
58
# remote-nick is the URL given on the command line (or a shorthand)
59
# remote-name is the $GIT_DIR relative refs/ path we computed
60
# for this refspec.
61
+ remote_1_=$(expr "$remote_" : '\(.*\)\.git/*$') &&
62
+ remote_="$remote_1_"
63
+ case "$remote_" in
64
+ . | ./) where_= ;;
65
+ *) where_=" of $remote_" ;;
66
+ esac
67
case "$remote_name_" in
68
HEAD)
69
note_= ;;
70
refs/heads/*)
71
note_="$(expr "$remote_name_" : 'refs/heads/\(.*\)')"
66
- note_="branch '$note_' of " ;;
72
+ note_="branch '$note_'" ;;
73
refs/tags/*)
74
note_="$(expr "$remote_name_" : 'refs/tags/\(.*\)')"
69
- note_="tag '$note_' of " ;;
75
+ note_="tag '$note_'" ;;
76
*)
71
- note_="$remote_name of " ;;
77
+ note_="$remote_name" ;;
78
esac
73
- remote_1_=$(expr "$remote_" : '\(.*\)\.git/*$') &&
74
- remote_="$remote_1_"
75
- note_="$note_$remote_"
79
+ note_="$note_$where_"
80
81
# 2.6.11-tree tag would not be happy to be fed to resolve.
82
if git-cat-file commit "$head_" >/dev/null 2>&1
git-pull.sh
+76
-5
@@ -57,10 +57,81 @@ then
57
fi
58
59
merge_head=$(sed -e 's/ .*//' "$GIT_DIR"/FETCH_HEAD | tr '\012' ' ')
60
-merge_name=$(
61
- perl -e 'print join("; ", map { chomp; s/^[0-9a-f]* //; $_ } <>)' \
62
- "$GIT_DIR"/FETCH_HEAD
63
-)
60
+
61
+case "$merge_head" in
62
+?*' '?*)
63
+ merge_name="Octopus merge of "$(
64
+ perl -e '
65
+ my @src;
66
+ my %src;
67
+
68
+ sub andjoin {
69
+ my ($label, $labels, $stuff, $src) = @_;
70
+ my $l = scalar @$stuff;
71
+ my $m = "";
72
+ if ($l == 0) {
73
+ return "";
74
+ }
75
+ if ($l == 1) {
76
+ $m = "$label $stuff->[0]";
77
+ }
78
+ else {
79
+ $m = ("$labels " .
80
+ join (", ", @{$stuff}[0..$l-2]) .
81
+ " and $stuff->[-1]");
82
+ }
83
+ if ($src ne ".") {
84
+ $m .= " from $src";
85
+ }
86
+ return $m;
87
+ }
88
+
89
+ while (<>) {
90
+ my ($bname, $tname, $gname, $src);
91
+ s/^[0-9a-f]* //;
92
+ if (s/ of (.*)$//) {
93
+ $src = $1;
94
+ } else {
95
+ $src = ".";
96
+ }
97
+ if (! exists $src{$src}) {
98
+ push @src, $src;
99
+ $src{$src} = { BRANCH => [], TAG => [], GENERIC => [] };
100
+ }
101
+ if (/^branch (.*)$/) {
102
+ push @{$src{$src}{BRANCH}}, $1;
103
+ }
104
+ elsif (/^tag (.*)$/) {
105
+ push @{$src{$src}{TAG}}, $1;
106
+ }
107
+ else {
108
+ push @{$src{$src}{GENERIC}}, $1;
109
+ }
110
+ }
111
+ my @msg;
112
+ for my $src (@src) {
113
+ my $bag = $src{$src}{BRANCH};
114
+ if (@{$bag}) {
115
+ push @msg, andjoin("branch", "branches", $bag, $src);
116
+ }
117
+ $bag = $src{$src}{TAG};
118
+ if (@{$bag}) {
119
+ push @msg, andjoin("tag", "tags", $bag, $src);
120
+ }
121
+ $bag = $src{$src}{GENERIC};
122
+ if (@{$bag}) {
123
+ push @msg, andjoin("commit", "commits", $bag, $src);
124
+ }
125
+ }
126
+ print join("; ", @msg);
127
+ ' "$GIT_DIR"/FETCH_HEAD
128
+ )
129
+ ;;
130
+*)
131
+ merge_name="Merge "$(sed -e 's/^[0-9a-f]* //' \
132
+ "$GIT_DIR"/FETCH_HEAD)
133
+ ;;
134
+esac
135
136
case "$merge_head" in
137
'')
@@ -69,4 +140,4 @@ case "$merge_head" in
140
;;
141
esac
142
72
-git-merge $no_summary $strategy_args "Merge $merge_name" HEAD $merge_head
143
+git-merge $no_summary $strategy_args "$merge_name" HEAD $merge_head