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

5 messages from 2006-02-23 to 2006-02-23. Participants: Alex Riesen, Junio C Hamano, Johannes Schindelin.
Thread: https://gitlist.dev/t/3443

## Alex Riesen, 2006-02-23 10:26

Subject: PATCH: simplify calls to git programs in git-fmt-merge-msg
Message-ID: <81b0412b0602230226j12e88682h303d466a273bec09@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0602230226j12e88682h303d466a273bec09%40mail.gmail.com

```
It also makes it work on ActiveState Perl.


---

 git-fmt-merge-msg.perl |   31 +++++--------------------------
 1 files changed, 5 insertions(+), 26 deletions(-)

1c0dd861fa32017cf7bc4226bfa54d390a3fb91e
diff --git a/git-fmt-merge-msg.perl b/git-fmt-merge-msg.perl
index c13af48..dae383f 100755
--- a/git-fmt-merge-msg.perl
+++ b/git-fmt-merge-msg.perl
@@ -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 --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;
 }
 
-- 
1.2.3.g6ae0e


```

## Junio C Hamano, 2006-02-23 10:35

Subject: Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
Message-ID: <7vslqaicqj.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vslqaicqj.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <81b0412b0602230226j12e88682h303d466a273bec09@mail.gmail.com>

```
"Alex Riesen" <raa.lkml@gmail.com> writes:

> It also makes it work on ActiveState Perl.
>
> ---

ActiveState or not, this simplification is pretty much welcomed.
The only problem I _might_ have later is with shortlog, though I
have not looked at it closely yet.

Thanks.

```

## Alex Riesen, 2006-02-23 10:57

Subject: Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
Message-ID: <81b0412b0602230257h3713e6e8ud11c6aa9547b0d37@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0602230257h3713e6e8ud11c6aa9547b0d37%40mail.gmail.com
In-Reply-To: <7vslqaicqj.fsf@assigned-by-dhcp.cox.net>

```
On 2/23/06, Junio C Hamano <junkio@cox.net> wrote:
>
> > It also makes it work on ActiveState Perl.
> >
> > ---
>
> ActiveState or not, this simplification is pretty much welcomed.
> The only problem I _might_ have later is with shortlog, though I
> have not looked at it closely yet.

I tested it a bit.
I suppose you can have two following concerns there:
- $tip - it seem to be always an sha1
- perl can decide to fetch whole output of git-log into memory.
  I heard it optimizes such cases into reading only when needed...

```

## Johannes Schindelin, 2006-02-23 12:36

Subject: Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
Message-ID: <Pine.LNX.4.63.0602231335420.3726@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0602231335420.3726%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <81b0412b0602230226j12e88682h303d466a273bec09@mail.gmail.com>

```
Hi,

On Thu, 23 Feb 2006, Alex Riesen wrote:

> It also makes it work on ActiveState Perl.

Thank you for teaching me this very valuable construct: qx{ ... }.

Ciao,
Dscho

```

## Alex Riesen, 2006-02-23 12:40

Subject: Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
Message-ID: <81b0412b0602230440j24ab1ecfwf35921236b905f2b@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0602230440j24ab1ecfwf35921236b905f2b%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.63.0602231335420.3726@wbgn013.biozentrum.uni-wuerzburg.de>

```
On 2/23/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> > It also makes it work on ActiveState Perl.
>
> Thank you for teaching me this very valuable construct: qx{ ... }.

You're welcome. That's the same as shells old `` (backquote).

```
