git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Timothy Chen <tnachen@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Allow multiple merges to invalid HEAD
Date: Sun, 3 Apr 2011 17:22:56 -0500	[thread overview]
Message-ID: <20110403222234.GB6537@elie> (raw)
In-Reply-To: <1301813216-19507-1-git-send-email-tnachen@gmail.com>

Hi,

Timothy Chen wrote:

>  builtin/merge.c |   57 +++++++++++++++++++++++++++++-------------------------
>  1 files changed, 31 insertions(+), 26 deletions(-)

Now for mechanics.

> --- a/builtin/merge.c
> +++ b/builtin/merge.c
[...]
> @@ -1101,36 +1098,44 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  		remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
>  		if (!remote_head)
>  			die(_("%s - not something we can merge"), argv[0]);
> -		read_empty(remote_head->sha1, 0);
>  		update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
>  				DIE_ON_ERR);
> -		return 0;
> +
> +		if (argc < 2)
> +			return 0;

When argc == 1, this means read_empty never gets called.  Is that
intended?

It breaks 7607.13.  Running "make test" is a good way to find some
breakages.

> +
> +		hashcpy(head, remote_head->sha1);
> +		read_empty(remote_head->sha1, 0);
> +		head_arg = argv[0];
> +		argc--;
> +		argv++;

As always when pretending something, I think a comment would be
helpful.  Something to the effect of:

	/*
	 * We were called as "git merge <branch1> <branch2> <branch3>...".
	 *
	 * Now HEAD has advanced to <branch1>, and we can pretend
	 * we were called as "git merge <branch2> <branch3>...".
	 */

Though I think I prefer the more explicit comment I suggested last
time[1].

> +	}
> +
> +	struct strbuf merge_names = STRBUF_INIT;
> +
> -	} else {
> -		struct strbuf merge_names = STRBUF_INIT;
> -
> -		/* We are invoked directly as the first-class UI. */
> +	/* We are invoked directly as the first-class UI. */

Won't this break

	git merge "message here" $(git rev-parse HEAD) foo bar

?  Previously this code was in an "else" block so it wasn't reached in
the is_old_style_invocation case.

> -	if (head_invalid || !argc)
> +	if (!argc)
>  		usage_with_options(builtin_merge_usage,
>  			builtin_merge_options);

What happens with

	git merge "message here" HEAD foo bar

from an unborn branch?

Hope that helps.
Jonathan

[1] http://thread.gmane.org/gmane.comp.version-control.git/170456

  parent reply	other threads:[~2011-04-03 22:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-03  6:46 [PATCH] Allow multiple merges to invalid HEAD Timothy Chen
2011-04-03  7:07 ` Junio C Hamano
2011-04-03 21:52   ` Jonathan Nieder
2011-04-03  8:08 ` Junio C Hamano
2011-04-03 22:22 ` Jonathan Nieder [this message]
2011-04-05  6:01   ` Timothy Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110403222234.GB6537@elie \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tnachen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).