2013-04-11 106 views
6

我試着在回購站上運行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

回答

2

我想通了。該問題是由行結束引起的。我用一個不同的文件重新測試了這個問題,在這種情況下,錯誤是由在perforce工作區檢出的文件的行結尾爲win-style crlf,並且git repo中文件的行結尾爲unix風格如果。

在這種情況下,我在perforce中檢出了這個文件,對它運行了dos2unix,並提交了這個文件,然後運行git p4 submit並運行。

這不是真正的解決方案。這只是解決方法。我向git的郵件列表發送了一封電子郵件,要求修復。 http://marc.info/?l=git&m=136630231402536&w=2

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