From: Johan Herland <johan@herland.net>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Git mailing list <git@vger.kernel.org>,
Michael Haggerty <mhagger@alum.mit.edu>,
Eric Sunshine <sunshine@sunshineco.com>,
Junio C Hamano <gitster@pobox.com>,
Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCH v4 3/4] notes: add notes.merge option to select default strategy
Date: Wed, 12 Aug 2015 02:04:21 +0200 [thread overview]
Message-ID: <CALKQrgcYpbae0eu2sT_rOZYq3DsnVSpYua1SZr=TC=dYfG_fpw@mail.gmail.com> (raw)
In-Reply-To: <1439326641-9447-4-git-send-email-jacob.e.keller@intel.com>
On Tue, Aug 11, 2015 at 10:57 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:
> From: Jacob Keller <jacob.keller@gmail.com>
>
> Teach git-notes about "notes.merge" to select a general strategy for all
> notes merges. This enables a user to always get expected merge strategy
> such as "cat_sort_uniq" without having to pass the "-s" option manually.
>
> Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
> ---
> Documentation/config.txt | 7 ++++++
> Documentation/git-notes.txt | 14 +++++++++++-
> builtin/notes.c | 44 +++++++++++++++++++++++--------------
> notes-merge.h | 16 ++++++++------
> t/t3309-notes-merge-auto-resolve.sh | 29 ++++++++++++++++++++++++
> 5 files changed, 86 insertions(+), 24 deletions(-)
>
[...]
> diff --git a/builtin/notes.c b/builtin/notes.c
> index 63f95fc55439..3c705f5e26ff 100644
> --- a/builtin/notes.c
> +++ b/builtin/notes.c
> @@ -737,6 +737,24 @@ static int merge_commit(struct notes_merge_options *o)
> return ret;
> }
>
> +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;
> +}
> +
> static int merge(int argc, const char **argv, const char *prefix)
> {
> struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
> @@ -745,7 +763,7 @@ static int merge(int argc, const char **argv, const char *prefix)
> struct notes_merge_options o;
> int do_merge = 0, do_commit = 0, do_abort = 0;
> int verbosity = 0, result;
> - const char *strategy = NULL;
> + const char *strategy = NULL, *configured_strategy = NULL;
> struct option options[] = {
> OPT_GROUP(N_("General options")),
> OPT__VERBOSITY(&verbosity),
> @@ -795,21 +813,15 @@ 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);
> - }
> + git_config_get_string_const("notes.merge", &configured_strategy);
> +
> + if (configured_strategy &&
> + parse_notes_strategy(configured_strategy, &o.strategy))
> + die("Unknown notes merge strategy: %s", configured_strategy);
> +
> + if (strategy && parse_notes_strategy(strategy, &o.strategy)) {
> + error("Unknown -s/--strategy: %s", strategy);
> + usage_with_options(git_notes_merge_usage, options);
> }
Do you need to look at the notes.merge config variable at all if
-s/--strategy is given?
I'd expect the above to rather look something like:
if (strategy) {
if (parse_notes_strategy(strategy, &o.strategy)) {
error("Unknown -s/--strategy: %s", strategy);
usage_with_options(git_notes_merge_usage, options);
}
} else if (configured_strategy) {
if (parse_notes_strategy(configured_strategy, &o.strategy))
die("Unknown notes merge strategy: %s", configured_strategy);
} /* else o.strategy = NOTES_MERGE_RESOLVE_MANUAL; */
Otherwise, this patch looks good to me.
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
next prev parent reply other threads:[~2015-08-12 0:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-11 20:57 [PATCH v4 0/4] add notes strategy configuration options Jacob Keller
2015-08-11 20:57 ` [PATCH v4 1/4] notes: document cat_sort_uniq rewriteMode Jacob Keller
2015-08-12 0:35 ` Johan Herland
2015-08-11 20:57 ` [PATCH v4 2/4] notes: add tests for --commit/--abort/--strategy exclusivity Jacob Keller
2015-08-12 0:36 ` Johan Herland
2015-08-11 20:57 ` [PATCH v4 3/4] notes: add notes.merge option to select default strategy Jacob Keller
2015-08-12 0:04 ` Johan Herland [this message]
2015-08-11 20:57 ` [PATCH v4 4/4] notes: teach git-notes about notes.<ref>.merge option Jacob Keller
2015-08-12 0:11 ` Eric Sunshine
2015-08-12 0:34 ` Johan Herland
2015-08-12 2:26 ` Junio C Hamano
2015-08-12 19:05 ` Jacob Keller
2015-08-12 19:09 ` Junio C Hamano
2015-08-12 19:16 ` Jacob Keller
2015-08-12 21:43 ` Jacob Keller
2015-08-12 22:04 ` Johan Herland
2015-08-12 21:46 ` Johan Herland
2015-08-12 21:57 ` Jacob Keller
2015-08-12 22:03 ` Jacob Keller
2015-08-12 22:41 ` Junio C Hamano
2015-08-12 22:51 ` Jacob Keller
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALKQrgcYpbae0eu2sT_rOZYq3DsnVSpYua1SZr=TC=dYfG_fpw@mail.gmail.com' \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jacob.e.keller@intel.com \
--cc=jacob.keller@gmail.com \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).