git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <bebarino@gmail.com>
To: Mark Lodato <lodatom@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCHv2] Add an optional argument for --color options
Date: Thu, 18 Feb 2010 01:56:44 -0800	[thread overview]
Message-ID: <4B7D0EDC.8070309@gmail.com> (raw)
In-Reply-To: <1266382558-26325-1-git-send-email-lodatom@gmail.com>

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);

      reply	other threads:[~2010-02-18  9:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-17  4:55 [PATCHv2] Add an optional argument for --color options Mark Lodato
2010-02-18  9:56 ` Stephen Boyd [this message]

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=4B7D0EDC.8070309@gmail.com \
    --to=bebarino@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lodatom@gmail.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).