From: Junio C Hamano <gitster@pobox.com>
To: Jay Soffian <jaysoffian@gmail.com>
Cc: git@vger.kernel.org, jean-luc malet <jeanluc.malet@gmail.com>
Subject: Re: [PATCH 3/3] builtin-merge: add support for default merge options
Date: Fri, 06 Mar 2009 14:46:09 -0800 [thread overview]
Message-ID: <7vr61aqngu.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <9f755b5bae0b02c5cb3e01680acf71fe7153be04.1236377358.git.jaysoffian@gmail.com> (Jay Soffian's message of "Fri, 6 Mar 2009 17:15:15 -0500")
Jay Soffian <jaysoffian@gmail.com> writes:
> @@ -838,6 +847,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
> if (is_null_sha1(head))
> head_invalid = 1;
>
> + git_config(git_merge_config_default, NULL);
> git_config(git_merge_config, NULL);
The placement of this comes before parse_options(), just like the part
that slurps "branch.*.mergeoptions", so it can be overridden by the
command line just like "branch.*.mergeoptions" can, which is good.
When you are on branch "frotz", your config have both merge.options and
branch.frotz.mergeoptions, and you give some other options from the
command line, how should they interact? I'd expect the branch.*.options
to take effect, ignoring merge.options entirely.
I think the right way to structure this is to change the code in
git_merge_config() that accepts "branch.*.mergeoptions" to just store a
xstrdup() pointer away, add a similar thing in the same function for the
new "merge.options" variable. Get rid of your git_merge_config_default
function that forces git_config() to iterate over the same config file one
more time. And after the config parser returns, run the parse_options
only once.
In other words, the overall code structure would look like this:
static char *options_from_config;
static int options_from_config_taken_from_branch_config;
static int git_merge_config(...)
{
if (branch && !prefixcmp(k, "branch.") ... ) {
/*
* We may have found merge.options first;
* free it and override it with the value of
* branch.*.mergeoptions for the current branch
* we just found.
*/
free(options_from_config);
options_from_config_taken_from_branch_config = 1;
options_from_config = xstrdup(value);
return 0;
}
if (!strcmp(k, "merge.options")) {
/*
* Do not override branch.*.mergeoptions for the
* current branch if we already found one.
*/
if (!options_from_config_taken_from_branch_config)
options_from_config = xstrdup(value);
return 0;
}
...
}
int cmd_merge(...)
{
...
git_config(git_merge_config, NULL);
if (options_from_config)
/*
* There is a "prime" options given in
* the configuration file. Parse it.
*/
git_config_option_string(builtin_merge_options, ...,
options_from_config);
...
argc = parse_options(argc, argv, builtin_merge_options,...);
...
}
If for some reason you would want to have cumulative options across
branch.*.merge, merge.options and the command line, then you would instead
keep two separate strings, and call git_config_option_string() for both of
them, before processing the real command line options.
Hmm?
next prev parent reply other threads:[~2009-03-06 22:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-06 22:15 [PATCH 0/3] Re: how to have --no-ff be the default for all branch Jay Soffian
2009-03-06 22:15 ` [PATCH 1/3] config: add git_config_option_string() Jay Soffian
2009-03-06 22:15 ` [PATCH 2/3] builtin-merge: refactor to use git_config_option_string Jay Soffian
2009-03-06 22:15 ` [PATCH 3/3] builtin-merge: add support for default merge options Jay Soffian
2009-03-06 22:46 ` Junio C Hamano [this message]
2009-03-06 23:16 ` Jay Soffian
2009-03-07 0:44 ` [PATCH v2 " Jay Soffian
2009-03-07 0:58 ` [PATCH " Junio C Hamano
2009-03-07 1:56 ` Jay Soffian
2009-03-07 7:18 ` Junio C Hamano
2009-03-07 13:48 ` Jay Soffian
2009-03-07 19:31 ` jean-luc malet
2010-03-19 14:19 ` jean-luc malet
2010-03-19 14:54 ` Jay Soffian
2010-04-02 17:19 ` jean-luc malet
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=7vr61aqngu.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jaysoffian@gmail.com \
--cc=jeanluc.malet@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).