git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Handling merge conflicts a bit more gracefully..
@ 2005-06-08 20:55 Linus Torvalds
  2005-06-08 23:07 ` Junio C Hamano
  2005-06-09  3:07 ` Jeff Garzik
  0 siblings, 2 replies; 33+ messages in thread
From: Linus Torvalds @ 2005-06-08 20:55 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Jeff Garzik


Ok, Jeff reported that whenever there is a merge conflict, he ends up 
really punting on it and doing it all with diffs, which clearly meant that 
I had to fix up my silly things for this. Which I think I've done now.

What happens now in the case of a merge conflict is:
 - the merge is obviously not committed
 - we do all the successful merges, and update the index file for them
 - for the files that conflict, we force the index to contain the old
   version of the file (ie we remove the merge from the index), and we
   write the (failed) output of the merge into the working directory, and
   we complain loudly:

	Auto-merging xyzzy.
	merge: warning: conflicts during merge
	ERROR: Merge conflict in xyzzy.
	fatal: merge program failed
	Automatic merge failed, fix up by hand

at which point a normal "git-diff-files -p xyzzy" will show the incomplete
merge results (as relative to the original BRANCH you started with), and
in fact you can also do "git-diff-cache -p MERGE_HEAD xyzzy" to see the
same thing (but relative to the branch you tried to merge).

You then fix up the merge failure by hand (exactly the way you'd do with 
CVS), and you do a "git-update-cache xyzzy" when you're happy with the end 
result. Then a simple "git commit" should do the right thing.

If you decide that the merge is too hard to undo, you'd do:

	git-read-tree -u -m HEAD
	rm .git/MERGE_HEAD

and use git-checkout-cache judiciously to remove any edits the merge did.

This is definitely not perfect, but it's a hell of a lot more usable than
it used to be, and not really worse than what CVS people are used to (and
usually a lot better, since git will obviously get the origin of a
three-way merge right, unlike CVS).

Comments? It would be good to have people test this and maybe even write a 
few automated tests that it all works as expected..

		Linus

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2005-06-18  0:18 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-08 20:55 Handling merge conflicts a bit more gracefully Linus Torvalds
2005-06-08 23:07 ` Junio C Hamano
2005-06-08 23:35   ` Linus Torvalds
2005-06-09  0:03     ` Junio C Hamano
2005-06-09  0:41       ` Linus Torvalds
2005-06-09  1:04         ` Junio C Hamano
2005-06-09  0:11     ` Junio C Hamano
2005-06-09  1:08       ` Linus Torvalds
2005-06-09  2:15         ` Junio C Hamano
2005-06-09  2:48           ` Linus Torvalds
2005-06-09  4:35             ` Junio C Hamano
2005-06-09  4:54               ` Linus Torvalds
2005-06-09  5:15                 ` Junio C Hamano
2005-06-09  7:02     ` [PATCH 0/3] " Junio C Hamano
2005-06-09  7:04       ` [PATCH 1/3] read-tree.c: rename local variables used in 3-way merge code Junio C Hamano
2005-06-09  7:05       ` [PATCH 2/3] read-tree -m 3-way: loosen index requirements that is too strict Junio C Hamano
2005-06-09  7:06       ` [PATCH 3/3] read-tree -m 3-way: handle more trivial merges internally Junio C Hamano
2005-06-09 15:15         ` Linus Torvalds
2005-06-09 17:26           ` Junio C Hamano
2005-06-09 17:37             ` Linus Torvalds
     [not found]               ` <7vbr6fnzf0.fsf@assigned-by-dhcp.cox.net>
     [not found]                 ` <Pine.LNX.4.58.0506091152530.2286@ppc970.osdl.org>
2005-06-09 22:45                   ` [PATCH] read-tree.c: rename local variables used in 3-way merge code Junio C Hamano
2005-06-09 22:47                   ` [PATCH] Handle entry removals during merge correctly Junio C Hamano
2005-06-09 22:48                   ` [PATCH] read-tree -m 3-way: loosen an index requirement that was too strict Junio C Hamano
2005-06-09 22:49                   ` [PATCH] read-tree -m 3-way: handle more trivial merges internally Junio C Hamano
2005-06-09 20:35           ` [PATCH 3/3] " Junio C Hamano
2005-06-09 22:13             ` [PATCH] Add git-diff-stages command Junio C Hamano
2005-06-09 22:30               ` Linus Torvalds
2005-06-11  1:44               ` [PATCH] diff-stages: unuglify the too big main() function Junio C Hamano
2005-06-10 19:59             ` [PATCH 3/3] read-tree -m 3-way: handle more trivial merges internally Junio C Hamano
2005-06-18  0:15     ` Handling merge conflicts a bit more gracefully Herbert Xu
2005-06-18  0:26       ` Linus Torvalds
2005-06-09  3:07 ` Jeff Garzik
2005-06-09  4:11   ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).