Git p4 submit fails

I tried running git p4 submit on a repo that I was running as an intermediate bridge between git and perforce. A lot of people use the repo as a remote one, and it is periodically sent back to the team.

It worked mostly fine, except for some duplicate perforce commits, whose strange behavior I can't reproduce. Then once a day I get this error. I can no longer push any git commit.

user@hostname :~/Source/code$ git p4 submit -M --export-labels Perforce checkout for depot path //depot/perforce/workspace/ located at /home/user/Source/git-p4-area/perforce/workspace/ Synchronizing p4 checkout... ... - file(s) up-to-date. Applying ffa390f comments in config xml files //depot/perforce/workspace/sub/folder/structure/first.xml#3 - opened for edit //depot/perforce/workspace/sub/folder/structure/second.xml#3 - opened for edit //depot/perforce/workspace/sub/folder/structure/third.xml#3 - opened for edit //depot/perforce/workspace/sub/folder/structure/forth.xml#3 - opened for edit //depot/perforce/workspace/sub/folder/structure/fifth.xml#1 - opened for edit error: patch failed: sub/folder/structure/first.xml:1 error: sub/folder/structure/first.xml: patch does not apply error: patch failed: sub/folder/structure/second.xml:1 error: sub/folder/structure/second.xml: patch does not apply error: patch failed: sub/folder/structure/third.xml:1 error: sub/folder/structure/third.xml: patch does not apply error: patch failed: sub/folder/structure/forth.xml:1 error: sub/folder/structure/forth.xml: patch does not apply error: patch failed: sub/folder/structure/fifth.xml:1 error: sub/folder/structure/fifth.xml: patch does not apply Unfortunately applying the change failed! //depot/perforce/workspace/sub/folder/structure/first.xml#1 - was edit, reverted //depot/perforce/workspace/sub/folder/structure/second.xml#3 - was edit, reverted //depot/perforce/workspace/sub/folder/structure/third.xml#3 - was edit, reverted //depot/perforce/workspace/sub/folder/structure/forth.xml#3 - was edit, reverted //depot/perforce/workspace/sub/folder/structure/fifth.xml#3 - was edit, reverted No commits applied. 

This error is very similar to this error:

git -p4 submit fail with patch not applicable

except that I DO NOT perform keyword replacements, so I have no idea what it could be. adding --verbose doesn't seem to help much explain (I don't have this command output)

The only change I could imagine was that I added a .gitattributes file with the following contents at the time I committed. However, the commits made before this commit while the gitattributes file was in place worked, so it couldn't be (I have since made the .gitattributes file more verbose)

 * text eol=lf 

I tried to discard the commits in this remote repo right before this abusive commit, and then canceled them from my repo to this remote repo and then resent. The same behavior. I tried rolling back and making various changes to the same file, reseeding and resubmitting. The same behavior. And this only happens with these files. From the moment of rollback, I tried to make changes to other files, and they work. I tried running dos2unix to force unix line endings in files with violations, and this did not fix either.

Which team can give me a better explanation of what is going on here? Is there a git log file that I could tail? Any help would be appreciated.

edit: I re-tested my problem with and without a .gitattributes file. it didn't make any difference. my global configuration core.autocrlf is currently being introduced. But with the lack of a .gitattributes file that seemed to change nothing. This is how it looked when I retested it with only one of the intruder files with --verbose .

 user@hostname :/code$ git p4 submit -M --export-labels --verbose Reading pipe: git name-rev HEAD Reading pipe: ['git', 'config', 'git-p4.allowSubmit'] Reading pipe: git rev-parse --symbolic --remotes Reading pipe: git rev-parse p4/master Reading pipe: git cat-file commit 0457c7589ea679dcc0c9114b34f8f30bc2ee08cf Reading pipe: git cat-file commit HEAD~0 Reading pipe: git cat-file commit HEAD~1 Reading pipe: ['git', 'config', 'git-p4.conflict'] Origin branch is remotes/p4/master Reading pipe: ['git', 'config', '--bool', 'git-p4.useclientspec'] Opening pipe: ['p4', '-G', 'where', '//depot/perforce/workspace/...'] Perforce checkout for depot path //depot/perforce/workspace/ located at /home/user/Source/git-p4-area/perforce/workspace/ Synchronizing p4 checkout... ... - file(s) up-to-date. Opening pipe: p4 -G opened ... Reading pipe: ['git', 'rev-list', '--no-merges', 'remotes/p4/master..master'] Reading pipe: ['git', 'config', '--bool', 'git-p4.skipUserNameCheck'] Reading pipe: ['git', 'config', 'git-p4.detectCopies'] Reading pipe: ['git', 'config', '--bool', 'git-p4.detectCopiesHarder'] Reading pipe: ['git', 'show', '-s', '--format=format:%h %s', 'ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e'] Applying ef3b95f making test change Opening pipe: p4 -G users Reading pipe: ['git', 'log', '--max-count=1', '--format=%ae', 'ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e'] Reading pipe: git diff-tree -r -M "ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e^" "ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e" //depot/perforce/workspace/sub/folder/structure/first.xml#3 - opened for edit <stdin>:17: trailing whitespace. <!-- comment line 1 --> <stdin>:18: trailing whitespace. <!-- comment line 2 --> <stdin>:19: trailing whitespace. <!-- comment line 3 --> error: patch failed: sub/folder/structure/first.xml:1 error: sub/folder/structure/first.xml: patch does not apply Unfortunately applying the change failed! Reading pipe: ['git', 'config', '--bool', 'git-p4.attemptRCSCleanup'] //depot/perforce/workspace/sub/folder/structure/first.xml#3 - was edit, reverted No commits applied. Reading pipe: ['git', 'config', '--bool', 'git-p4.exportLabels'] Opening pipe: ['p4', '-G', 'labels', '//depot/ipstor.maple/automation/...'] Reading pipe: ['git', 'tag'] Reading pipe: ['git', 'config', 'git-p4.labelExportRegexp'] 
+6
source share
3 answers

I get it. This problem is caused by line endings. I re-tested the problem with another file, in which case the error is caused by the end of the line of the file extracted in the perforce workspace, which is win-style crlf, and the end of the line of the file in the git unix style lf repository.

In this case, I checked the file in perforce, ran dos2unix against it and sent it, then executed git p4 submit and worked.

This is not a real solution. This is just a workaround. I sent an email to the git mailing list asking for a fix. http://marc.info/?l=git&m=136630231402536&w=2

+3
source

To submit the view after installing git config apply.ignorewhitespace change .

I think the error occurs because the git core.whitespace parameter is restrictive by default:

Those that are enabled by default are empty-on-eol, which looks for spaces at the end of a line; blank-at-eof, which marks a space at the end of the file; and a space before the tab, which looks for spaces before the tabs at the beginning of the line.

(see http://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration )

Setting apply.ignorewhitespace change allows git apply fix these errors. Changing the core.whitespace parameter, which will be less restrictive, should also fix the problem, but I have not tried this.

+3
source

Please note that git p4 submit may fail if you do not rebase. So be sure to run git p4 rebase before submitting.

0
source

All Articles