Re: [PATCH 2/2] name-rev: favor describing with tags and use committer date to tiebreak
- Date: Thu, 16 Mar 2017 22:56:22 -0700
- From: Junio C Hamano <gitster@xxxxxxxxx>
- Subject: Re: [PATCH 2/2] name-rev: favor describing with tags and use committer date to tiebreak
Junio C Hamano <gitster@xxxxxxxxx> writes:
> Lars Schneider <larsxschneider@xxxxxxxxx> writes:
>> A quick bisect indicates that this patch might break
>> t9807-git-p4-submit.sh 8 and 13. I haven't looked into
>> it further, yet.
> As I do not do P4, help in diagnosing why it breaks is appreciated.
> If the test script expects...
> On the other hand, if git-p4 command internally uses name-rev and it
> is not prepared to properly handle commits that can be named in more
> than one way, the problem would be deeper, as it would mean it can
> misbehave even without the change to name-rev when multiple branches
> point at the same commit.
Yikes. Perhaps something along this line?
This function seems to want to learn which branch we are on, and
running "name-rev HEAD" is *NEVER* the right way to do so. If you
are on branch B which happens to point at the same commit as branch
A, "name-rev HEAD" can say either A or B (and it is likely it would
say A simply because it sorts earlier, and the logic seems to favor
the one that was discovered earlier when all else being equal).
git-p4.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-p4.py b/git-p4.py
index eab319d76e..351d1ab58e 100755
@@ -582,7 +582,7 @@ def currentGitBranch():
# on a detached head
- return read_pipe(["git", "name-rev", "HEAD"]).split(" ").strip()
+ return read_pipe(["git", "symbolic-ref", "HEAD"]).strip()[11:]
return git_dir(path) != None