git p4提交失败

问题描述:

我试着在回购站上运行git p4提交,我一直在作为git和perforce之间的过渡桥运行。多人使用回购作为远程,并定期提交回执行。git p4提交失败

它一直工作得很好,除了一些重复的perforce提交的奇怪的行为,我似乎无法重现。然后有一天,我得到这个错误。我不能再推任何git提交来执行。

[email protected]:~/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. 

该错误看起来很像这个错误:

git-p4 submit fails with patch does not apply

除了我没有做任何关键字替换,所以我不知道它可能是什么。加入--verbose似乎没有帮助解释很多(我手边没有那个命令输出)

我能想象的唯一变化就是我添加了一个.gitattributes文件,其中包含以下内容作出承诺。然而,均属此之前提交,而gitattributes文件已经到位没有工作,所以它不可能是(我以来取得的.gitattributes文件更详细)

* text eol=lf 

我试图回滚做在此违规提交之前提交此远程仓库,然后将它们从我的仓库中重新装入此远程仓库,然后重新提交。同样的行为。我尝试回滚,并对同一文件进行不同的编辑,重新编排,重新提交。同样的行为。它似乎只发生在这些文件。自回滚以来,我试图对其他文件进行编辑,并且它们可以正常工作。我试图运行dos2unix来强制unix行结束在违规的文件,并没有解决它。

什么命令可以让我更好地解释这里发生了什么?有一个我可以尾巴的git日志文件吗?任何援助将不胜感激。

编辑:我重新测试了我的问题,没有.gitattributes文件。这没有什么区别。目前我的全局core.autocrlf设置是输入。但是.gitattributes文件丢失似乎没有什么区别。下面是当我用--verbose打开的其中一个违规文件重新测试它时的样子。

[email protected]:/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'] 
+0

我想'git diff-tree -r -M“ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e ^”“ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e”'看看你是否可以手动应用补丁? – 2013-04-12 08:24:04

我想通了。该问题是由行结束引起的。我用一个不同的文件重新测试了这个问题,在这种情况下,错误是由在perforce工作区检出的文件的行结尾为win-style crlf,并且git repo中文件的行结尾为unix风格如果。

在这种情况下,我在perforce中检出了这个文件,对它运行了dos2unix,并提交了这个文件,然后运行git p4 submit并运行。

这不是真正的解决方案。这只是解决方法。我向git的邮件列表发送了一封电子邮件,要求修复。 http://marc.info/?l=git&m=136630231402536&w=2

对于我提交工作后,我设置git config apply.ignorewhitespace change

我想是因为git的core.whitespace设置为默认每限制性出现错误:

The ones that are turned on by default are blank-at-eol, which looks for spaces at the end of a line; blank-at-eof, which notices blank lines at the end of a file; and space-before-tab, which looks for spaces before tabs at the beginning of a line.

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

设置apply.ignorewhitespace change允许git apply修正这些错误。更改core.whitespace设置为限制较少的也应该可以解决问题,但我没有试过。

+0

谢谢,您的解决方案适合我! – beshanoe 2015-10-23 14:15:47