Skip to content
  • Elijah Newren's avatar
    merge-recursive: fix was_tracked() to quit lying with some renamed paths · a35edc84
    Elijah Newren authored and Junio C Hamano's avatar Junio C Hamano committed
    In commit aacb82de
    
     ("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: default avatarElijah Newren <newren@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    a35edc84