Skip to content

Commit c3f2358

Browse files
mdymikegitster
authored andcommitted
p4 unshelve: fix "Not a valid object name HEAD0" on Windows
git p4 unshelve was failing with these errors: fatal: Not a valid object name HEAD0 Command failed: git cat-file commit HEAD^0 (git version 2.21.0.windows.1, python 2.7.16) The pOpen call used by git-p4 to invoke the git command can take either a string or an array as a first argument. The array form is preferred because platform-specific escaping of special characters will be handled automatically.(https://docs.python.org/2/library/subprocess.html) The extractLogMessageFromGitCommit method was, however, using the string form and so the caret (^) character in the HEAD^0 argument was not being escaped on Windows. The caret happens to be the escape character, which is why the git command was receiving HEAD0. The behaviour can be confirmed by typing ECHO HEAD^0 at the command- prompt, which emits HEAD0. The solution is simply to use the array format of passing the command to fOpen, which is recommended and used in other parts of this code anyway. Signed-off-by: Mike Mueller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aeb582a commit c3f2358

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-p4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ def extractLogMessageFromGitCommit(commit):
737737

738738
## fixme: title is first line of commit, not 1st paragraph.
739739
foundTitle = False
740-
for log in read_pipe_lines("git cat-file commit %s" % commit):
740+
for log in read_pipe_lines(["git", "cat-file", "commit", commit]):
741741
if not foundTitle:
742742
if len(log) == 1:
743743
foundTitle = True

0 commit comments

Comments
 (0)