Re: [PATCHv2] Add an optional argument for --color options

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

 



On 02/16/2010 08:55 PM, Mark Lodato wrote:
> @@ -599,6 +600,22 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
>  	return 0;
>  }
>  
> +int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
> +			    int unset)
> +{
> +	int value;
> +	if (unset && arg)
> +		return opterror(opt, "takes no value", OPT_UNSET);
>   

We can't have unset and arg both set at the same time. This exact case
is handled by get_value() in parse-options.c (did you copy that?)

> +	if (!arg)
> +		arg = unset ? "never" : (const char *)opt->defval;
>   

I've always been annoyed that the OPTION_CALLBACK doesn't set the
option's value to the defval before calling the callback when it's
PARSE_OPT_OPTARG. If it did we could drop half of this if condition too.

Here's something to squash
--->8----

diff --git a/parse-options.c b/parse-options.c
index 22da9be..0986314 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -604,8 +604,6 @@ int parse_opt_color_flag_cb(const struct option *opt, const 
                            int unset)
 {
        int value;
-       if (unset && arg)
-               return opterror(opt, "takes no value", OPT_UNSET);
        if (!arg)
                arg = unset ? "never" : (const char *)opt->defval;
        value = git_config_colorbool(NULL, arg, -1);


--
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]