git-p4: don't use name-rev to get current branch

git-p4 was using "git name-rev" to find out the current branch. That is not safe, since if multiple branches or tags point at the same revision, the result obtained might not be what is expected. Instead use "git symbolic-ref". Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Luke Diamand committed Apr 15, 2017 at 11:36 UTC eff451101dcdc6fe023861c6c02a9bacc43f372e
2 files changed +2 -7
git-p4.py
+1 -6
@@ -602,12 +602,7 @@ def p4Where(depotPath):
602 return clientPath
603
604 def currentGitBranch():
605 - retcode = system(["git", "symbolic-ref", "-q", "HEAD"], ignore_error=True)
606 - if retcode != 0:
607 - # on a detached head
608 - return None
609 - else:
610 - return read_pipe(["git", "name-rev", "HEAD"]).split(" ")[1].strip()
605 + return read_pipe_text(["git", "symbolic-ref", "--short", "-q", "HEAD"])
606
607 def isValidGitDir(path):
608 return git_dir(path) != None
t/t9807-git-p4-submit.sh
+1 -1
@@ -139,7 +139,7 @@ test_expect_success 'submit with master branch name from argv' '
139 )
140 '
141
142 -test_expect_failure 'allow submit from branch with same revision but different name' '
142 +test_expect_success 'allow submit from branch with same revision but different name' '
143 test_when_finished cleanup_git &&
144 git p4 clone --dest="$git" //depot &&
145 (