git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/3] git-svn: correctly handle packed-refs in refs/remotes/
Date: Tue, 12 Dec 2006 17:27:51 -0800	[thread overview]
Message-ID: <7vlklcmvoo.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 20061213004500.GA17811@localdomain

Eric Wong <normalperson@yhbt.net> writes:

> We now use git-rev-parse universally to read refs, instead
> of our own file_to_s function (which I plan on removing).
>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> ---
>  git-svn.perl |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 1f8a3b0..aac8f73 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2016,9 +2016,17 @@ sub git_commit {
>  
>  	# just in case we clobber the existing ref, we still want that ref
>  	# as our parent:
> -	if (my $cur = eval { file_to_s("$GIT_DIR/refs/remotes/$GIT_SVN") }) {
> +	open my $null, '>', '/dev/null' or croak $!;
> +	open my $stderr, '>&', \*STDERR or croak $!;
> +	open STDERR, '>&', $null or croak $!;
> +	if (my $cur = eval { safe_qx('git-rev-parse',
> +	                             "refs/remotes/$GIT_SVN^0") }) {
> +		chomp $cur;
>  		push @tmp_parents, $cur;
>  	}
> +	open STDERR, '>&', $stderr or croak $!;
> +	close $stderr or croak $!;
> +	close $null or croak $!;
>  
>  	if (exists $tree_map{$tree}) {
>  		foreach my $p (@{$tree_map{$tree}}) {

It's a neat trick you do to stash away STDERR and redirect to
/dev/null ;-).  It might be worth doing something like this:

	sub without_stderr {
        	my ($cmd, @param) = @_;
                # stash away magic
                my @return = eval {
                	safe_qx($cmd, @param);
                };
                # restore magic
                return @return;
	}

in Git.pm?

Then the caller would do something like this instead:

	sub git_commit {
        	...
		if (my ($cur) = without_stderr(qw(git rev-parse --verify),
			"refs/remotes/$GIT_SVN^0")) {
                	...


  reply	other threads:[~2006-12-13  1:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-12 22:47 [PATCH 1/3] git-svn: enable logging of information not supported by git Eric Wong
2006-12-12 22:47 ` [PATCH 2/3] git-svn: allow dcommit to take an alternate head Eric Wong
2006-12-12 22:47 ` [PATCH 3/3] git-svn: correctly display fatal() error messages Eric Wong
2006-12-13  0:45   ` [PATCH 4/3] git-svn: correctly handle packed-refs in refs/remotes/ Eric Wong
2006-12-13  1:27     ` Junio C Hamano [this message]
2006-12-13  2:26       ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vlklcmvoo.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).