我尝试在已经作为git和perforce之间中转桥的仓库上运行git p4 submit。多人将该仓库用作远程,并定期提交回perforce,这一切都一直运行良好,除了一些我无法复制的重复perforce提交的异常行为。然后某天突然出现错误,我无法再将任何git提交推送到perforce。
我已经尝试将远程存储库中的提交回滚到这个有问题的提交之前,然后从我的存储库将它们推送到这个远程存储库并重新提交。但是结果一样。我还尝试了回滚并对同一文件进行不同的编辑,然后再次推送和重新提交,但仍然出现相同的问题。而且只在这些文件中才会出现这种情况。自从回滚以来,我尝试对其他文件进行编辑,它们可以正常工作。我尝试运行dos2unix强制将有问题的文件转换为Unix行结尾,但也没有解决问题。
有什么命令可以更好地解释这里发生了什么?是否有一个git日志文件我可以跟踪?任何帮助都将不胜感激。
编辑:我已经测试过我的问题,无论是否有.gitattributes文件都是一样的。目前我的全局core.autocrlf设置为input。但是在缺少.gitattributes文件的情况下,似乎没有任何区别。以下是我使用--verbose选项对其中一个有问题的文件重新测试时的情况。
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.
那个错误看起来很像这个错误:
但是我并没有进行任何关键词替换,所以我不知道可能是什么原因。添加--verbose
似乎也不能帮助解释太多(我手头没有该命令的输出)
唯一的变化可能就是在我提交时添加了一个.gitattributes文件,其内容如下。然而,在该gitattributes文件存在的情况下,之前进行的提交确实有效,因此不能是这个问题(我后来对.gitattributes文件进行了更详细的修改)
* text eol=lf
我已经尝试将远程存储库中的提交回滚到这个有问题的提交之前,然后从我的存储库将它们推送到这个远程存储库并重新提交。但是结果一样。我还尝试了回滚并对同一文件进行不同的编辑,然后再次推送和重新提交,但仍然出现相同的问题。而且只在这些文件中才会出现这种情况。自从回滚以来,我尝试对其他文件进行编辑,它们可以正常工作。我尝试运行dos2unix强制将有问题的文件转换为Unix行结尾,但也没有解决问题。
有什么命令可以更好地解释这里发生了什么?是否有一个git日志文件我可以跟踪?任何帮助都将不胜感激。
编辑:我已经测试过我的问题,无论是否有.gitattributes文件都是一样的。目前我的全局core.autocrlf设置为input。但是在缺少.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']
git diff-tree -r -M "ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e^" "ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e"
然后看是否可以手动应用补丁? - Douglas Leeder