projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Retire git-log.sh (take #4)
[git.git]
/
git-fmt-merge-msg.perl
diff --git
a/git-fmt-merge-msg.perl
b/git-fmt-merge-msg.perl
index
0467a38
..
5986e54
100755
(executable)
--- a/
git-fmt-merge-msg.perl
+++ b/
git-fmt-merge-msg.perl
@@
-28,37
+28,30
@@
sub andjoin {
}
sub repoconfig {
}
sub repoconfig {
- my $fh;
- my $val;
- eval {
- open $fh, '-|', 'git-repo-config', '--get', 'merge.summary'
- or die "$!";
- ($val) = <$fh>;
- close $fh;
- };
+ my ($val) = qx{git-repo-config --get merge.summary};
return $val;
}
return $val;
}
-sub mergebase {
- my ($other) = @_;
- my $fh;
- open $fh, '-|', 'git-merge-base', '--all', 'HEAD', $other or die "$!";
- my (@mb) = map { chomp; $_ } <$fh>;
- close $fh or die "$!";
- return @mb;
+sub current_branch {
+ my ($bra) = qx{git-symbolic-ref HEAD};
+ chomp($bra);
+ $bra =~ s|^refs/heads/||;
+ if ($bra ne 'master') {
+ $bra = " into $bra";
+ } else {
+ $bra = "";
+ }
+ return $bra;
}
sub shortlog {
}
sub shortlog {
- my ($tip, $limit, @base) = @_;
- my ($fh, @result);
- open $fh, '-|', ('git-log', "--max-count=$limit", '--topo-order',
- '--pretty=oneline', $tip, map { "^$_" } @base)
- or die "$!";
- while (<$fh>) {
+ my ($tip) = @_;
+ my @result;
+ foreach ( qx{git-log --no-merges --topo-order --pretty=oneline $tip ^HEAD} ) {
s/^[0-9a-f]{40}\s+//;
push @result, $_;
}
s/^[0-9a-f]{40}\s+//;
push @result, $_;
}
-
close $fh or die "$!"
;
+
die "git-log failed\n" if $?
;
return @result;
}
return @result;
}
@@
-82,6
+75,7
@@
while (<>) {
$src{$src} = {
BRANCH => [],
TAG => [],
$src{$src} = {
BRANCH => [],
TAG => [],
+ R_BRANCH => [],
GENERIC => [],
# &1 == has HEAD.
# &2 == has others.
GENERIC => [],
# &1 == has HEAD.
# &2 == has others.
@@
-98,6
+92,11
@@
while (<>) {
push @{$src{$src}{TAG}}, $1;
$src{$src}{HEAD_STATUS} |= 2;
}
push @{$src{$src}{TAG}}, $1;
$src{$src}{HEAD_STATUS} |= 2;
}
+ elsif (/^remote branch (.*)$/) {
+ $origin = $1;
+ push @{$src{$src}{R_BRANCH}}, $1;
+ $src{$src}{HEAD_STATUS} |= 2;
+ }
elsif (/^HEAD$/) {
$origin = $src;
$src{$src}{HEAD_STATUS} |= 1;
elsif (/^HEAD$/) {
$origin = $src;
$src{$src}{HEAD_STATUS} |= 1;
@@
-130,6
+129,8
@@
for my $src (@src) {
}
push @this, andjoin("branch ", "branches ",
$src{$src}{BRANCH});
}
push @this, andjoin("branch ", "branches ",
$src{$src}{BRANCH});
+ push @this, andjoin("remote branch ", "remote branches ",
+ $src{$src}{R_BRANCH});
push @this, andjoin("tag ", "tags ",
$src{$src}{TAG});
push @this, andjoin("commit ", "commits ",
push @this, andjoin("tag ", "tags ",
$src{$src}{TAG});
push @this, andjoin("commit ", "commits ",
@@
-140,7
+141,10
@@
for my $src (@src) {
}
push @msg, $this;
}
}
push @msg, $this;
}
-print "Merge ", join("; ", @msg), "\n";
+
+my $into = current_branch();
+
+print "Merge ", join("; ", @msg), $into, "\n";
if (!repoconfig) {
exit(0);
if (!repoconfig) {
exit(0);
@@
-151,8
+155,7
@@
my $limit = 20;
for (@origin) {
my ($sha1, $name) = @$_;
for (@origin) {
my ($sha1, $name) = @$_;
- my @mb = mergebase($sha1);
- my @log = shortlog($sha1, $limit + 1, @mb);
+ my @log = shortlog($sha1);
if ($limit + 1 <= @log) {
print "\n* $name: (" . scalar(@log) . " commits)\n";
}
if ($limit + 1 <= @log) {
print "\n* $name: (" . scalar(@log) . " commits)\n";
}