git p4提交失败

时间:2013-04-11 16:04:00

标签: git perforce git-p4

我尝试在一个repo上运行git p4 submit,我一直在运行它作为git和perforce之间的临时桥梁。多人正在使用repo作为远程服务器,并定期将其提交回perforce。

除了一些重复的perforce提交之外,它一直很好地工作,其奇怪的行为似乎无法再现。然后有一天,我得到了这个错误。我再也无法将任何git提交到perforce了。

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.

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

git-p4 submit fails with patch does not apply

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

我能想到的唯一变化是我在提交时添加了一个.gitattributes文件,其中包含以下内容。但是,当gitattributes文件到位时,在此提交之前进行的提交确实有效,所以它不可能(我已经使.gitattributes文件更加详细)

* text eol=lf

我已尝试将此远程仓库中的提交回滚到此违规提交之前,然后将其从我的仓库中复制到此远程仓库,然后重新提交。相同的行为。我尝试回滚,对同一个文件进行不同的编辑,重新推送,重新提交。相同的行为。它似乎只发生在这些文件中。由于回滚,我尝试对其他文件进行编辑,然后才能工作。我尝试运行dos2unix强制unix行结束有问题的文件,而且也没有修复它。

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

编辑:我在使用和不使用.gitattributes文件的情况下重新测试了我的问题。没有任何区别。目前我的全局core.autocrlf设置是输入。但是缺少.gitattributes文件似乎没有任何区别。这是我在仅使用其中一个打开--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']

3 个答案:

答案 0 :(得分:3)

我设置git config apply.ignorewhitespace change之后提交工作。

我认为发生错误是因为git core.whitespace设置在默认情况下是限制性的:

  

默认打开的是看起来像是空白的   对于行尾的空格; blank-at-eof,注意到空白   文件末尾的行;和空格之前的标签,寻找   在行开头的制表符之前的空格。

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

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

答案 1 :(得分:2)

我明白了。问题是由行结尾引起的。我用不同的文件重新测试了这个问题,在这种情况下,错误是由perforce工作区中检出的文件的行结尾为win-style crlf引起的,git repo中文件的行结尾为unix样式LF。

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

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

答案 2 :(得分:0)

请注意,如果不进行基准调整,git p4 submit可能会失败。因此,请务必在提交之前运行git p4 rebase