]> git.ipfire.org Git - thirdparty/git.git/commit - merge-recursive.c
merge-recursive: fix was_tracked() to quit lying with some renamed paths
authorElijah Newren <newren@gmail.com>
Thu, 19 Apr 2018 17:58:20 +0000 (10:58 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 May 2018 07:11:00 +0000 (16:11 +0900)
commita35edc84bdd6134d7aaa7bb0d220941154fe9e7e
treecf39677e2475ee83e407c8abb8c39542c79755d6
parentc04ba51739a7771583e31966adb7c472980f3fc3
merge-recursive: fix was_tracked() to quit lying with some renamed paths

In commit aacb82de3ff8 ("merge-recursive: Split was_tracked() out of
would_lose_untracked()", 2011-08-11), was_tracked() was split out of
would_lose_untracked() with the intent to provide a function that could
answer whether a path was tracked in the index before the merge.  Sadly,
it instead returned whether the path was in the working tree due to having
been tracked in the index before the merge OR having been written there by
unpack_trees().  The distinction is important when renames are involved,
e.g. for a merge where:

   HEAD:  modifies path b
   other: renames b->c

In this case, c was not tracked in the index before the merge, but would
have been added to the index at stage 0 and written to the working tree by
unpack_trees().  would_lose_untracked() is more interested in the
in-working-copy-for-either-reason behavior, while all other uses of
was_tracked() want just was-it-tracked-in-index-before-merge behavior.

Unsplit would_lose_untracked() and write a new was_tracked() function
which answers whether a path was tracked in the index before the merge
started.

This will also affect was_dirty(), helping it to return better results
since it can base answers off the original index rather than an index that
possibly only copied over some of the stat information.  However,
was_dirty() will need an additional change that will be made in a
subsequent patch.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
merge-recursive.h