git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Different behaviour for --find-renames between git diff and git merge?
@ 2025-12-12 18:04 Luca Balsanelli
  2025-12-13  1:57 ` Elijah Newren
  0 siblings, 1 reply; 6+ messages in thread
From: Luca Balsanelli @ 2025-12-12 18:04 UTC (permalink / raw)
  To: git

Hi,

   I'm scratching my head to understand why on the following case `git 
diff` and `git merge` give a different interpretation about a rename.

    git switch master
    touch aaa
    git add aaa
    git commit -m 'aaa'

    git switch -c branch
    echo -en 'A\nB\nC\n' > aaa
    git add aaa
    git commit -m 'A\nB\nC\n > aaa'

    git switch master
    echo -en 'A\nB\n' > aaa
    mkdir dir
    mv aaa dir/
    git add aaa dir/
    git commit -m 'A\nB\n > aaa -> dir/'

The `|merge.renames` config variable is true. Changing `git diff 
--find-renames=50%` (the default) or `git merge -s ort -X 
find-renames=50%` ||to something lower does not change the following.
|

`git diff` prints

    diff --git a/aaa b/dir/aaa
    similarity index 71%
    rename from aaa
    rename to dir/aaa
    index bbd2b90..986ad36 100644
    --- a/aaa
    +++ b/dir/aaa
    @@ -1,4 +1,3 @@
      A
      B
    -C

     that is the similarity index is 71% and it detects the rename.

`git merge branch`, instead, gives

    CONFLICT (modify/delete): aaa deleted in HEAD and modified in
    branch.  Version branch of aaa left in tree.
    Automatic merge failed; fix conflicts and then commit the result

Why it is that? I always supposed that the rename detection was the same 
for `git diff`, `git merge`. Reading the documentation I do not find any 
hint why `git diff` and `git merge` are behaving differently.

Thanks,

Luca Balsanelli


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

end of thread, other threads:[~2025-12-16 19:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12 18:04 Different behaviour for --find-renames between git diff and git merge? Luca Balsanelli
2025-12-13  1:57 ` Elijah Newren
2025-12-15 14:02   ` Luca Balsanelli
2025-12-16  0:57     ` Elijah Newren
2025-12-16 13:15       ` Luca Balsanelli
2025-12-16 19:44         ` Elijah Newren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).