@matheusbsbs / matheus-bagliano / commits / a92c73eccc
Fork 0

PATCH: simplify calls to git programs in git-fmt-merge-msg

It also makes it work on ActiveState Perl. Signed-off-by: Junio C Hamano <junkio@cox.net>

Alex Riesen committed Feb 23, 2006 at 11:26 UTC a92c73eccc81b5bfc9e62866505ff1ea72492173
1 file changed +5 -26
git-fmt-merge-msg.perl
+5 -26
@@ -28,28 +28,13 @@ sub andjoin {
28 }
29
30 sub repoconfig {
31 - my $val;
32 - eval {
33 - my $pid = open(my $fh, '-|');
34 - if (!$pid) {
35 - exec('git-repo-config', '--get', 'merge.summary');
36 - }
37 - ($val) = <$fh>;
38 - close $fh;
39 - };
31 + my ($val) = qx{git-repo-config --get merge.summary};
32 return $val;
33 }
34
35 sub current_branch {
44 - my $fh;
45 - my $pid = open($fh, '-|');
46 - die "$!" unless defined $pid;
47 - if (!$pid) {
48 - exec('git-symbolic-ref', 'HEAD') or die "$!";
49 - }
50 - my ($bra) = <$fh>;
36 + my ($bra) = qx{git-symbolic-ref HEAD};
37 chomp($bra);
52 - close $fh or die "$!";
38 $bra =~ s|^refs/heads/||;
39 if ($bra ne 'master') {
40 $bra = " into $bra";
@@ -61,18 +46,12 @@ sub current_branch {
46
47 sub shortlog {
48 my ($tip) = @_;
64 - my ($fh, @result);
65 - my $pid = open($fh, '-|');
66 - die "$!" unless defined $pid;
67 - if (!$pid) {
68 - exec('git-log', '--topo-order',
69 - '--pretty=oneline', $tip, '^HEAD') or die "$!";
70 - }
71 - while (<$fh>) {
49 + my @result;
50 + foreach ( qx{git-log --topo-order --pretty=oneline $tip ^HEAD} ) {
51 s/^[0-9a-f]{40}\s+//;
52 push @result, $_;
53 }
75 - close $fh or die "$!";
54 + die "git-log failed\n" if $?;
55 return @result;
56 }
57