git-tar-tree: no more void pointer arithmetic
[git.git] / git-fmt-merge-msg.perl
index c13af48..5986e54 100755 (executable)
@@ -28,28 +28,13 @@ sub andjoin {
 }
 
 sub repoconfig {
-       my $val;
-       eval {
-               my $pid = open(my $fh, '-|');
-               if (!$pid) {
-                       exec('git-repo-config', '--get', 'merge.summary');
-               }
-               ($val) = <$fh>;
-               close $fh;
-       };
+       my ($val) = qx{git-repo-config --get merge.summary};
        return $val;
 }
 
 sub current_branch {
-       my $fh;
-       my $pid = open($fh, '-|');
-       die "$!" unless defined $pid;
-       if (!$pid) {
-           exec('git-symbolic-ref', 'HEAD') or die "$!";
-       }
-       my ($bra) = <$fh>;
+       my ($bra) = qx{git-symbolic-ref HEAD};
        chomp($bra);
-       close $fh or die "$!";
        $bra =~ s|^refs/heads/||;
        if ($bra ne 'master') {
                $bra = " into $bra";
@@ -61,18 +46,12 @@ sub current_branch {
 
 sub shortlog {
        my ($tip) = @_;
-       my ($fh, @result);
-       my $pid = open($fh, '-|');
-       die "$!" unless defined $pid;
-       if (!$pid) {
-           exec('git-log', '--topo-order',
-                '--pretty=oneline', $tip, '^HEAD') or die "$!";
-       }
-       while (<$fh>) {
+       my @result;
+       foreach ( qx{git-log --no-merges --topo-order --pretty=oneline $tip ^HEAD} ) {
                s/^[0-9a-f]{40}\s+//;
                push @result, $_;
        }
-       close $fh or die "$!";
+       die "git-log failed\n" if $?;
        return @result;
 }
 
@@ -96,6 +75,7 @@ while (<>) {
                $src{$src} = {
                        BRANCH => [],
                        TAG => [],
+                       R_BRANCH => [],
                        GENERIC => [],
                        # &1 == has HEAD.
                        # &2 == has others.
@@ -112,6 +92,11 @@ while (<>) {
                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;
@@ -144,6 +129,8 @@ for my $src (@src) {
        }
        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 ",