git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH: simplify calls to git programs in git-fmt-merge-msg
@ 2006-02-23 10:26 Alex Riesen
  2006-02-23 10:35 ` Junio C Hamano
  2006-02-23 12:36 ` Johannes Schindelin
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Riesen @ 2006-02-23 10:26 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]

It also makes it work on ActiveState Perl.

[-- Attachment #2: 0001-fix-git-fmt-merge-msg.perl-for-activestate-perl.txt --]
[-- Type: text/plain, Size: 1470 bytes --]

---

 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
  2006-02-23 10:26 PATCH: simplify calls to git programs in git-fmt-merge-msg Alex Riesen
@ 2006-02-23 10:35 ` Junio C Hamano
  2006-02-23 10:57   ` Alex Riesen
  2006-02-23 12:36 ` Johannes Schindelin
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-02-23 10:35 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git

"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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
  2006-02-23 10:35 ` Junio C Hamano
@ 2006-02-23 10:57   ` Alex Riesen
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Riesen @ 2006-02-23 10:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
  2006-02-23 10:26 PATCH: simplify calls to git programs in git-fmt-merge-msg Alex Riesen
  2006-02-23 10:35 ` Junio C Hamano
@ 2006-02-23 12:36 ` Johannes Schindelin
  2006-02-23 12:40   ` Alex Riesen
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Schindelin @ 2006-02-23 12:36 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Git Mailing List

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
  2006-02-23 12:36 ` Johannes Schindelin
@ 2006-02-23 12:40   ` Alex Riesen
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Riesen @ 2006-02-23 12:40 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Git Mailing List

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).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-23 12:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-23 10:26 PATCH: simplify calls to git programs in git-fmt-merge-msg Alex Riesen
2006-02-23 10:35 ` Junio C Hamano
2006-02-23 10:57   ` Alex Riesen
2006-02-23 12:36 ` Johannes Schindelin
2006-02-23 12:40   ` Alex Riesen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).