Re: [PATCH] Fix rebase with file move when diff.renames = copies
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jul 22, 2010, 07:51 UTC
- Message-ID
- <20100722075133.GA9292@burratino>
- In-Reply-To
- <1279742303-29817-1-git-send-email-ddkilzer@kilzer.net>
David D. Kilzer wrote:
Show 7 quoted lines
> With diff.renames = copies, a rebase with a file move will fail with > the following error: > > fatal: mode change for <file>, which is not in current HEAD > Repository lacks necessary blobs to fall back on 3-way merge. > Cannot fall back to three-way merge. > Patch failed at 0001.
I would think that the following works fine:
git init test-repo && cd test-repo && echo hello >greeting.txt && git add greeting.txt && git commit -m base && git checkout -b move && git mv greeting.txt moved.txt && git commit -m move && git checkout master && echo hi >greeting.txt && git add greeting.txt && git commit -m change && git checkout move && echo '[diff] renames = copies' >>.git/config && git rebase master
What am I doing wrong?
On the other hand I find Junio’s explanation[1] compelling already on its own.
The end user configuration for "diff" should not affect the result produced by the higher level command that is related to "diff" only because internally it is implemented in terms of it.
In cases where a patch copies a file that was then removed on the mainline, my intuition says ‘rebase’ without some extra flag should accept the change without complaint. Of course, this intuition is totally warped --- I tend to think of rebase as diff + apply.
Patch does not apply to master or maint, due to conflict with v1.7.1-rc0~37^2~5 (rebase: support automatic notes copying, 2010-03-12). One sneaky way to avoid this kind of thing would be to insert new tests at some logical point in the middle of a test script.
Test nitpicks:
Show 7 quoted lines
> +++ b/t/t3400-rebase.sh > @@ -155,4 +155,21 @@ test_expect_success 'Rebase a commit that sprinkles CRs in' ' > git diff --exit-code file-with-cr:CR HEAD:CR > ' > > +test_expect_success 'rebase a single file move with diff.renames = copies' ' > + git config diff.renames copies &&
Use
test_when_finished "git config --unset diff.renames" &&
to shelter future tests from the effect of this one.
Show 5 quoted lines
> + git checkout master && > + echo 1 > Y && > + git add Y && > + test_tick && > + git commit -m "prepare file move" &&
commit: new file Y.
Show 7 quoted lines
> + git checkout -b filemove HEAD^ && > + echo 1 > Y && > + git add Y && > + mkdir D && > + git mv A D/A && > + test_tick && > + git commit -m filemove &&
commit: new file Y, rename A to D/A.
> + GIT_TRACE=1 git rebase master
This wants to notice that Y was already added so the top patch can be simplified to include only a rename.
Can you explain why this test will fail without your patch?
Thanks, Jonathan
[1] http://thread.gmane.org/gmane.comp.version-control.git/100583/focus=100606