Re: [PATCH] [RFC] Introduce Git.pm
- From
- Eric Wong <normalperson@yhbt.net>
- Date
- Jun 22, 2006, 02:31 UTC
- Message-ID
- <20060622023104.GB27871@hand.yhbt.net>
- In-Reply-To
- <20060622003546.17760.23089.stgit@machine.or.cz>
Petr Baudis <pasky@suse.cz> wrote:
> Currently Git.pm just wraps up exec()s of Git commands, but even that > is not trivial to get right and various Git perl scripts do it in > various inconsistent ways. And things will get much more interesting > when we get to XS-izing libgit.
git-svn uses fork/pipe/exec very heavily for both reads and writes and also a few bidirectional cases, as well. It would be good exercise to port it to use Git.pm once it's more complete and stable.
XS-ising libgit would be awesome with all the git-hash-object calls in git-svn (and other importers, too, I imagine).
> This is mostly to show up what I have so far and gather some comments > on the general shapes of the interface; I guess in the current shape > of the API it's suitable for pu at best, but that's not my call.
safe_qx (git-svn) AKA safe_pipe_capture (archimport) would be non-git-specific, but very useful.
> + my $pid = open(my $fh, "-|");
> + if ($pid < 0) {
> + die "generic($cmd, @args) open: $!";In Perl, fork returns undef instead of $pid < 0 on failure. Doing join(' ',@args) will also make the error message more readable, too :)
-- Eric Wong