git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "git checkout: --track and --no-track require -b" check accidentally resurrected?
@ 2008-10-19  0:54 Matt McCutchen
  2008-10-19 22:15 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Matt McCutchen @ 2008-10-19  0:54 UTC (permalink / raw)
  To: git

Merge commit 9ba929ed resurrected the following two-line check, which
was removed in the first parent and unchanged in the second:

	if (!opts.new_branch && (opts.track != git_branch_track))
		die("git checkout: --track and --no-track require -b");

Is this intentional?  Does it make a difference?

(I noticed this while carefully examining 9ba929ed to find out why "git
merge" stopped honoring merge.conflictstyle.  Ironically, I hit this bug
again during the examination.)

Matt

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

* Re: "git checkout: --track and --no-track require -b" check accidentally resurrected?
  2008-10-19  0:54 "git checkout: --track and --no-track require -b" check accidentally resurrected? Matt McCutchen
@ 2008-10-19 22:15 ` Junio C Hamano
  2008-10-19 22:52   ` Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)? Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2008-10-19 22:15 UTC (permalink / raw)
  To: Matt McCutchen; +Cc: git

Matt McCutchen <matt@mattmccutchen.net> writes:

> Merge commit 9ba929ed resurrected the following two-line check, which
> was removed in the first parent and unchanged in the second:
>
> 	if (!opts.new_branch && (opts.track != git_branch_track))
> 		die("git checkout: --track and --no-track require -b");
>
> Is this intentional?  Does it make a difference?
>
> (I noticed this while carefully examining 9ba929ed to find out why "git
> merge" stopped honoring merge.conflictstyle.  Ironically, I hit this bug
> again during the examination.)

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).

Thanks.

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

* Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)?
  2008-10-19 22:15 ` Junio C Hamano
@ 2008-10-19 22:52   ` Junio C Hamano
  2008-10-20  3:42     ` Matt McCutchen
  2008-10-20 16:17     ` Johannes Schindelin
  0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2008-10-19 22:52 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Matt McCutchen

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.

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

* Re: Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)?
  2008-10-19 22:52   ` Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)? Junio C Hamano
@ 2008-10-20  3:42     ` Matt McCutchen
  2008-10-20 16:17     ` Johannes Schindelin
  1 sibling, 0 replies; 5+ messages in thread
From: Matt McCutchen @ 2008-10-20  3:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

On Sun, 2008-10-19 at 15:52 -0700, Junio C Hamano wrote:
> 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.

IMHO, the solution is just to use diff3 style.  I never understood how I
was supposed to intuit the correct result of a merge from the two sides
without seeing the common ancestor, so I am glad to have the diff3 style
working now.

Matt

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

* Re: Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)?
  2008-10-19 22:52   ` Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)? Junio C Hamano
  2008-10-20  3:42     ` Matt McCutchen
@ 2008-10-20 16:17     ` Johannes Schindelin
  1 sibling, 0 replies; 5+ messages in thread
From: Johannes Schindelin @ 2008-10-20 16:17 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Matt McCutchen

Hi,

On Sun, 19 Oct 2008, Junio C Hamano wrote:

> <<<<<<< 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

This is that case that adjacent blocks A and B are changed to A' B and A 
B' in the to-be-merged branches.

I could imagine that you would have this automerged to A' B', but I 
actually advise against that.

My gut feeling tells me that a "for" statement as block "A" and some 
change ("B") in the _body_ of the "for" loop that takes advantage of the 
original version of the "for" statement would be _real_ hard to detect.

Better have trivial conflicts reported, but catch more non-trivial ones 
(instead of mismerging them).

(Another possibility would be that block "B" is actually an "else".  Also 
in this case it is easy to think of cases that would wreak havoc; OTOH we 
would mismerge them _already_ if at least 1 common line is unchanged 
between the blocks.  Tough.)

But I might be completely wrong.

Ciao,
Dscho "who is a little jet-lagged, so you should trust him even less than 
normally"

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

end of thread, other threads:[~2008-10-20 16:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-19  0:54 "git checkout: --track and --no-track require -b" check accidentally resurrected? Matt McCutchen
2008-10-19 22:15 ` Junio C Hamano
2008-10-19 22:52   ` Is XDL_MERGE_ZEALOUS too zealous (or maybe not zealous enough)? Junio C Hamano
2008-10-20  3:42     ` Matt McCutchen
2008-10-20 16:17     ` Johannes Schindelin

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).