Git development
 help / color / mirror / Atom feed
* Patches generated by "git format-patch -M -B" can't be applied with "git apply"?
@ 2015-09-14 22:21 Dan Kegel
  2015-09-14 22:32 ` Junio C Hamano
  2015-09-14 22:32 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Kegel @ 2015-09-14 22:21 UTC (permalink / raw)
  To: git

A bot I wrote uses 'git format-patch -M -B' to generate a patch
to send off to be applied with 'git am' on a remote machine.
Alas, renames do not appear to work; git am rejects them with
 error: file2: already exists in working directory
This happens both with the git that ships with Ubuntu 14.04
and with master ( git version 2.6.0.rc1.16.g1962994 ).

I noticed that git has a similar test case already,
t4130-apply-criss-cross-rename.sh
so I munged that to reproduce the error,
http://kegel.com/git/t4154-apply-half-criss-cross-rename.sh.txt
Running
 ./t4154-apply-half-criss-cross-rename.sh -v
fails for me reliably with
 error: file2: already exists in working directory
with either v2.6.0-rc2 or random local git on local Mac and Linux.
is this behavior indeed a bug, or am I breaking some rule?
Thanks!
- Dan

p.s. Here's the test case inline, but if email munges whitespace,
the url above might be better.

#!/bin/sh

test_description='git apply handling half-criss-cross rename patch.'
. ./test-lib.sh

create_file() {
        cnt=0
        while test $cnt -le 100
        do
                cnt=$(($cnt + 1))
                echo "$2" >> "$1"
        done
}

test_expect_success 'setup' '
        create_file file1 "File1 contents" &&
        create_file file2 "File2 contents" &&
        git add file1 file2 &&
        git commit -m 1
'

test_expect_success 'half criss-cross rename' '
        mv file1 file2 &&
        git rm file1 &&
        git add file2 &&
        git commit -m 2
'

test_expect_success 'diff -M -B' '
        git format-patch -M -B HEAD^ --stdout > diff &&
        git reset --hard HEAD^
'

test_expect_success 'apply' '
        git apply --check diff
'

test_done

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patches generated by "git format-patch -M -B" can't be applied with "git apply"?
  2015-09-14 22:21 Patches generated by "git format-patch -M -B" can't be applied with "git apply"? Dan Kegel
@ 2015-09-14 22:32 ` Junio C Hamano
  2015-09-14 22:32 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2015-09-14 22:32 UTC (permalink / raw)
  To: Dan Kegel; +Cc: git

Dan Kegel <dank@kegel.com> writes:

Yes, "diff -M -B" is known to be problematic, unfortunately.  It
incorrectly creates an irreversible patch under certain conditions.

http://thread.gmane.org/gmane.linux.kernel/1879635

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patches generated by "git format-patch -M -B" can't be applied with "git apply"?
  2015-09-14 22:21 Patches generated by "git format-patch -M -B" can't be applied with "git apply"? Dan Kegel
  2015-09-14 22:32 ` Junio C Hamano
@ 2015-09-14 22:32 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2015-09-14 22:32 UTC (permalink / raw)
  To: Dan Kegel; +Cc: git

Yes, "diff -M -B" is known to be problematic, unfortunately.  It
incorrectly creates an irreversible patch under certain conditions.

http://thread.gmane.org/gmane.linux.kernel/1879635

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-14 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-14 22:21 Patches generated by "git format-patch -M -B" can't be applied with "git apply"? Dan Kegel
2015-09-14 22:32 ` Junio C Hamano
2015-09-14 22:32 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox