Re: [PATCH] Allow multiple merges to invalid HEAD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Timothy Chen <tnachen@xxxxxxxxx> writes:

> This patch will allow multiple branches to be passed in,
> and first updates current HEAD to the first branch's head then subsequently
> merge the rest of the branches.

I've questioned the motivation of the patch already, but let's comment on
the mechanics as well while I am waiting for some builds to finish ;-)

> diff --git a/builtin/merge.c b/builtin/merge.c
> index d54e7dd..290e0d4 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -1090,9 +1090,6 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
>  		 * to forbid "git merge" into a branch yet to be born.
>  		 * We do the same for "git pull".
>  		 */
>  		if (squash)
>  			die(_("Squash commit into empty head not supported yet"));
>  		if (!allow_fast_forward)
> @@ -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]);
>  		update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
>  				DIE_ON_ERR);

You are going to perform a series of operations that is a lot more complex
than what we traditionally have done at this point.  I do not think it is
safe at all to update the ref this early before even knowing if the rest
of the command succeeds.

> +		if (argc < 2)
> +			return 0;
> +
> +		hashcpy(head, remote_head->sha1);
> +		read_empty(remote_head->sha1, 0);
> +		head_arg = argv[0];
> +		argc--;
> +		argv++;
> +	}
> +
> +	struct strbuf merge_names = STRBUF_INIT;

Decl-after-statement.

> +	/* We are invoked directly as the first-class UI. */
> +	if(!head_invalid)

SP after syntactic keyword and the open paren associated with it.

>  		head_arg = "HEAD";
>  
> +	/*
> +	 * All the rest are the commits being merged;
> +	 * prepare the standard merge summary message to
> +	 * be appended to the given message.  If remote
> +	 * is invalid we will die later in the common
> +	 * codepath so we discard the error in this
> +	 * loop.
> +	 */
> +	for (i = 0; i < argc; i++)
> +		merge_name(argv[i], &merge_names);
> +
> +	if (!have_message || shortlog_len) {
> +		fmt_merge_msg(&merge_names, &merge_msg, !have_message,
> +				  shortlog_len);
> +		if (merge_msg.len)
> +			strbuf_setlen(&merge_msg, merge_msg.len - 1);
>  	}
>  
> +	if (!argc)
>  		usage_with_options(builtin_merge_usage,
>  			builtin_merge_options);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]