From: Bill Okara <billokara@gmail.com>
To: "SZEDER Gábor" <szeder@ira.uka.de>
Cc: Karsten Blees <karsten.blees@gmail.com>,
Stefan Beller <sbeller@google.com>, Kevin Daudt <me@ikke.info>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: git mv messed up file mapping if folders contain identical files
Date: Fri, 26 Feb 2016 08:48:56 -0700 [thread overview]
Message-ID: <CADsr5c-WztuTM5Tmu9_h_9_uSnGLwqSR1c5ZPa_DDi9yAJBNnw@mail.gmail.com> (raw)
In-Reply-To: <1456487400-31174-1-git-send-email-szeder@ira.uka.de>
Hi,
On Fri, Feb 26, 2016 at 4:50 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
>
> Please don't top-post on this list.
>
Sorry about that. Just learned what that means and why it is bad...
> Subject: [PATCH] diffcore: fix iteration order of identical files during rename detection
>
> If the two paths 'dir/A/file' and 'dir/B/file' have identical content
> and the parent directory is renamed, e.g. 'git mv dir other-dir', then
> diffcore reports the following exact renames:
>
> renamed: dir/B/file -> other-dir/A/file
> renamed: dir/A/file -> other-dir/B/file
>
> While technically not wrong, this is confusing not only for the user,
> but also for git commands that make decisions based on rename
> information, e.g. 'git log --follow'.
>
> This behavior is a side effect of commit v2.0.0-rc4~8^2~14
> (diffcore-rename.c: simplify finding exact renames, 2013-11-14): the
> hashmap storing sources returns entries from the same bucket, i.e.
> sources matching the current destination, in LIFO order. Thus the
> iteration first examines 'other-dir/A/file' and 'dir/B/file' and, upon
> finding identical content and basename, reports an exact rename.
>
> Restore the original behavior by reversing the order of filling the
> hashmap with source entries.
>
> Reported-by: Bill Okara <billokara@gmail.com>
> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
> ---
> diffcore-rename.c | 6 ++++--
> t/t4001-diff-rename.sh | 11 +++++++++++
> 2 files changed, 15 insertions(+), 2 deletions(-)
> diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh
> index 2f327b749588..ed90c6c6f984 100755
> --- a/t/t4001-diff-rename.sh
> +++ b/t/t4001-diff-rename.sh
> @@ -77,6 +77,17 @@ test_expect_success 'favour same basenames even with minor differences' '
> git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
> git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
>
> +test_expect_success 'two files with same basename and same content' '
> + git reset --hard &&
> + mkdir -p dir/A dir/B &&
> + cp path1 dir/A/file &&
> + cp path1 dir/B/file &&
> + git add dir &&
> + git commit -m 2 &&
> + git mv dir other-dir &&
> + git status | test_i18ngrep "renamed: .*dir/A/file -> other-dir/A/file"
> +'
> +
> test_expect_success 'setup for many rename source candidates' '
> git reset --hard &&
> for i in 0 1 2 3 4 5 6 7 8 9;
> --
> 2.7.2.410.g92cb358
>
Thank you very much for the fix and the detailed explanation!
-Bill
prev parent reply other threads:[~2016-02-26 15:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 23:38 git mv messed up file mapping if folders contain identical files Bill Okara
2016-02-24 23:39 ` Junio C Hamano
2016-02-24 23:51 ` Bill Okara
2016-02-25 0:03 ` Bill Okara
2016-02-25 11:49 ` Kevin Daudt
2016-02-25 13:56 ` Stefan Beller
2016-02-25 16:25 ` Bill Okara
2016-02-26 11:50 ` SZEDER Gábor
2016-02-26 15:48 ` Bill Okara [this message]
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=CADsr5c-WztuTM5Tmu9_h_9_uSnGLwqSR1c5ZPa_DDi9yAJBNnw@mail.gmail.com \
--to=billokara@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karsten.blees@gmail.com \
--cc=me@ikke.info \
--cc=sbeller@google.com \
--cc=szeder@ira.uka.de \
/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 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).