{"thread":{"id":"40351","subject":"Patches generated by \"git format-patch -M -B\" can't be applied with \"git apply\"?","startedAt":"2015-09-14T22:21:11Z","lastAt":"2015-09-14T22:32:49Z","messageCount":3,"participants":["Dan Kegel","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"269966","messageId":"CAPF-yOb4dRWGLmL==x8=ifvU4Znsut9XQWMLPxBCPq7TzgJ84A@mail.gmail.com","threadId":"40351","inReplyTo":null,"subject":"Patches generated by \"git format-patch -M -B\" can't be applied with \"git apply\"?","fromName":"Dan Kegel","fromEmail":"dank@kegel.com","sentAt":"2015-09-14T22:21:11Z","receivedAt":"2015-09-14T22:21:11Z","isPatch":false,"sender":{"key":"dank@kegel.com","avatar":null},"body":"A bot I wrote uses 'git format-patch -M -B' to generate a patch\nto send off to be applied with 'git am' on a remote machine.\nAlas, renames do not appear to work; git am rejects them with\n error: file2: already exists in working directory\nThis happens both with the git that ships with Ubuntu 14.04\nand with master ( git version 2.6.0.rc1.16.g1962994 ).\n\nI noticed that git has a similar test case already,\nt4130-apply-criss-cross-rename.sh\nso I munged that to reproduce the error,\nhttp://kegel.com/git/t4154-apply-half-criss-cross-rename.sh.txt\nRunning\n ./t4154-apply-half-criss-cross-rename.sh -v\nfails for me reliably with\n error: file2: already exists in working directory\nwith either v2.6.0-rc2 or random local git on local Mac and Linux.\nis this behavior indeed a bug, or am I breaking some rule?\nThanks!\n- Dan\n\np.s. Here's the test case inline, but if email munges whitespace,\nthe url above might be better.\n\n#!/bin/sh\n\ntest_description='git apply handling half-criss-cross rename patch.'\n. ./test-lib.sh\n\ncreate_file() {\n        cnt=0\n        while test $cnt -le 100\n        do\n                cnt=$(($cnt + 1))\n                echo \"$2\" >> \"$1\"\n        done\n}\n\ntest_expect_success 'setup' '\n        create_file file1 \"File1 contents\" &&\n        create_file file2 \"File2 contents\" &&\n        git add file1 file2 &&\n        git commit -m 1\n'\n\ntest_expect_success 'half criss-cross rename' '\n        mv file1 file2 &&\n        git rm file1 &&\n        git add file2 &&\n        git commit -m 2\n'\n\ntest_expect_success 'diff -M -B' '\n        git format-patch -M -B HEAD^ --stdout > diff &&\n        git reset --hard HEAD^\n'\n\ntest_expect_success 'apply' '\n        git apply --check diff\n'\n\ntest_done\n"},{"id":"269967","messageId":"xmqqio7cvdgy.fsf@gitster.mtv.corp.google.com","threadId":"40351","inReplyTo":"CAPF-yOb4dRWGLmL==x8=ifvU4Znsut9XQWMLPxBCPq7TzgJ84A@mail.gmail.com","subject":"Re: Patches generated by \"git format-patch -M -B\" can't be applied with \"git apply\"?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-14T22:32:45Z","receivedAt":"2015-09-14T22:32:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan Kegel <dank@kegel.com> writes:\n\nYes, \"diff -M -B\" is known to be problematic, unfortunately.  It\nincorrectly creates an irreversible patch under certain conditions.\n\nhttp://thread.gmane.org/gmane.linux.kernel/1879635\n"},{"id":"269968","messageId":"xmqqh9mwvdgu.fsf@gitster.mtv.corp.google.com","threadId":"40351","inReplyTo":"CAPF-yOb4dRWGLmL==x8=ifvU4Znsut9XQWMLPxBCPq7TzgJ84A@mail.gmail.com","subject":"Re: Patches generated by \"git format-patch -M -B\" can't be applied with \"git apply\"?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-14T22:32:49Z","receivedAt":"2015-09-14T22:32:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yes, \"diff -M -B\" is known to be problematic, unfortunately.  It\nincorrectly creates an irreversible patch under certain conditions.\n\nhttp://thread.gmane.org/gmane.linux.kernel/1879635\n"}]}