3 # Copyright (c) 2005 Junio C Hamano
5 # Read .git/FETCH_HEAD and make a human readable merge message
6 # by grouping branches and tags together to form a single line.
13 my ($label, $labels, $stuff) = @_;
14 my $l = scalar @
$stuff;
20 $m = "$label$stuff->[0]";
24 join (', ', @
{$stuff}[0..$l-2]) .
31 my ($val) = qx{git
-repo
-config
--get merge
.summary
};
36 my ($bra) = qx{git
-symbolic
-ref HEAD
};
38 $bra =~ s
|^refs
/heads/||;
39 if ($bra ne 'master') {
50 foreach ( qx{git
-log --no-merges
--topo
-order
--pretty
=oneline
$tip ^HEAD
} ) {
54 die "git-log failed\n" if $?
;
60 my ($bname, $tname, $gname, $src, $sha1, $origin);
64 next if (/^not-for-merge/);
73 if (! exists $src{$src}) {
85 if (/^branch (.*)$/) {
87 push @
{$src{$src}{BRANCH
}}, $1;
88 $src{$src}{HEAD_STATUS
} |= 2;
90 elsif (/^tag (.*)$/) {
92 push @
{$src{$src}{TAG
}}, $1;
93 $src{$src}{HEAD_STATUS
} |= 2;
95 elsif (/^remote branch (.*)$/) {
97 push @
{$src{$src}{R_BRANCH
}}, $1;
98 $src{$src}{HEAD_STATUS
} |= 2;
102 $src{$src}{HEAD_STATUS
} |= 1;
105 push @
{$src{$src}{GENERIC
}}, $_;
106 $src{$src}{HEAD_STATUS
} |= 2;
109 if ($src eq '.' || $src eq $origin) {
110 $origin =~ s/^'(.*)'$/$1/;
111 push @origin, [$sha1, "$origin"];
114 push @origin, [$sha1, "$origin of $src"];
120 if ($src{$src}{HEAD_STATUS
} == 1) {
121 # Only HEAD is fetched, nothing else.
126 if ($src{$src}{HEAD_STATUS
} == 3) {
127 # HEAD is fetched among others.
128 push @this, andjoin
('', '', ['HEAD']);
130 push @this, andjoin
("branch ", "branches ",
132 push @this, andjoin
("remote branch ", "remote branches ",
133 $src{$src}{R_BRANCH
});
134 push @this, andjoin
("tag ", "tags ",
136 push @this, andjoin
("commit ", "commits ",
137 $src{$src}{GENERIC
});
138 my $this = join(', ', @this);
145 my $into = current_branch
();
147 print "Merge ", join("; ", @msg), $into, "\n";
153 # We limit the merge message to the latst 20 or so per each branch.
157 my ($sha1, $name) = @
$_;
158 my @log = shortlog
($sha1);
159 if ($limit + 1 <= @log) {
160 print "\n* $name: (" . scalar(@log) . " commits)\n";
163 print "\n* $name:\n";
167 if ($limit < ++$cnt) {