# Read .git/FETCH_HEAD and make a human readable merge message
# by grouping branches and tags together to form a single line.
+unshift @INC, '@@INSTLIBDIR@@';
use strict;
+use Git;
+use Error qw(:try);
+
+my $repo = Git->repository();
my @src;
my %src;
}
sub repoconfig {
- my ($val) = qx{git-repo-config --get merge.summary};
+ my $val;
+ try {
+ $val = $repo->command_oneline('repo-config', '--get', 'merge.summary');
+ } catch Git::Error::Command with {
+ my ($E) = shift;
+ if ($E->value() == 1) {
+ return undef;
+ } else {
+ throw $E;
+ }
+ };
return $val;
}
sub current_branch {
- my ($bra) = qx{git-symbolic-ref HEAD};
- chomp($bra);
+ my ($bra) = $repo->command_oneline('symbolic-ref', 'HEAD');
$bra =~ s|^refs/heads/||;
if ($bra ne 'master') {
$bra = " into $bra";
sub shortlog {
my ($tip) = @_;
my @result;
- foreach ( qx{git-log --topo-order --pretty=oneline $tip ^HEAD} ) {
+ foreach ($repo->command('log', '--no-merges', '--topo-order', '--pretty=oneline', $tip, '^HEAD')) {
s/^[0-9a-f]{40}\s+//;
push @result, $_;
}
- die "git-log failed\n" if $?;
return @result;
}
$src{$src} = {
BRANCH => [],
TAG => [],
+ R_BRANCH => [],
GENERIC => [],
# &1 == has HEAD.
# &2 == has others.
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;
}
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 ",
print " ...\n";
last;
}
- print " $log";
+ print " $log\n";
}
}