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

Re: [PATCH] contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch args

From
Junio C Hamano <junkio@cox.net>
Date
Mar 9, 2006, 10:08 UTC
Message-ID
<7vacc07wwp.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060308015730.GA28056@localdomain>
Eric Wong <normalperson@yhbt.net> writes:
> Junio: please don't apply this patch to git.git just yet.  It seems fine
> to me, but I haven't tested it heavily yet (Yann can help me, I hope :)
> I hardly slept the past few days and I may have broken something badly
> (it pasts all the tests, though).
I won't be applying it then.
I think this part is wrong.
Show 8 quoted lines
> @@ -922,7 +930,9 @@ sub git_commit {
>  	}
>  	my @update_ref = ('git-update-ref',"refs/remotes/$GIT_SVN",$commit);
>  	if (my $primary_parent = shift @exec_parents) {
> -		push @update_ref, $primary_parent;
> +		if (!system('git-rev-parse',"refs/remotes/$GIT_SVN")){
> +			push @update_ref, $primary_parent;
> +		}

I think you are trying to see if you have .git/refs/remotes/foo, and I think you actually have tried it to determine that is the case.

But "git-rev-parse refs/remotes/foo" dies not because there is no valid file .git/refs/remotes/foo that records SHA1 of an existing commit. If there is refs/remotes/foo file, it thinks you have asked for it and gives it back happily.

A demonstration:
	$ cd /var/tmp/ && rm -fr junk && mkdir junk && cd junk
        $ git init-db
	defaulting to local storage area
        $ git-rev-parse refs/remotes/foo ; echo $?
        refs/remotes/foo
        fatal: 'refs/remotes/foo': No such file or directory
        128
        $ mkdir -p refs/remotes/foo
        $ ls -a
        ./  ../  .git/	refs/
        $ git-rev-parse refs/remotes/foo; echo $?
        refs/remotes/foo
        0

If you are trying to see if there is such a ref, I would do this:

	$ git-rev-parse --verify refs/remotes/foo^0
        git-rev-parse --verify refs/remotes/foo^0
        fatal: Needed a single revision
	128

The --verify flag makes sure that the argument resolves to a valid 40-hexadigit string (note that it does not verify if that object actually exists), so asking for zeroth parent makes sure you are dealing with a ref that actually points at a commit object that exists.

Previous: Eric WongNext: Eric Wong
Message 4 of 9 in “git-svn, tree moves, and --no-stop-on-copy”
  1. Yann DirsonMar 7, 2006
  2. Eric WongMar 8, 2006
  3. contrib/git-svn: fix UUID reading w/pre-1.2 svn; fetch argsEric Wong, Mar 8, 2006
  4. Junio C HamanoMar 9, 2006
  5. contrib/git-svn: fix svn compat and fetch argsEric Wong, Mar 9, 2006
  6. Yann DirsonMar 8, 2006
  7. Yann DirsonMar 8, 2006
  8. contrib/git-svn: remove the --no-stop-on-copy flagEric Wong, Mar 9, 2006
  9. Matthias UrlichsMar 8, 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.