git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/3] git-svn: correctly handle packed-refs in refs/remotes/

From
Junio C Hamano <junkio@cox.net>
Date
Dec 13, 2006, 01:27 UTC
Message-ID
<7vlklcmvoo.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061213004500.GA17811@localdomain>
Eric Wong <normalperson@yhbt.net> writes:
Show 31 quoted lines
> 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")) {
                	...
Previous: Eric WongNext: Eric Wong
Message 5 of 6 in “git-svn: enable logging of information not supported by git”
  1. 1/3 git-svn: enable logging of information not supported by gitEric Wong, Dec 12, 2006
  2. 2/3 git-svn: allow dcommit to take an alternate headEric Wong, Dec 12, 2006
  3. 3/3 git-svn: correctly display fatal() error messagesEric Wong, Dec 12, 2006
  4. 4/3 git-svn: correctly handle packed-refs in refs/remotes/Eric Wong, Dec 13, 2006
  5. Junio C HamanoDec 13, 2006
  6. Eric WongDec 13, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.