All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Balsanelli <lucabalsanelli@gmail.com>
To: git@vger.kernel.org
Subject: Different behaviour for --find-renames between git diff and git merge?
Date: Fri, 12 Dec 2025 19:04:00 +0100	[thread overview]
Message-ID: <3742e7de-7d88-4e77-b711-9fed867a8c23@gmail.com> (raw)

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


             reply	other threads:[~2025-12-12 18:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12 18:04 Luca Balsanelli [this message]
2025-12-13  1:57 ` Different behaviour for --find-renames between git diff and git merge? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3742e7de-7d88-4e77-b711-9fed867a8c23@gmail.com \
    --to=lucabalsanelli@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.