Git development
 help / color / mirror / Atom feed
* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Johannes Schindelin @ 2006-02-23 20:19 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.64.0602231151580.3771@g5.osdl.org>

Hi,

On Thu, 23 Feb 2006, Linus Torvalds wrote:

> On Thu, 23 Feb 2006, Johannes Schindelin wrote:
> > > 
> > > Before anybody mentions tcl ;-).
> > 
> > Darn, I had my suggestion sent out: Java ;-)
> 
> I do see the smileys, but the fact is, "perl" is a hell of a lot more 
> portable than either, if we want to talk executing processes and pipelines 
> etc. But even perl is clearly not portable enough, and has tons of version 
> skew.
> 
> Java, afaik, has absolutely _zero_ support for creating a new process and 
> piping its output to another one and doing things like safe argument 
> expansion. Which is what almost all of the git scripts are all about.

You are right, but for the wrong reason. Java is actually a wonderful 
thing to create new processes and talk between threads.

But Java is HUGE. No, it is rather HOOODGEEE.

And I don't know if something like Lua does any good. The problem is not 
so much the language. It is the fork().

AFAIAC, cygwin is pretty good at hiding Windows behind sortofa POSIX 
layer. <tongue-in-cheek>It hides it behind a POSIX layer *and* a 
performance hit.</tongue-in-cheek>

I would rather like to see how all the fork()ing and |'ing can be done 
with MinGW32.

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Linus Torvalds @ 2006-02-23 19:54 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.63.0602232037260.30630@wbgn013.biozentrum.uni-wuerzburg.de>



On Thu, 23 Feb 2006, Johannes Schindelin wrote:
> > 
> > Before anybody mentions tcl ;-).
> 
> Darn, I had my suggestion sent out: Java ;-)

I do see the smileys, but the fact is, "perl" is a hell of a lot more 
portable than either, if we want to talk executing processes and pipelines 
etc. But even perl is clearly not portable enough, and has tons of version 
skew.

Java, afaik, has absolutely _zero_ support for creating a new process and 
piping its output to another one and doing things like safe argument 
expansion. Which is what almost all of the git scripts are all about.

		Linus

^ permalink raw reply

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Linus Torvalds @ 2006-02-23 19:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7virr5hnw4.fsf@assigned-by-dhcp.cox.net>



On Thu, 23 Feb 2006, Junio C Hamano wrote:
>
> Linus Torvalds <torvalds@osdl.org> writes: 
> > There are many portable interpreters out there, and I don't mean perl. And 
> > writing a small "specialized for git" one isn't even that hard. In fact, 
> > most of the shell (and bash) hackery we do now would be unnecessary if we 
> > just made a small "git interpreter" that ran "git scripts".
> 
> Before anybody mentions tcl ;-).

Well, I was thinking more of the "embeddable" ones - things that are so 
small that they can be compiled with the project. Things like Lua.

Now, Lua is not really very useful for this use case: our scripts are much 
more about combining other programs - piping the output from one to the 
other - than about any traditional scripting. Which, afaik, Lua isn't good 
at.

> I agree with the above in principle, but I am afraid that is
> only half of the solution to the problem Alex is having.
> 
> In the longer term, libified git with script language bindings
> would make the way git things work together a lot better.  I've
> always wanted to make merge-base a subroutine callable from
> other things, so that I can say "git diff A...B" to mean "diff
> up to B since B forked from A" ;-).

Yeah, we should libify some of it, to make things easier. That said, I 
don't belive in the "big-picture" libification. The fact is, a lot of git 
really _is_ about piping things from one part to another, and library 
interfaces work horribly badly for that. You really want more of a 
"stream" interface, and that's just not something I see happening.

I think one of the strengths of git is that you can use it in a very 
traditional UNIX manner, and do your own pipelines. And that will 
obviously NEVER work well under Windows, if only because it's not the 
natural way to do things.

Again, libification does nothing for that thing.

What I'd suggest using an embedded interpreter for is literally just the 
common helper scripts. We'll never make 

	git-rev-list --header a..b -- tree | 
		grep -z '^author.*torvalds' |
		..

style interesting power-user pipelines work in windows, but we _can_ make 
the things like "git commit" work natively in windows without having to 
re-write it in C by just having an embedded interpreter.

And I very much mean _embedded_. Otherwise we'll just have all the same 
problems with perl and bash and versioning. 

> But we do need to talk to non-git things.  git-grep needs a way
> for ls-files to drive xargs/grep, for example.  diff --cc reads
> from GNU diff output.  And for these external tools, the way
> they expect the input to be fed to them or their output is taken
> out is via UNIXy pipe.

I was really thinking more of a simple shell-like script interpreter. 
Something that we can make portable, by virtue of it _not_ being real 
shell. For example, the "find | xargs" stuff we do is really not that hard 
to do portably even on windows using standard C, it's just that you can't 
do it THAT WAY portably without assuming that it's a full cygwin thing.

		Linus

^ permalink raw reply

* Re: [PATCH] Convert open("-|") to qx{} calls
From: Johannes Schindelin @ 2006-02-23 19:41 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Junio C Hamano, Alex Riesen, git
In-Reply-To: <863bi9hq6u.fsf@blue.stonehenge.com>

Hi,

On Thu, 23 Feb 2006, Randal L. Schwartz wrote:

> >>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:
> 
> Junio> The version of Perl Alex has to use claims to be 5.8, but does
> Junio> not understand open($kid, '-|'), and he is trying to come up
> Junio> with a workaround.
> 
> Ahh, the problem is activestate then.  If that's the case, then amend 
> the code with a check for $^O (operating system) that falls back to a qx 
> if on activestate, and hope that filenames aren't a problem.  
> Unfortunately, I don't know enough about that to fix it.

Now that our local Perl guru joined the discussion, may I ask what is, and 
what is not quoted when put inside qx{}? I had the impression that all 
arguments are quoted, except that variables are resolved first. Was that 
wrong? IOW does

	qx{bash $variable}

quote the value of $variable, or not?

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Johannes Schindelin @ 2006-02-23 19:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Linus Torvalds, git
In-Reply-To: <7virr5hnw4.fsf@assigned-by-dhcp.cox.net>

Hi,

On Thu, 23 Feb 2006, Junio C Hamano wrote:

> Linus Torvalds <torvalds@osdl.org> writes:
> 
> > There are many portable interpreters out there, and I don't mean perl. And 
> > writing a small "specialized for git" one isn't even that hard. In fact, 
> > most of the shell (and bash) hackery we do now would be unnecessary if we 
> > just made a small "git interpreter" that ran "git scripts".
> 
> Before anybody mentions tcl ;-).

Darn, I had my suggestion sent out: Java ;-)

Ciao,
Dscho

^ permalink raw reply

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Junio C Hamano @ 2006-02-23 19:32 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0602230911410.3771@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> There are many portable interpreters out there, and I don't mean perl. And 
> writing a small "specialized for git" one isn't even that hard. In fact, 
> most of the shell (and bash) hackery we do now would be unnecessary if we 
> just made a small "git interpreter" that ran "git scripts".

Before anybody mentions tcl ;-).

I agree with the above in principle, but I am afraid that is
only half of the solution to the problem Alex is having.

In the longer term, libified git with script language bindings
would make the way git things work together a lot better.  I've
always wanted to make merge-base a subroutine callable from
other things, so that I can say "git diff A...B" to mean "diff
up to B since B forked from A" ;-).

That way, we would eliminate the current common pattern of
piping rev-list output to diff-tree, or ls-files/diff-files
output to update-index --stdin.  These components live in the
single process, a calling "git script", and will talk with each
other internally.

But we do need to talk to non-git things.  git-grep needs a way
for ls-files to drive xargs/grep, for example.  diff --cc reads
from GNU diff output.  And for these external tools, the way
they expect the input to be fed to them or their output is taken
out is via UNIXy pipe.

And the breakage Alex wants to work around is that the platform
is not friendly to pipes, if you deny Cygwin.  So I suspect
avoiding shell would not help much.

^ permalink raw reply

* gitview: Display the lines joining commit nodes clearly.
From: Aneesh Kumar K.V @ 2006-02-23 19:29 UTC (permalink / raw)
  To: git, Junio C Hamano, Aneesh Kumar K.V

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



[-- Attachment #2: 0001-gitview-Display-the-lines-joining-commit-nodes-clearly.txt --]
[-- Type: text/plain, Size: 3255 bytes --]


Since i wanted to limit the graph box size i was resetting
the window after an index of 5. This result in line joining
commit nodes to pass over nodes which are not related. The
changes fixes the same

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@gmail.com>

---

 contrib/gitview/gitview |   48 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 35 insertions(+), 13 deletions(-)

3fcd411c65b2c6f84052d69ca05766e45a34682e
diff --git a/contrib/gitview/gitview b/contrib/gitview/gitview
index 4b52eb7..b04df74 100755
--- a/contrib/gitview/gitview
+++ b/contrib/gitview/gitview
@@ -823,6 +823,7 @@ class GitView:
 		self.colours = {}
 		self.nodepos = {}
 		self.incomplete_line = {}
+		self.commits = []
 
 		index = 0
 		last_colour = 0
@@ -840,12 +841,7 @@ class GitView:
 
 			commit = Commit(commit_lines)
 			if (commit != None ):
-				(out_line, last_colour, last_nodepos) = self.draw_graph(commit,
-										index, out_line,
-										last_colour,
-										last_nodepos)
-				self.index[commit.commit_sha1] = index
-				index += 1
+				self.commits.append(commit)
 
 			# Skip the '\0
 			commit_lines = []
@@ -854,6 +850,14 @@ class GitView:
 
 		fp.close()
 
+		for commit in self.commits:
+			(out_line, last_colour, last_nodepos) = self.draw_graph(commit,
+										index, out_line,
+										last_colour,
+										last_nodepos)
+			self.index[commit.commit_sha1] = index
+			index += 1
+
 		self.treeview.set_model(self.model)
 		self.treeview.show()
 
@@ -869,13 +873,6 @@ class GitView:
 			last_nodepos = 0
 
 		# Add the incomplete lines of the last cell in this
-		for sha1 in self.incomplete_line.keys():
-			if ( sha1 != commit.commit_sha1):
-				for pos in self.incomplete_line[sha1]:
-					in_line.append((pos, pos, self.colours[sha1]))
-			else:
-				del self.incomplete_line[sha1]
-
 		try:
 			colour = self.colours[commit.commit_sha1]
 		except KeyError:
@@ -897,6 +894,14 @@ class GitView:
 			self.colours[commit.parent_sha1[0]] = colour
 			self.nodepos[commit.parent_sha1[0]] = node_pos
 
+		for sha1 in self.incomplete_line.keys():
+			if ( sha1 != commit.commit_sha1):
+				self.draw_incomplete_line(sha1, node_pos,
+						out_line, in_line, index)
+			else:
+				del self.incomplete_line[sha1]
+
+
 		in_line.append((node_pos, self.nodepos[commit.parent_sha1[0]],
 					self.colours[commit.parent_sha1[0]]))
 
@@ -936,6 +941,23 @@ class GitView:
 		except KeyError:
 			self.incomplete_line[sha1] = [self.nodepos[sha1]]
 
+	def draw_incomplete_line(self, sha1, node_pos, out_line, in_line, index):
+		for idx, pos in enumerate(self.incomplete_line[sha1]):
+			if(pos == node_pos):
+				out_line.append((pos,
+					pos+0.5, self.colours[sha1]))
+				self.incomplete_line[sha1][idx] = pos = pos+0.5
+			try:
+				next_commit = self.commits[index+1]
+				if (next_commit.commit_sha1 == sha1 and pos != int(pos)):
+				# join the line back to the node point 
+				# This need to be done only if we modified it
+					in_line.append((pos, pos-0.5, self.colours[sha1]))
+					continue;
+			except IndexError:
+				pass
+			in_line.append((pos, pos, self.colours[sha1]))
+
 
 	def _go_clicked_cb(self, widget, revid):
 		"""Callback for when the go button for a parent is clicked."""
-- 
1.2.3.g2cf3-dirty


^ permalink raw reply related

* Re: [PATCH] Convert open("-|") to qx{} calls
From: Randal L. Schwartz @ 2006-02-23 18:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Alex Riesen, Johannes Schindelin, git
In-Reply-To: <7v1wxuhsgw.fsf@assigned-by-dhcp.cox.net>

>>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:

Junio> The version of Perl Alex has to use claims to be 5.8, but does
Junio> not understand open($kid, '-|'), and he is trying to come up
Junio> with a workaround.

Ahh, the problem is activestate then.  If that's the case, then amend the code
with a check for $^O (operating system) that falls back to a qx if on
activestate, and hope that filenames aren't a problem.  Unfortunately, I don't
know enough about that to fix it.

But whatever you do, *don't* replace safe_qx with qx() for all other systems,
or you'll be opening up a can of worms for those of us on sensible systems.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

^ permalink raw reply

* Re: [PATCH] Convert open("-|") to qx{} calls
From: Junio C Hamano @ 2006-02-23 17:53 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Alex Riesen, Johannes Schindelin, git
In-Reply-To: <86hd6qgit5.fsf@blue.stonehenge.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

> Convert all of these to use "safe_qx" (perl 5.6 compatible):
>
>     sub safe_qx {
>       defined (my $pid = open my $kid, "-|") or die "Cannot fork: $!";
>...

IIRC, that is backwards.  The thread's conversion is not about
5.6 vs 5.8.  The conversion like what you suggested above was
done, but the thing is, and Alex's Perl is unhappy about it.

The version of Perl Alex has to use claims to be 5.8, but does
not understand open($kid, '-|'), and he is trying to come up
with a workaround.

I wish Perl had a stricter trademark policy that required
language features to be fully ported for an implementation to
use that name ;-).

^ permalink raw reply

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Linus Torvalds @ 2006-02-23 17:13 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Andreas Ericsson, Junio C Hamano, git
In-Reply-To: <81b0412b0602230607n22146a77k36929f0ad9e44d53@mail.gmail.com>



On Thu, 23 Feb 2006, Alex Riesen wrote:
>
> Someday we'll have to start dropping features on Windows or restrict them
> beyond their usefullness.

One thing that would help a bit would be to avoid shell.

There are many portable interpreters out there, and I don't mean perl. And 
writing a small "specialized for git" one isn't even that hard. In fact, 
most of the shell (and bash) hackery we do now would be unnecessary if we 
just made a small "git interpreter" that ran "git scripts".

The fact that it would also help portability is just an added advantage.

		Linus

^ permalink raw reply

* Re: [PATCH] Convert open("-|") to qx{} calls
From: Randal L. Schwartz @ 2006-02-23 16:07 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Johannes Schindelin, git, junkio
In-Reply-To: <81b0412b0602230738s3445bd86h2d1d670e0ef5daed@mail.gmail.com>

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

Alex> Is $tmpname safe?

>> -       my $sha = <$F>;
>> +       my $sha = qx{git-hash-object -w $name};
>> +       !$? or exit $?;

Alex> Is $name safe?

>> -       while(<$f>) {
>> +       foreach (qx{git-ls-tree -r -z $gitrev $srcpath}) {
>> chomp;

Alex> Is $srcpath safe?

>> -                       while(<$F>) {
>> +                       foreach (qx{git-ls-files -z @o1}) {

Alex> @o1 must contain filenames. Can be dangerous

Convert all of these to use "safe_qx" (perl 5.6 compatible):

    sub safe_qx {
      defined (my $pid = open my $kid, "-|") or die "Cannot fork: $!";
      unless ($pid) { # child does:
        exec @_;
        die "Cannot exec @_: $!";
      }
      my $result = do { local $/; <$kid> };
      close $kid;                   # sets $?
      return $result;
    }

my $result = safe_qx('some shell command');
my $other_result = safe_qx('git-ls-tree', '-r', '-z', $gitrev, $srcpath);

Args are safe, as if being passed to system/exec, so a single arg
can be a shell command, multiargs are passed arg-by-arg to a single
exec target.  $? is set correctly.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

^ permalink raw reply

* Re: [PATCH] Convert open("-|") to qx{} calls
From: Alex Riesen @ 2006-02-23 15:38 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio
In-Reply-To: <Pine.LNX.4.63.0602231532470.29635@wbgn013.biozentrum.uni-wuerzburg.de>

On 2/23/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>       Since of these 4, I only use cvsimport myself, I could only test
>       that. Could someone who uses the others give them a hard beating?

I can't really test them (no svn and cvs, and locked down network), but I took
a look at the patches. Hope it helps.

git-cvsimport:

> -               open(F,"git-cat-file commit $ftag |");
> -               while(<F>) {
> +               foreach (qx{git-cat-file commit $ftag}) {
>                         next unless /^author\s.*\s(\d+)\s[-+]\d{4}$/;

Are you sure you don't need quoting/safe pipe here?
Or is it a CVS tag?

> +} else {
> +    @input = qx{cvsps --norc opt -u -A --root $opt_d $cvs_tree};
> +    !$? or exit $?;

Same here. $cvs_tree can contain any filesystem-allowed character.

git-svnimport:

> -                       my $sha = <$F>;
> +                       my $sha = qx{git-hash-object -w $tmpname};
> +                       !$? or exit $?;

Is $tmpname safe?

> -       my $sha = <$F>;
> +       my $sha = qx{git-hash-object -w $name};
> +       !$? or exit $?;

Is $name safe?

> -       while(<$f>) {
> +       foreach (qx{git-ls-tree -r -z $gitrev $srcpath}) {
>                 chomp;

Is $srcpath safe?

> -                       while(<$F>) {
> +                       foreach (qx{git-ls-files -z @o1}) {

@o1 must contain filenames. Can be dangerous

^ permalink raw reply

* FYI: git-am allows creation of empty commits.
From: Eric W. Biederman @ 2006-02-23 15:33 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano


Currently I am using: git version 1.2.2.g709a.

I have been rebasing and refactoring a number of patchsets using git.

Frequently because of prior edits I will git a patch that does not
apply at all.  So all I get is the creation of the .dotest directory.
The automatic merge logic does not kick in, so I have to manually
call patch -p1 and resolve the differences but hand.  There everything
is expected and fine.  Although it might have been nice to have one
of those failed merge indicators in the index.

After fixing it up and doing all of my edits I occasionally forget
the git-update-index step, before calling git-am --resolved.  This
proceeds along it's merry way and creates an empty commit.

Is this the expected correct behavior or should git-am complain about
a situation like that?

Eric

^ permalink raw reply

* Re: [PATCH] Port git-annotate to qx{} syntax, and make default output more like CVS
From: Alex Riesen @ 2006-02-23 15:08 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, junkio
In-Reply-To: <Pine.LNX.4.63.0602231442390.24946@wbgn013.biozentrum.uni-wuerzburg.de>

On 2/23/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
>
> This uses the qx{} syntax Alex digged up, and it makes output without "-l"
> quite similar to CVS's annotate output.
>

Works here.

^ permalink raw reply

* [PATCH] Convert open("-|") to qx{} calls
From: Johannes Schindelin @ 2006-02-23 14:33 UTC (permalink / raw)
  To: git, junkio


Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

	Since of these 4, I only use cvsimport myself, I could only test
	that. Could someone who uses the others give them a hard beating?

 git-cvsimport.perl  |   64 +++++++++++++++++++--------------------------------
 git-rerere.perl     |    9 ++-----
 git-send-email.perl |    9 ++-----
 git-svnimport.perl  |   62 ++++++++++++++-----------------------------------
 4 files changed, 46 insertions(+), 98 deletions(-)

b37d21c223fdc0ef7fc6af889432f6b51ac82992
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index b46469a..da009f2 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -478,9 +478,9 @@ unless(-d $git_dir) {
 		       "Either use the correct '-o branch' option,\n".
 		       "or import to a new repository.\n";
 
-	open(F, "git-symbolic-ref HEAD |") or
-		die "Cannot run git-symbolic-ref: $!\n";
-	chomp ($last_branch = <F>);
+	$last_branch = qx{git-symbolic-ref HEAD};
+	!$? or exit $?;
+	chomp ($last_branch);
 	$last_branch = basename($last_branch);
 	close(F);
 	unless($last_branch) {
@@ -516,13 +516,12 @@ EOM
 			or die "Bad head branch: $head: $!\n";
 		chomp(my $ftag = <F>);
 		close(F);
-		open(F,"git-cat-file commit $ftag |");
-		while(<F>) {
+		foreach (qx{git-cat-file commit $ftag}) {
 			next unless /^author\s.*\s(\d+)\s[-+]\d{4}$/;
 			$branch_date{$head} = $1;
 			last;
 		}
-		close(F);
+		!$? or exit $?;
 	}
 	closedir(D);
 }
@@ -538,24 +537,21 @@ if ($opt_A) {
 	write_author_info("$git_dir/cvs-authors");
 }
 
-my $pid = open(CVS,"-|");
-die "Cannot fork: $!\n" unless defined $pid;
-unless($pid) {
-	my @opt;
-	@opt = split(/,/,$opt_p) if defined $opt_p;
-	unshift @opt, '-z', $opt_z if defined $opt_z;
-	unshift @opt, '-q'         unless defined $opt_v;
-	unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
-		push @opt, '--cvs-direct';
-	}
-	if ($opt_P) {
-	    exec("cat", $opt_P);
-	} else {
-	    exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree);
-	    die "Could not start cvsps: $!\n";
-	}
+my @opt;
+@opt = split(/,/,$opt_p) if defined $opt_p;
+unshift @opt, '-z', $opt_z if defined $opt_z;
+unshift @opt, '-q'         unless defined $opt_v;
+unless (defined($opt_p) && $opt_p =~ m/--no-cvs-direct/) {
+	push @opt, '--cvs-direct';
 }
 
+my @input;
+if ($opt_P) {
+    @input = qx{cat $opt_P};
+} else {
+    @input = qx{cvsps --norc opt -u -A --root $opt_d $cvs_tree};
+    !$? or exit $?;
+}
 
 ## cvsps output:
 #---------------------
@@ -603,17 +599,11 @@ my $commit = sub {
 		die "Cannot add files: $?\n" if $?;
 	}
 
-	$pid = open(C,"-|");
-	die "Cannot fork: $!" unless defined $pid;
-	unless($pid) {
-		exec("git-write-tree");
-		die "Cannot exec git-write-tree: $!\n";
-	}
-	chomp(my $tree = <C>);
+	my $tree = qx{git-write-tree};
+	!$? or exit $?;
+	chomp($tree);
 	length($tree) == 40
 		or die "Cannot get tree id ($tree): $!\n";
-	close(C)
-		or die "Error running git-write-tree: $?\n";
 	print "Tree ID $tree\n" if $opt_v;
 
 	my $parent = "";
@@ -734,7 +724,7 @@ my $commit = sub {
 	}
 };
 
-while(<CVS>) {
+foreach (@input) {
 	chomp;
 	if($state == 0 and /^-+$/) {
 		$state = 1;
@@ -846,15 +836,9 @@ while(<CVS>) {
 			print "Drop $fn\n" if $opt_v;
 		} else {
 			print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v;
-			my $pid = open(my $F, '-|');
-			die $! unless defined $pid;
-			if (!$pid) {
-			    exec("git-hash-object", "-w", $tmpname)
-				or die "Cannot create object: $!\n";
-			}
-			my $sha = <$F>;
+			my $sha = qx{git-hash-object -w $tmpname};
+			!$? or exit $?;
 			chomp $sha;
-			close $F;
 			my $mode = pmode($cvs->{'mode'});
 			push(@new,[$mode, $sha, $fn]); # may be resurrected!
 		}
diff --git a/git-rerere.perl b/git-rerere.perl
index d3664ff..0dd04c5 100755
--- a/git-rerere.perl
+++ b/git-rerere.perl
@@ -131,20 +131,15 @@ sub record_preimage {
 sub find_conflict {
 	my $in;
 	local $/ = "\0";
-	my $pid = open($in, '-|');
-	die "$!" unless defined $pid;
-	if (!$pid) {
-		exec(qw(git ls-files -z -u)) or die "$!: ls-files";
-	}
 	my %path = ();
 	my @path = ();
-	while (<$in>) {
+	foreach (qx{git-ls-files -z -u}) {
 		chomp;
 		my ($mode, $sha1, $stage, $path) =
 		    /^([0-7]+) ([0-9a-f]{40}) ([123])\t(.*)$/s;
 		$path{$path} |= (1 << $stage);
 	}
-	close $in;
+	!$? or exit $?;
 	while (my ($path, $status) = each %path) {
 		if ($status == 14) { push @path, $path; }
 	}
diff --git a/git-send-email.perl b/git-send-email.perl
index b0d095b..bd8fae6 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -62,13 +62,8 @@ my $rc = GetOptions("from=s" => \$from,
 sub gitvar {
     my ($var) = @_;
     my $fh;
-    my $pid = open($fh, '-|');
-    die "$!" unless defined $pid;
-    if (!$pid) {
-	exec('git-var', $var) or die "$!";
-    }
-    my ($val) = <$fh>;
-    close $fh or die "$!";
+    my ($val) = qx{git-var $var};
+    !$? or exit $?;
     chomp($val);
     return $val;
 }
diff --git a/git-svnimport.perl b/git-svnimport.perl
index ee2940f..6094a11 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -218,11 +218,10 @@ unless(-d $git_dir) {
 	-f "$git_dir/svn2git"
 		or die "'$git_dir/svn2git' does not exist.\n".
 		       "You need that file for incremental imports.\n";
-	open(F, "git-symbolic-ref HEAD |") or
-		die "Cannot run git-symbolic-ref: $!\n";
-	chomp ($last_branch = <F>);
+	$last_brach = qx{git-symbolic-ref HEAD};
+	!$? or exit $?;
+	chomp $last_branch;
 	$last_branch = basename($last_branch);
-	close(F);
 	unless($last_branch) {
 		warn "Cannot read the last branch name: $! -- assuming 'master'\n";
 		$last_branch = "master";
@@ -321,15 +320,9 @@ sub get_file($$$) {
 		return undef unless defined $name;
 	}
 
-	my $pid = open(my $F, '-|');
-	die $! unless defined $pid;
-	if (!$pid) {
-	    exec("git-hash-object", "-w", $name)
-		or die "Cannot create object: $!\n";
-	}
-	my $sha = <$F>;
+	my $sha = qx{git-hash-object -w $name};
+	!$? or exit $?;
 	chomp $sha;
-	close $F;
 	unlink $name;
 	my $mode = "0644"; # SV does not seem to store any file modes
 	return [$mode, $sha, $path];
@@ -401,14 +394,8 @@ sub copy_path($$$$$$$$) {
 			$srcpath =~ s#/*$#/#;
 	}
 	
-	my $pid = open my $f,'-|';
-	die $! unless defined $pid;
-	if (!$pid) {
-		exec("git-ls-tree","-r","-z",$gitrev,$srcpath)
-			or die $!;
-	}
 	local $/ = "\0";
-	while(<$f>) {
+	foreach (qx{git-ls-tree -r -z $gitrev $srcpath}) {
 		chomp;
 		my($m,$p) = split(/\t/,$_,2);
 		my($mode,$type,$sha1) = split(/ /,$m);
@@ -420,8 +407,7 @@ sub copy_path($$$$$$$$) {
 		}
 		push(@$new,[$mode,$sha1,$p]);	
 	}
-	close($f) or
-		print STDERR "$newrev:$newbranch: could not list files in $oldpath \@ $rev\n";
+	!$? or exit $?;
 }
 
 sub commit {
@@ -472,9 +458,8 @@ sub commit {
 
 	my $rev;
 	if($revision > $opt_s and defined $parent) {
-		open(H,"git-rev-parse --verify $parent |");
-		$rev = <H>;
-		close(H) or do {
+		$rev = qx{git-rev-parse --verify $parent};
+		!$? or do {
 			print STDERR "$revision: cannot find commit '$parent'!\n";
 			return;
 		};
@@ -555,25 +540,20 @@ sub commit {
 		}
 
 		while(@old) {
-			my @o1;
+			my @o2;
 			if(@old > 55) {
-				@o1 = splice(@old,0,50);
+				@o2 = splice(@old,0,50);
 			} else {
-				@o1 = @old;
+				@o2 = @old;
 				@old = ();
 			}
-			my $pid = open my $F, "-|";
-			die "$!" unless defined $pid;
-			if (!$pid) {
-				exec("git-ls-files", "-z", @o1) or die $!;
-			}
-			@o1 = ();
+			my @o1 = ();
 			local $/ = "\0";
-			while(<$F>) {
+			foreach (qx{git-ls-files -z @o1}) {
 				chomp;
 				push(@o1,$_);
 			}
-			close($F);
+			!$? or exit $?;
 
 			while(@o1) {
 				my @o2;
@@ -600,17 +580,11 @@ sub commit {
 			die "Cannot add files: $?\n" if $?;
 		}
 
-		my $pid = open(C,"-|");
-		die "Cannot fork: $!" unless defined $pid;
-		unless($pid) {
-			exec("git-write-tree");
-			die "Cannot exec git-write-tree: $!\n";
-		}
-		chomp(my $tree = <C>);
+		my $tree = qx{git-write-tree};
+		!$? or exit $?;
+		chomp($tree);
 		length($tree) == 40
 			or die "Cannot get tree id ($tree): $!\n";
-		close(C)
-			or die "Error running git-write-tree: $?\n";
 		print "Tree ID $tree\n" if $opt_v;
 
 		my $pr = IO::Pipe->new() or die "Cannot open pipe: $!\n";
-- 
1.2.3.gb37d

^ permalink raw reply related

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Andreas Ericsson @ 2006-02-23 14:22 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, git
In-Reply-To: <81b0412b0602230607n22146a77k36929f0ad9e44d53@mail.gmail.com>

Alex Riesen wrote:
> On 2/23/06, Andreas Ericsson <ae@op5.se> wrote:
> 
>>If we claim to support windows but do a poor job of it, no-one else will
>>start working on a windows-port. If we don't claim to support windows
>>but say that "it's known to work with cygwin, although be aware of these
>>performance penalties...", eventually someone will come along with their
>>shiny Visual Express and hack up support for it, even if some tools will
>>be missing and others unnecessarily complicated.
> 
> 
> That seem to be the case, except for shiny.
> (I really don't know what could possibly mean by that. It stinks, smears,
> and sometimes bounces. Never saw it shining).
> 

The logo has a little glint thing on it, like those things that go 
'ting' on a front tooth in commercials for toothpaste and particularly 
healthy chewing gum.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Alex Riesen @ 2006-02-23 14:07 UTC (permalink / raw)
  To: Andreas Ericsson; +Cc: Junio C Hamano, git
In-Reply-To: <43FDB8CC.5000503@op5.se>

On 2/23/06, Andreas Ericsson <ae@op5.se> wrote:
> >
> >>Not to be unhelpful or anything, but activestate perl seems to be quite
> >>a lot of bother. Is it worth supporting it?
> >
> >
> > It's not activestate perl actually. It's only one platform it also
> > _has_ to support.
> > Is it worth supporting Windows?
>
> With or without cygwin? With cygwin, I'd say "yes, unless it makes
> things terribly difficult to maintain and so long as we don't take
> performance hits on unices". Without cygwin, I'd say "What? It runs on
> windows?".

There not much difference with or without cygwin. The penalties of
doing any kind of support for it will pile up (as they started to do
with pipes).
Someday we'll have to start dropping features on Windows or restrict them
beyond their usefullness. The fork emulation in cygwin isn't perfect,
signals do not work reliably (if at all), filesystem is slow and locked down,
and exec-attribute is NOT really useful even on NTFS (it is somehow related
to execute permission and open files. I still cannot figure out how exactly
are they related).

> If we claim to support windows but do a poor job of it, no-one else will
> start working on a windows-port. If we don't claim to support windows
> but say that "it's known to work with cygwin, although be aware of these
> performance penalties...", eventually someone will come along with their
> shiny Visual Express and hack up support for it, even if some tools will
> be missing and others unnecessarily complicated.

That seem to be the case, except for shiny.
(I really don't know what could possibly mean by that. It stinks, smears,
and sometimes bounces. Never saw it shining).

^ permalink raw reply

* [PATCH] Port git-annotate to qx{} syntax, and make default output more like CVS
From: Johannes Schindelin @ 2006-02-23 13:53 UTC (permalink / raw)
  To: git, junkio


This uses the qx{} syntax Alex digged up, and it makes output without "-l"
quite similar to CVS's annotate output.

Oh, and it ignores a dirty work file. In fact, it even ignores a clean 
work file, but fetches a clean version from the repository.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

 git-annotate.perl |   82 +++++++++++++++++++++++++----------------------------
 1 files changed, 38 insertions(+), 44 deletions(-)

diff --git a/git-annotate.perl b/git-annotate.perl
index 3800c46..e9e5a3d 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -37,14 +37,14 @@ my @stack = (
 
 our (@lineoffsets, @pendinglineoffsets);
 our @filelines = ();
-open(F,"<",$filename)
-	or die "Failed to open filename: $!";
 
-while(<F>) {
+our $blob_sha1 = qx{git-ls-tree HEAD "$filename"};
+$blob_sha1 =~ s/^.*blob (\S*).*$/$1/;
+foreach (qx{git-cat-file blob $blob_sha1}) {
 	chomp;
 	push @filelines, $_;
 }
-close(F);
+!$? or exit $?;
 our $leftover_lines = @filelines;
 our %revs;
 our @revqueue;
@@ -91,13 +91,12 @@ foreach my $l (@filelines) {
 		if (!$opt_l && length($rev) > 8) {
 			$rev = substr($rev,0,8);
 		}
+		printf("%s\t(%10s\t%s):%s\n", $rev, $committer,
+			format_date($date), $output);
 	} else {
-		$output = $l;
-		($rev, $committer, $date) = ('unknown', 'unknown', 'unknown');
+		printf("%s\t(%10s\t%10s\t%d)%s\n", $rev, $committer,
+			format_date($date), $i++, $output);
 	}
-
-	printf("%s\t(%10s\t%10s\t%d)%s\n", $rev, $committer,
-		format_date($date), $i++, $output);
 }
 
 sub init_claim {
@@ -143,20 +142,24 @@ sub handle_rev {
 sub git_rev_list {
 	my ($rev, $file) = @_;
 
+	my @revs;
 	if ($opt_S) {
 		open(P, '<' . $opt_S);
+		while(my $line = <P>) {
+			chomp $line;
+			my ($rev, @parents) = split /\s+/, $line;
+			push @revs, [ $rev, @parents ];
+		}
+		close(P);
 	} else {
-		open(P,"-|","git-rev-list","--parents","--remove-empty",$rev,"--",$file)
-			or die "Failed to exec git-rev-list: $!";
-	}
-
-	my @revs;
-	while(my $line = <P>) {
-		chomp $line;
-		my ($rev, @parents) = split /\s+/, $line;
-		push @revs, [ $rev, @parents ];
+		foreach (qx{git-rev-list --parents --remove-empty $rev -- $file}
+) {
+			chomp $_;
+			my ($rev, @parents) = split /\s+/, $_;
+			push @revs, [ $rev, @parents ];
+		}
+		!$? or exit $?;
 	}
-	close(P);
 
 	printf("0 revs found for rev %s (%s)\n", $rev, $file) if (@revs == 0);
 	return @revs;
@@ -165,13 +168,11 @@ sub git_rev_list {
 sub find_parent_renames {
 	my ($rev, $file) = @_;
 
-	open(P,"-|","git-diff-tree", "-M50", "-r","--name-status", "-z","$rev")
-		or die "Failed to exec git-diff: $!";
-
 	local $/ = "\0";
 	my %bound;
 	my $junk = <P>;
-	while (my $change = <P>) {
+	foreach (qx{git-diff-tree -M50 -r --name-status -z $rev}) {
+		my $change = $_;
 		chomp $change;
 		my $filename = <P>;
 		chomp $filename;
@@ -189,7 +190,7 @@ sub find_parent_renames {
 			}
 		}
 	}
-	close(P);
+	!$? or exit $?;
 
 	return \%bound;
 }
@@ -198,15 +199,12 @@ sub find_parent_renames {
 sub git_find_parent {
 	my ($rev, $filename) = @_;
 
-	open(REVPARENT,"-|","git-rev-list","--remove-empty", "--parents","--max-count=1","$rev","--",$filename)
-		or die "Failed to open git-rev-list to find a single parent: $!";
+	my $parentline = qx{git-rev-list --remove-empty --parents --max-count=1 $rev -- $filename};
+	!$? or die "Failed to open git-rev-list to find a single parent: $!";
 
-	my $parentline = <REVPARENT>;
 	chomp $parentline;
 	my ($revfound,$parent) = split m/\s+/, $parentline;
 
-	close(REVPARENT);
-
 	return $parent;
 }
 
@@ -217,17 +215,13 @@ sub git_diff_parse {
 	my ($parent, $rev, %revinfo) = @_;
 
 	my ($ri, $pi) = (0,0);
-	open(DIFF,"-|","git-diff-tree","-M","-p",$rev,$parent,"--",
-			$revs{$rev}{'filename'}, $revs{$parent}{'filename'})
-		or die "Failed to call git-diff for annotation: $!";
-
 	my $slines = $revs{$rev}{'lines'};
 	my @plines;
 
 	my $gotheader = 0;
 	my ($remstart, $remlength, $addstart, $addlength);
 	my ($hunk_start, $hunk_index, $hunk_adds);
-	while(<DIFF>) {
+	foreach (qx{git-diff-tree -M -p $rev $parent -- $revs{$rev}{'filename'} $revs{$parent}{'filename'}}) {
 		chomp;
 		if (m/^@@ -(\d+),(\d+) \+(\d+),(\d+)/) {
 			($remstart, $remlength, $addstart, $addlength) = ($1, $2, $3, $4);
@@ -279,7 +273,7 @@ sub git_diff_parse {
 		}
 		$hunk_index++;
 	}
-	close(DIFF);
+	!$? or exit $?;
 	for (my $i = $ri; $i < @{$slines} ; $i++) {
 		push @plines, $slines->[$ri++];
 	}
@@ -300,15 +294,12 @@ sub git_cat_file {
 	my $blobline = `git-ls-tree $parent $filename`;
 	my ($mode, $type, $blob, $tfilename) = split(/\s+/, $blobline, 4);
 
-	open(C,"-|","git-cat-file", "blob", $blob)
-		or die "Failed to git-cat-file blob $blob (rev $parent, file $filename): " . $!;
-
 	my @lines;
-	while(<C>) {
+	foreach (qx{git-cat-file blob $blob}) {
 		chomp;
 		push @lines, $_;
 	}
-	close(C);
+	!$? or die "Failed to git-cat-file blob $blob (rev $parent, file $filename).";
 
 	return @lines;
 }
@@ -325,11 +316,9 @@ sub claim_line {
 
 sub git_commit_info {
 	my ($rev) = @_;
-	open(COMMIT, "-|","git-cat-file", "commit", $rev)
-		or die "Failed to call git-cat-file: $!";
 
 	my %info;
-	while(<COMMIT>) {
+	foreach (qx{git-cat-file commit $rev}) {
 		chomp;
 		last if (length $_ == 0);
 
@@ -343,7 +332,7 @@ sub git_commit_info {
 			$info{'committer_date'} = $3;
 		}
 	}
-	close(COMMIT);
+	!$? or exit $?;
 
 	return %info;
 }
@@ -351,6 +340,11 @@ sub git_commit_info {
 sub format_date {
 	my ($timestamp, $timezone) = split(' ', $_[0]);
 
+	if (!$opt_l) {
+		return strftime("%Y-%b-%d", gmtime($timestamp));
+	}
+
 	return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($timestamp));
 }
 
+

^ permalink raw reply related

* Re: [PATCH] fmt-merge-msg: avoid open "-|" list form for Perl 5.6
From: Andreas Ericsson @ 2006-02-23 13:29 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, git
In-Reply-To: <81b0412b0602230210r3ffe6e2dta5dc86d6516692b9@mail.gmail.com>

Alex Riesen wrote:
> On 2/23/06, Andreas Ericsson <ae@op5.se> wrote:
> 
>>Not to be unhelpful or anything, but activestate perl seems to be quite
>>a lot of bother. Is it worth supporting it?
> 
> 
> It's not activestate perl actually. It's only one platform it also
> _has_ to support.
> Is it worth supporting Windows?


With or without cygwin? With cygwin, I'd say "yes, unless it makes 
things terribly difficult to maintain and so long as we don't take 
performance hits on unices". Without cygwin, I'd say "What? It runs on 
windows?".

If we claim to support windows but do a poor job of it, no-one else will 
start working on a windows-port. If we don't claim to support windows 
but say that "it's known to work with cygwin, although be aware of these 
performance penalties...", eventually someone will come along with their 
shiny Visual Express and hack up support for it, even if some tools will 
be missing and others unnecessarily complicated.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

^ permalink raw reply

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
From: Alex Riesen @ 2006-02-23 12:40 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Git Mailing List
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).

^ permalink raw reply

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
From: Johannes Schindelin @ 2006-02-23 12:36 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Git Mailing List
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

^ permalink raw reply

* fix t5600-clone-fail-cleanup.sh on windows
From: Alex Riesen @ 2006-02-23 11:25 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

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

In windows you cannot remove current or opened directory,
an opened file, a running program, a loaded library, etc...

---
I still wonder how they managed to survive...

[-- Attachment #2: 0001-fix-t5600-clone-fail-cleanup.sh-on-windows-canot-remove-current-dir.txt --]
[-- Type: text/plain, Size: 706 bytes --]

>From nobody Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Thu Feb 23 11:49:31 2006 +0100
Subject: [PATCH] fix t5600-clone-fail-cleanup.sh on windows

---

 git-clone.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

3453c0df0d815580c5e7aaeb67bfc54b5b0954c6
diff --git a/git-clone.sh b/git-clone.sh
index dc0ad55..0c60e0b 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -118,7 +118,7 @@ dir="$2"
 [ -e "$dir" ] && echo "$dir already exists." && usage
 mkdir -p "$dir" &&
 D=$(cd "$dir" && pwd) &&
-trap 'err=$?; rm -r $D; exit $err' exit
+trap 'err=$?; cd ..; rm -r $D; exit $err' exit
 case "$bare" in
 yes) GIT_DIR="$D" ;;
 *) GIT_DIR="$D/.git" ;;
-- 
1.2.3.g6ae0e


^ permalink raw reply related

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
From: Alex Riesen @ 2006-02-23 10:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
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...

^ permalink raw reply

* Re: PATCH: simplify calls to git programs in git-fmt-merge-msg
From: Junio C Hamano @ 2006-02-23 10:35 UTC (permalink / raw)
  To: Alex Riesen; +Cc: git
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.

^ permalink raw reply

* PATCH: simplify calls to git programs in git-fmt-merge-msg
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


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox