Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
p4: fix "Not a valid object name HEAD0" when unshelving #183
git p4 unshelve was failing with "fatal: Not a valid object name HEAD0" and "Command failed: git cat-file commit HEAD^0" on certain systems e.g. git version 2.21.0.windows.1 + python 2.7.16
It seems that certain python pOpen implementations drop the ^ character when invoked using a string instead of an array as first argument, which is what is done by extractLogMessageFromGitCommit.
Solution is to use the array format of passing the command to fOpen, which is preferred (see https://docs.python.org/2/library/subprocess.html) and is used in other parts of this code anyway.
Welcome to GitGitGadget
Hi @mdymike, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests.
Please make sure that this Pull Request has a good description, as it will be used as cover letter.
Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code.
Contributing the patches
Before you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a PR comment of the form
Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment
After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions.
If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox ("raw") file corresponding to the mail you want to reply to from the Git mailing list. If you use GMail, you can upload that raw mbox file via:
curl -g --user "<EMailAddress>:<Password>" --url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txt
@mdymike please consider using your real email address (as the Git mailing list will most likely reject the patch if it has a fake email address in the author/Signed-off-by info).
Also, please wrap the commit message at 74 columns/line or less.
Finally, I think that you might want to add a bit more information about that
Is my take on this correct?
Note there are a couple of other suspicious uses of ^ however I don't have access to a non-prod perforce to test these code paths:
line#1459, part of P4RollBack
line#1830, part of applyCommit
line#3303, part of getCommitByP4Change, called by importNewBranch
If those lines have code coverage in the automatic checks I would be happy to propose the fixes, just let me know.
Sorry about that. GitGitGadget looks at your GitHub profile to come up with your full name so that the mails can be sent as "Mike Mueller via GitGitGadget". And since your profile does not have that information, GitGitGadget gives up.
I'm currently quite busy preparing for the upcoming v2.22.0-rc0, so I am unable to change GitGitGadget right now. Would you mind changing your profile and then issuing another
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@example.com>
Looks okay to me (but it's up to @gitster to judge), and yes, you need to
Cool thanks - been offline in the mountains, will submit now - thanks!