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

Re: using xdl_merge(), was Re: Resolving conflicts

From
Junio C Hamano <junkio@cox.net>
Date
Dec 5, 2006, 19:50 UTC
Message-ID
<7vac22glzz.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0612051949290.28348@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> On Tue, 5 Dec 2006, Linus Torvalds wrote:
>
>>  - take every single merge in git (or the kernel, if you want even more)

The attached is the script I am using. The test checks the output from 'master' (merge from RCS) and 'next' (with xdl-merge) and also tries to see how different the conflicts look like.

In the git.git archive, there is no "clean" merge on which 'master' and 'next' did not agree. It is not a proof of correctness at all but it gives a sense of assurance.

However, the conflict 'next' leaves seems a bit suspicious. Trying to reproduce

	56f9686c4d1e1d586b731b815bd98d70f84ecda4
gives an interesting illustration.
Here is one conflicted hunk from that merge (RCS merge)
-- 8< -- RCS merge conflict hunk, diff from the 1st parent -- 8< --
 
--- a/Makefile
+++ b/Makefile
@@ -232,8 +232,13 @@ LIB_FILE=libgit.a
 XDIFF_LIB=xdiff/lib.a
 
 LIB_H = \
+<<<<<<< HEAD/Makefile
 	archive.h blob.h cache.h commit.h csum-file.h delta.h \
 	diff.h object.h pack.h pkt-line.h quote.h refs.h \
+=======
+	blob.h cache.h commit.h csum-file.h delta.h \
+	diff.h object.h pack.h pkt-line.h quote.h refs.h sideband.h \
+>>>>>>> d47f3db75c58139cdcbca5cc63b17bf5db293b6a/Makefile
 	run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
 	tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h
 
-- >8 -- RCS merge conflict hunk, diff from the 1st parent -- >8 --

-- 8< -- JS merge conflict hunk, diff from the 1st parent -- 8< --

--- a/Makefile
+++ b/Makefile
@@ -232,8 +232,14 @@ LIB_FILE=libgit.a
 XDIFF_LIB=xdiff/lib.a
 
 LIB_H = \
+<<<<<<< HEAD/Makefile
 	archive.h blob.h cache.h commit.h csum-file.h delta.h \
 	diff.h object.h pack.h pkt-line.h quote.h refs.h \
+=======
+	blob.h cache.h commit.h csum-file.h delta.h \
+	diff.h object.h pack.h pkt-line.h quote.h refs.h sideband.h \
+>>>>>>> d47f3db75c58139cdcbca5cc63b17bf5db293b6a/Makefile
+	diff.h object.h pack.h pkt-line.h quote.h refs.h sideband.h \
 	run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
 	tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h
 
-- >8 -- JS merge conflict hunk, diff from the 1st parent -- >8 --

Notice that there is one duplicated line after the closing
conflict marker?


-- 8< -- remerge.sh test script -- 8< --
#!/bin/sh
# Leaves things to be examined in /var/tmp/remerge-$$/

ogit=$HOME/git-master/bin/git
ngit=$HOME/git-next/bin/git
tmp=/var/tmp/remerge-$$-tmp

trap 'rm -f $tmp-*' 0

# Revlist
if ! test -f ./+RL
then
	git rev-list --parents HEAD |
	perl -n -e 'if (/^[0-9a-f]{40} [0-9a-f]{40} [0-9a-f]{40}$/) {
		print;
	}' >./+RL
fi

try_one () {
	# should be on a discardable branch.

	git=$1 parent1=$2 parent2=$3
	$git reset --hard "$parent1"
	
	if $git merge "$parent2"
	then
		echo clean merge
		$git diff-tree -r --raw "$parent1" HEAD 
	else
		echo conflicted merge
		$git ls-files -u
		$git diff --binary -p "$parent1"
	fi
}

# Make sure we do not trash anything important
current=`git symbolic-ref HEAD`
if test "z$current" != zrefs/heads/remerge-test
then
	git checkout -b remerge-test ||
        git checkout remerge-test

        current=`git symbolic-ref HEAD`
        test "z$current" = zrefs/heads/remerge-test || exit
fi

while read result parent1 parent2
do
	try_one $ogit $parent1 $parent2 >$tmp-1 2>/dev/null
	try_one $ngit $parent1 $parent2 >$tmp-2 2>/dev/null
	if diff $tmp-1 $tmp-2
	then
		echo "Ok"
	else
		echo "Bad $result"
		mkdir -p $tmp/$result
		mv $tmp-1 $tmp/$result/ogit
		mv $tmp-2 $tmp/$result/ngit
	fi
	$git reset --hard
done < ./+RL
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 20 of 32 in “Resolving conflicts”
  1. Wink SavilleDec 1, 2006
  2. Alan ChandlerDec 1, 2006
  3. Wink SavilleDec 1, 2006
  4. Alan ChandlerDec 1, 2006
  5. Linus TorvaldsDec 1, 2006
  6. Wink SavilleDec 1, 2006
  7. Linus TorvaldsDec 1, 2006
  8. Linus TorvaldsDec 1, 2006
  9. Alan ChandlerDec 1, 2006
  10. Wink SavilleDec 1, 2006
  11. Alan ChandlerDec 1, 2006
  12. Wink SavilleDec 2, 2006
  13. Linus TorvaldsDec 2, 2006
  14. Junio C HamanoDec 2, 2006
  15. using xdl_merge(), was Re: Resolving conflictsJohannes Schindelin, Dec 2, 2006
  16. Ramsay JonesDec 5, 2006
  17. Linus TorvaldsDec 5, 2006
  18. Junio C HamanoDec 5, 2006
  19. Johannes SchindelinDec 5, 2006
  20. Junio C HamanoDec 5, 2006
  21. xdl_merge(): fix and simplify conflict handlingJohannes Schindelin, Dec 5, 2006
  22. Junio C HamanoDec 5, 2006
  23. Johannes SchindelinDec 5, 2006
  24. Junio C HamanoDec 5, 2006
  25. Jakub NarebskiDec 5, 2006
  26. Johannes SchindelinDec 5, 2006
  27. Junio C HamanoDec 6, 2006
  28. Johannes SchindelinDec 6, 2006
  29. Junio C HamanoDec 6, 2006
  30. Johannes SchindelinDec 6, 2006
  31. Johannes SchindelinDec 5, 2006
  32. Linus TorvaldsDec 1, 2006

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.