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

Re: [PATCH v2] Add support for merging from upstream by default.

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2011, 00:04 UTC
Message-ID
<7vpqr2oyy3.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110208223359.GB17981@elie>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Jared Hance wrote:
>>> Subject: Re: [PATCH v2] Add support for merging from upstream by default.
Drop full-stop '.' at the end.
Show 5 quoted lines
>> Adds the option merge.defaultupstream to add support for merging from the
>> upstream branch by default.
>
> Could you give an example of breakage this configurability is designed
> to prevent?

I think there is no "prevent" or "breakage"; the patch is to give people a way to turn the feature on; without the configuration, "git merge" will keep the traditional behaviour, no?

Show 13 quoted lines
>> +++ b/builtin/merge.c
>> @@ -37,7 +37,7 @@ struct strategy {
>>  };
>>  
>>  static const char * const builtin_merge_usage[] = {
>> -	"git merge [options] <remote>...",
>> +	"git merge [options] [<remote>...]",
>>  	"git merge [options] <msg> HEAD <remote>",
>>  	NULL
>
> Side note: these should probably say "<commit>" or "<branch>" rather
> than "<remote>".  I'm guessing the usage string comes from the days
> before the separate-remotes ref layout...
Yes, your guess is correct.
Show 24 quoted lines
>> @@ -911,6 +934,24 @@ static int evaluate_result(void)
>>  	return cnt;
>>  }
>>  
>> +static void setup_merge_commit(struct strbuf *buf,
>> +	struct commit_list ***remotes, const char *s)
>> +{
>> +	struct object *o;
>> +	struct commit *commit;
>> +
>> +	o = peel_to_type(s, 0, NULL, OBJ_COMMIT);
>> +	if (!o)
>> +		die("%s - not something we can merge", s);
>> +	commit = lookup_commit(o->sha1);
>> +	commit->util = (void *)s;
>> +	*remotes = &commit_list_insert(commit, *remotes)->next;
>> +
>> +	strbuf_addf(buf, "GITHEAD_%s", sha1_to_hex(o->sha1));
>> +	setenv(buf->buf, s, 1);
>> +	strbuf_reset(buf);
>> +}
>
> Would be easier to review if this code movement were in a separate
> patch (separating cleanup from semantic changes).

Probably. It is a very good idea to move this code out to its own helper function, nevertheless; I like this part of the patch.

Show 7 quoted lines
> Even better would be to use descriptive messages, like so:
>
>  if (head_invalid)
> 	usage_msg_opt("cannot use old-style invocation from an unborn branch",
> 		...);
>  if (!argc && ...)
> 	usage_msg_opt("no commit to merge specified", ...);
Much better.
Previous: Jonathan NiederNext: Jonathan Nieder
Message 4 of 14 in “Add support for merging from upstream by default.”
  1. Add support for merging from upstream by default.Jared Hance, Feb 8, 2011
  2. Jay SoffianFeb 8, 2011
  3. Jonathan NiederFeb 8, 2011
  4. Junio C HamanoFeb 9, 2011
  5. Jonathan NiederFeb 9, 2011
  6. 0/3 Updated patch series for default upstream mergeJared Hance, Feb 9, 2011
  7. 1/3 Add setup_merge_commit function to merge/builtin.c.Jared Hance, Feb 9, 2011
  8. Junio C HamanoFeb 9, 2011
  9. 2/3 Add function per_branch_config.Jared Hance, Feb 9, 2011
  10. Jonathan NiederFeb 9, 2011
  11. Junio C HamanoFeb 9, 2011
  12. 3/3 Add support for merging from upstream by default.Jared Hance, Feb 9, 2011
  13. Jonathan NiederFeb 9, 2011
  14. Junio C HamanoFeb 9, 2011

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.