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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 14, 2015 at 4:48 PM, Jacob Keller <jacob.e.keller@xxxxxxxxx> wrote:
> From: Jacob Keller <jacob.keller@xxxxxxxxx>
>
> 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@xxxxxxxxx>
> ---
> 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;
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]