2013-04-11 5 views
6

Tôi đã cố gắng chạy git p4 gửi trên một repo mà tôi đã chạy như một cây cầu tạm thời giữa git và lực lượng. Nhiều người đang sử dụng repo như một điều khiển từ xa và nó được định kỳ gửi trở lại cho lực lượng.git p4 gửi không thành công

Tính năng này hoạt động tốt, ngoại trừ một số cam kết thực hiện trùng lặp mà hành vi kỳ lạ của tôi dường như không thể tái tạo. Sau đó một ngày ra khỏi màu xanh tôi nhận được lỗi này. Tôi không còn có thể đẩy bất kỳ git cam kết nào với lực lượng.

[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. 

lỗi đó trông rất giống lỗi này:

git-p4 submit fails with patch does not apply

trừ Tôi không làm bất kỳ từ khóa thay thế, vì vậy tôi không có ý tưởng những gì nó có thể được. thêm --verbose dường như không giúp giải thích nhiều (tôi không có đầu ra lệnh đó trên tay)

Thay đổi duy nhất tôi có thể tưởng tượng là tôi đã thêm tệp .gitattributes với các nội dung sau bên dưới vào thời điểm tôi thực hiện cam kết. Tuy nhiên, cam kết thực hiện trước đây cam kết trong khi đó gitattributes tập tin được tại chỗ làm việc, vì vậy nó không thể là (tôi đã kể từ khi làm file .gitattributes chi tiết hơn)

* text eol=lf 

Tôi đã cố gắng đẩy lùi cam kết trong repo từ xa này ngay trước cam kết vi phạm này, và sau đó repushing chúng từ repo của tôi để repo từ xa này và sau đó gửi lại. Hành vi tương tự. Tôi đã thử quay lại và thực hiện các chỉnh sửa khác nhau cho cùng một tệp, gửi lại, gửi lại. Hành vi tương tự. Và nó dường như chỉ xảy ra với những tập tin này. Kể từ khi rollback tôi đã cố gắng thực hiện chỉnh sửa các tập tin khác và họ làm việc. Tôi đã thử chạy dos2unix để buộc kết thúc dòng unix trên các tệp vi phạm và điều đó cũng không khắc phục được.

Lệnh nào có thể cho tôi giải thích rõ hơn về những gì đang xảy ra ở đây? Có một tập tin đăng nhập git tôi có thể đuôi? Bất kỳ trợ giúp sẽ được đánh giá cao.

chỉnh sửa: Tôi đã thử lại vấn đề của mình có và không có tệp .gitattributes. điều đó không có gì khác biệt. hiện tại, cài đặt core.autocrlf toàn cục của tôi là đầu vào. Nhưng với tệp .gitattributes bị thiếu thì dường như không tạo ra sự khác biệt nào. Đây là những gì nó trông giống như khi tôi thử lại nó chỉ với một trong các tập tin vi phạm với --verbose bật.

[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

Tôi đoán 'git diff-tree -r -M 'ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e ^" "ef3b95f5fec193fe2612b28e2e3b5e7f8ba9419e" 'và xem liệu bạn có thể áp dụng các bản vá theo cách thủ công không? –

Trả lời

2

Tôi đã tìm ra. Vấn đề là do kết thúc dòng. Tôi đã thử lại vấn đề với một tệp khác và trong trường hợp này, lỗi được gây ra bởi kết thúc dòng của tệp được kiểm tra trong không gian làm việc theo kiểu là crlf giành chiến thắng và cuối dòng của tệp trong repo git là kiểu unix lf.

Trong trường hợp này, tôi đã kiểm tra tệp trong perforce, chạy dos2unix dựa vào nó và gửi tệp đó, sau đó chạy git p4 submit và nó hoạt động.

Đó không phải là giải pháp thực sự. Đó chỉ là cách giải quyết. Tôi đã gửi một e-mail đến danh sách gửi thư của git, yêu cầu sửa chữa. http://marc.info/?l=git&m=136630231402536&w=2

2

Đối với tôi, tôi đã gửi làm việc sau khi đặt git config apply.ignorewhitespace change.

Tôi nghĩ rằng lỗi xảy ra vì core.whitespace thiết lập git là hạn chế mỗi mặc định:

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.

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

Thiết apply.ignorewhitespace change phép git apply để sửa chữa các lỗi này. Thay đổi cài đặt core.whitespace ít bị hạn chế hơn cũng nên khắc phục sự cố, nhưng tôi chưa thử.

+0

cảm ơn, giải pháp của bạn đã làm việc cho tôi! – beshanoe