Re: [PATCH] Fix rebase with file move when diff.renames = copies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David D. Kilzer wrote:

> 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:

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

> +     git checkout master &&
> +     echo 1 > Y &&
> +     git add Y &&
> +     test_tick &&
> +     git commit -m "prepare file move" &&

commit: new file Y.

> +     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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]