Skip to content
  • Elijah Newren's avatar
    merge-recursive: avoid incorporating uncommitted changes in a merge · 65170c07
    Elijah Newren authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    builtin/merge.c contains this important requirement for merge strategies:
    	/*
    	 * At this point, we need a real merge.  No matter what strategy
    	 * we use, it would operate on the index, possibly affecting the
    	 * working tree, and when resolved cleanly, have the desired
    	 * tree in the index -- this means that the index must be in
    	 * sync with the head commit.  The strategies are responsible
    	 * to ensure this.
    	 */
    
    merge-recursive does not do this check directly, instead it relies on
    unpack_trees() to do it.  However, merge_trees() has a special check for
    the merge branch exactly matching the merge base; when it detects that
    situation, it returns early without calling unpack_trees(), because it
    knows that the HEAD commit already has the correct result.  Unfortunately,
    it didn't check that the index matched HEAD, so after it returned, the
    outer logic ended up creating a merge commit that included something
    other than HEAD.
    
    Signed-off-by: default avatarElijah Newren <newren@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    65170c07