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
0If 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
128The --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.