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

Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)?

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 19, 2008, 22:52 UTC
Message-ID
<7v3ais5hb3.fsf_-_@gitster.siamese.dyndns.org>
In-Reply-To
<7vhc785izq.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Again, good eyes.  I think the two lines should go; my fault at cdb22c4
> (Merge branch 'jc/better-conflict-resolution' into next, 2008-09-02).
Hmm, I am somewhat unhappy.  If you run:
	$ git checkout cdb22c4^
        $ git merge cdb22c4^2
	$ git checkout --conflict=diff3 builtin-checkout.c
and look at builtin-checkout.c.  You will find this:
<<<<<<< ours
	/* --track without -b should DWIM */
	if (0 < opts.track && !opts.new_branch) {
		const char *argv0 = argv[0];
	...
		opts.new_branch = argv0 + 1;
	}
	if (opts.track == BRANCH_TRACK_UNSPECIFIED)
		opts.track = git_branch_track;
|||||||
	if (!opts.new_branch && (opts.track != git_branch_track))
		die("git checkout: --track and --no-track require -b");
=======
	if (conflict_style) {
		opts.merge = 1; /* implied */
		git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
	}
	if (!opts.new_branch && (opts.track != git_branch_track))
		die("git checkout: --track and --no-track require -b");
>>>>>>> theirs

The two lines in the middle was from the common ancestor, which was not touched by the merged branch (that added the "if (conflict_style) {}" block) and was lost by a rewrite in "ours".

However, the usual simplified merge shows this (run "git checkout --merge builtin-checkout.c" if you have done the above):

<<<<<<< ours
	/* --track without -b should DWIM */
	if (0 < opts.track && !opts.new_branch) {
		const char *argv0 = argv[0];
	...
		opts.new_branch = argv0 + 1;
	}
	if (opts.track == BRANCH_TRACK_UNSPECIFIED)
		opts.track = git_branch_track;
=======
	if (conflict_style) {
		opts.merge = 1; /* implied */
		git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
	}
	if (!opts.new_branch && (opts.track != git_branch_track))
		die("git checkout: --track and --no-track require -b");
>>>>>>> theirs

Removing the two lines from the simplified "theirs" is not what I would suggest (it would be actively wrong), but I wonder if we can do something clever to help users with a merge like this.

Previous: Junio C HamanoNext: Matt McCutchen
Message 3 of 5 in “"git checkout: --track and --no-track require -b" check accidentally resurrected?”
  1. Matt McCutchenOct 19, 2008
  2. Junio C HamanoOct 19, 2008
  3. Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)?Junio C Hamano, Oct 19, 2008
  4. Matt McCutchenOct 20, 2008
  5. Johannes SchindelinOct 20, 2008

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.