git/list[1] front-page[2] threads[3] people[4] search[5] about
 

two-way merge corner case bug

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 26, 2013, 20:06 UTC
Message-ID
<7v7glun8kt.fsf@alter.siamese.dyndns.org>

It seems that we have a corner case bug in two-way merge to reset away the conflicts with "read-tree -u --reset HEAD ORIG_HEAD".

In a freshly created repository:
    rm -f A Z
    for i in $(seq 100)
    do
            echo hello
    done >Z
    git add Z
    git commit -m initial
    git branch side
    echo goodbye >>Z
    git commit -a -m changed
    git checkout side
    git mv Z A
    echo kitty >>A
    git commit -a -m side
if you do one of these:
	git checkout master && git merge side
	git checkout side && git merge master
you will get three stages for path A, and nothing for path Z.

With the former, you are starting from a tree with Z (and not A), and "resetting" should give you A that is the same as 'master' in the working tree. With the latter, you are starting from a tree with A, and "resetting" should give you Z and remove conflicted A from the working tree.

	git read-tree -u --reset ORIG_HEAD
does the right thing in either case, but
	git read-tree -u --reset HEAD ORIG_HEAD
dies with "cache entry has null sha1: A" for both cases.

The direct symptom comes from 4337b5856f88 (do not write null sha1s to on-disk index, 2012-07-28), but I think the root cause is somewhere else. When we start from 'side', we should notice that our HEAD has Z, and conflicted A we see in the index came from a conflicted merge that we are resetting away and should disappear from the working tree. When we start from 'master', we should notice that we do not want to keep the cache entry that is "modified" in the index, and write the one taken from the "going to" tree (ORIG_HEAD).

Next: Jeff King
Message 1 of 10 in “two-way merge corner case bug”
  1. Junio C HamanoFeb 26, 2013
  2. Jeff KingFeb 26, 2013
  3. Junio C HamanoFeb 26, 2013
  4. Jeff KingMar 1, 2013
  5. Junio C HamanoMar 1, 2013
  6. Jeff KingMar 1, 2013
  7. Junio C HamanoMar 1, 2013
  8. Jeff KingMar 1, 2013
  9. Junio C HamanoMar 1, 2013
  10. Jeff KingMar 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.