From: Junio C Hamano <gitster@pobox.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: git@vger.kernel.org, Jacob Keller <jacob.keller@gmail.com>,
Johan Herland <johan@herland.net>,
Michael Haggerty <mhagger@alum.mit.edu>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v3 3/4] notes: add notes.merge option to select default strategy
Date: Wed, 05 Aug 2015 13:47:35 -0700 [thread overview]
Message-ID: <xmqqegjh31js.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1438510226-1163-4-git-send-email-jacob.e.keller@intel.com> (Jacob Keller's message of "Sun, 2 Aug 2015 03:10:25 -0700")
Jacob Keller <jacob.e.keller@intel.com> writes:
> From: Jacob Keller <jacob.keller@gmail.com>
>
> Teach git-notes about a new configuration option "notes.merge" for
> selecting the default notes merge strategy. Document the option in
> config.txt and git-notes.txt
>
> Add tests for use of the configuration option. Include a test to ensure
> that --strategy correctly overrides the configured setting.
>
> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
> Cc: Johan Herland <johan@herland.net>
> Cc: Michael Haggerty <mhagger@alum.mit.edu>
> Cc: Eric Sunshine <sunshine@sunshineco.com>
> ---
Perhaps I am biased because we do not usually use Cc: around here,
but the above looks in a somewhat strange order. Shouldn't your
sign-off be at the end?
> +static enum notes_merge_strategy merge_strategy;
OK.
> +static int parse_notes_strategy(const char *arg, enum notes_merge_strategy *strategy)
> +{
> + if (!strcmp(arg, "manual"))
> + *strategy = NOTES_MERGE_RESOLVE_MANUAL;
> + else if (!strcmp(arg, "ours"))
> + *strategy = NOTES_MERGE_RESOLVE_OURS;
> + else if (!strcmp(arg, "theirs"))
> + *strategy = NOTES_MERGE_RESOLVE_THEIRS;
> + else if (!strcmp(arg, "union"))
> + *strategy = NOTES_MERGE_RESOLVE_UNION;
> + else if (!strcmp(arg, "cat_sort_uniq"))
> + *strategy = NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ;
> + else
> + return -1;
> +
> + return 0;
> +}
OK.
> static int merge(int argc, const char **argv, const char *prefix)
> {
> struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
> @@ -795,23 +815,13 @@ static int merge(int argc, const char **argv, const char *prefix)
> expand_notes_ref(&remote_ref);
> o.remote_ref = remote_ref.buf;
>
> - if (strategy) {
> - if (!strcmp(strategy, "manual"))
> - o.strategy = NOTES_MERGE_RESOLVE_MANUAL;
> - else if (!strcmp(strategy, "ours"))
> - o.strategy = NOTES_MERGE_RESOLVE_OURS;
> - else if (!strcmp(strategy, "theirs"))
> - o.strategy = NOTES_MERGE_RESOLVE_THEIRS;
> - else if (!strcmp(strategy, "union"))
> - o.strategy = NOTES_MERGE_RESOLVE_UNION;
> - else if (!strcmp(strategy, "cat_sort_uniq"))
> - o.strategy = NOTES_MERGE_RESOLVE_CAT_SORT_UNIQ;
> - else {
> - error("Unknown -s/--strategy: %s", strategy);
> - usage_with_options(git_notes_merge_usage, options);
> - }
> + if (strategy && parse_notes_strategy(strategy, &merge_strategy)) {
> + error("Unknown -s/--strategy: %s", strategy);
> + usage_with_options(git_notes_merge_usage, options);
> }
>
> + o.strategy = merge_strategy;
> +
This may be a minor taste thing, but initializing "o.strategy" with
merge_strategy at the same place as "o.remote_ref" is initialized,
and then passing &o.merge_strategy to parse_notes_strategy(), may be
easier to follow.
Renaming the global "merge_strategy" to "configured_merge_strategy"
might make it even easier to follow. If anybody uses the variable
instead of o.strategy after this point, it would be immediately
obvious that it is either a bug or it is deliberately using the
value from the configuration file, not command line.
Thanks.
next prev parent reply other threads:[~2015-08-05 20:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-02 10:10 [PATCH v3 0/4] notes: add support for notes.merge option Jacob Keller
2015-08-02 10:10 ` [PATCH v3 1/4] notes: document cat_sort_uniq rewriteMode Jacob Keller
2015-08-02 10:10 ` [PATCH v3 2/4] notes: add tests for --commit/--abort/--strategy exclusivity Jacob Keller
2015-08-02 10:10 ` [PATCH v3 3/4] notes: add notes.merge option to select default strategy Jacob Keller
2015-08-05 20:47 ` Junio C Hamano [this message]
2015-08-06 22:37 ` Eric Sunshine
2015-08-02 10:10 ` [PATCH RFC 4/4] notes: add per-ref configuration of merge strategy Jacob Keller
2015-08-05 21:10 ` Junio C Hamano
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=xmqqegjh31js.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jacob.keller@gmail.com \
--cc=johan@herland.net \
--cc=mhagger@alum.mit.edu \
--cc=sunshine@sunshineco.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).