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

A note on merging conflicts..

From
Linus Torvalds <torvalds@osdl.org>
Date
Jul 1, 2006, 02:44 UTC
Message-ID
<Pine.LNX.4.64.0606301927260.12404@g5.osdl.org>

Ok, over the last week or so, I've been having a lot more content conflicts than usual, mostly because of

 (a) just the fact that the way the merge window happens for the kernel 
     these days, rather than have incremental small merges, we often end 
     up having lots of big ones.
and
 (b) I ended up merging a few trees that had lots of small changes all 
     over, notably to header files having their <config.h> include 
     removed, causing trivial conflicts.

Now, the good news is that I have to say that our conflict resolution rocks. It's all been _very_ easy to do. In fact, it's been even more pleasant than BK was, because of one big issue: you could resolve the conflict in the tree, then _test_ it (perhaps just compile-test it), and commit the resolved result separately. With BK, you had to resolve and commit atomically, and you never had access to a "preliminary resolve" to test.

However, I also notived one particular thing that I did that we make less than perfectly easy.

One thing that is _very_ useful to do is to do when you have a conflict is this:

	git log -p HEAD MERGE_BASE..MERGE_HEAD -- conflicting-filename

because this shows all the changes (with their explanations) for that filename since the MERGE_BASE in _both_ branches you're trying to merge. This simple command really makes conflict resolution a hell of a lot easier, because you can see what caused the conflict, and you get a real feel for what both branches were doing, making it a _lot_ more likely that you actually do the right thing.

Now, the downside is that the above is both a pain to type, and we don't actually even save the MERGE_BASE as a head, so you actually have to compute it yourself. It's easy enough to do:

	git-merge-base HEAD MERGE_HEAD > .git/MERGE_BASE
will do it, but the fact is, we should make this even easier.

In fact, after writing the above a few times, I really think there's a case for making a helper function that does exactly the above for us. Including all the "conflicting-filename" thing. It would be nice if

	git log -p --merge [[--] filenames...]
would basically expand to
	git log -p HEAD MERGE_HEAD
		^$(git-merge-base HEAD MERGE_HEAD)
		-- $(git-ls-files -u [filenames...])
so that I wouldn't have to type that by hand ever again, and doing a
	git log -p --merge drivers/

would automatically give me exactly that for all the unmerged files in drivers/.

Anybody want to try to make me happy, and learn some git internals at the same time?

			Linus
Next: Junio C Hamano
Message 1 of 49 in “A note on merging conflicts..”
  1. Linus TorvaldsJul 1, 2006
  2. Junio C HamanoJul 1, 2006
  3. Linus TorvaldsJul 1, 2006
  4. Linus TorvaldsJul 1, 2006
  5. Rene ScharfeJul 1, 2006
  6. Johannes SchindelinJul 1, 2006
  7. Linus TorvaldsJul 1, 2006
  8. Rene ScharfeJul 1, 2006
  9. J. Bruce FieldsJul 1, 2006
  10. Linus TorvaldsJul 1, 2006
  11. Daniel BarkalowJul 1, 2006
  12. Linus TorvaldsJul 1, 2006
  13. Daniel BarkalowJul 1, 2006
  14. Daniel BarkalowJul 1, 2006
  15. Rene ScharfeJul 2, 2006
  16. Daniel BarkalowJul 2, 2006
  17. Linus TorvaldsJul 2, 2006
  18. Jakub NarebskiJul 1, 2006
  19. Linus TorvaldsJul 1, 2006
  20. Junio C HamanoJul 1, 2006
  21. Rene ScharfeJul 1, 2006
  22. Junio C HamanoJul 1, 2006
  23. Johannes SchindelinJul 1, 2006
  24. Linus TorvaldsJul 1, 2006
  25. Junio C HamanoJul 1, 2006
  26. Junio C HamanoJul 1, 2006
  27. 1/3 Add get_merge_bases_clean()Rene Scharfe, Jul 1, 2006
  28. Johannes SchindelinJul 1, 2006
  29. 2/3 Add '...' operator for revisionsRene Scharfe, Jul 1, 2006
  30. 3/3 Make clear_commit_marks() clean harderRene Scharfe, Jul 1, 2006
  31. Junio C HamanoJul 3, 2006
  32. Johannes SchindelinJul 3, 2006
  33. Linus TorvaldsJul 3, 2006
  34. Johannes SchindelinJul 3, 2006
  35. Junio C HamanoJul 3, 2006
  36. Johannes SchindelinJul 3, 2006
  37. Linus TorvaldsJul 3, 2006
  38. Johannes SchindelinJul 4, 2006
  39. Junio C HamanoJul 4, 2006
  40. 4/3 Fold get_merge_bases_clean() into get_merge_bases()Rene Scharfe, Jul 2, 2006
  41. Johannes SchindelinJul 2, 2006
  42. Linus TorvaldsJul 2, 2006
  43. Rene ScharfeJul 2, 2006
  44. Junio C HamanoJul 2, 2006
  45. Rene ScharfeJul 2, 2006
  46. Rene ScharfeJul 2, 2006
  47. Linus TorvaldsJul 2, 2006
  48. Linus TorvaldsJul 2, 2006
  49. Junio C HamanoJul 7, 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.