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

Re: [PATCH v6 3/4] notes: add notes.mergestrategy option to select default strategy

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Aug 14, 2015, 21:06 UTC
Message-ID
<CAPig+cTjQu2LRuR5cC+VSihVB00k-bjew3eCqA4Ee_tRuDK_=w@mail.gmail.com>
In-Reply-To
<1439585329-10542-4-git-send-email-jacob.e.keller@intel.com>
On Fri, Aug 14, 2015 at 4:48 PM, Jacob Keller <jacob.e.keller@intel.com> wrote:
Show 30 quoted lines
> From: Jacob Keller <jacob.keller@gmail.com>
>
> Teach git-notes about "notes.mergestrategy" 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>
> ---
> diff --git a/builtin/notes.c b/builtin/notes.c
> index 042348082709..d65134f89b40 100644
> --- a/builtin/notes.c
> +++ b/builtin/notes.c
> @@ -738,6 +738,41 @@ static int merge_commit(struct notes_merge_options *o)
> +static int git_config_get_notes_strategy(const char *key,
> +                                        enum notes_merge_strategy *strategy)
> +{
> +       const char *value = NULL;
> +
> +       git_config_get_string_const(key, &value);
> +
> +       if (value) {
> +               if (parse_notes_strategy(value, strategy))
> +                       git_die_config(key, "unknown notes merge strategy '%s'", value);
> +               else
> +                       return 0;
> +       }
> +
> +       return 1;
> +}
Nice. This seems like a better (and more user-helpful) approach.

Instead of initializing value to NULL and ignoring the return value of git_config_get_string_const(), would it instead make sense to respect the return of git_config_get_string_const(), like this?

    const char *value;
    if (!git_config_get_string_const(key, &value)) {
        if (parse_notes_strategy(value, strategy))
            git_die_config(key, "unknown notes merge strategy '%s'", value);
        return 0;
    }
    return 1;
Or, the equivalent, but less indented:
    if (git_config_get_string_const(key, &value))
        return 1;
    if (parse_notes_strategy(value, strategy))
        git_die_config(key, "unknown notes merge strategy '%s'", value);
    return 0;
Previous: Jacob KellerNext: Jacob Keller
Message 5 of 7 in “notes.mergestrategy config option”
  1. 0/4 notes.mergestrategy config optionJacob Keller, Aug 14, 2015
  2. 1/4 notes: document cat_sort_uniq rewriteModeJacob Keller, Aug 14, 2015
  3. 2/4 notes: add tests for --commit/--abort/--strategy exclusivityJacob Keller, Aug 14, 2015
  4. 3/4 notes: add notes.mergestrategy option to select default strategyJacob Keller, Aug 14, 2015
  5. Eric SunshineAug 14, 2015
  6. Jacob KellerAug 14, 2015
  7. 4/4 notes: teach git-notes about notes.<ref>.mergestrategy optionJacob Keller, Aug 14, 2015

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.