git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Pranit Bauva <pranit.bauva@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC] parse-options.c: make OPTION__COUNTUP consider negative values
Date: Wed, 16 Mar 2016 21:50:44 -0400	[thread overview]
Message-ID: <20160317015044.GB12830@sigill.intra.peff.net> (raw)
In-Reply-To: <0102015381b7c7b5-5b57a780-369b-478b-94d2-7094f0befdad-000000@eu-west-1.amazonses.com>

On Wed, Mar 16, 2016 at 11:16:58PM +0000, Pranit Bauva wrote:

> The reason to make it consider negative values or more specifically
> "unspecified" values is to differentiate between the option passed
> once, multiple times or with --no-option. This makes the receiver
> know what actually happened with the arguments which is particularly
> required with option have multiple levels of that option.
> 
> Eg. :
> initialize verbose = -1
> `git commit` => verbose = -1
> `git commit -v` => verbose = 1
> `git commit -v -v` => verbose = 1
> `git commit --no-verbose` => verbose = 0

This second to last example would be 2, right?

That aside, this patch does mean that one can no longer use
OPT_COUNTUP() for negative values (i.e., the caller must start it at
either 0 or 1, and it must always go up from there).

And we would need to verify that all of the existing callers are OK with
this. Did you check that that (not rhetorical; I suspect they are all
OK, but somebody needs to check)?

We are also changing semantics without changing the interface, which
means any topics in flight (that you _cannot_ review, because you have
not seen them yet) may be subtly broken. To me that is not an absolute
deal-breaker, but something to weigh against the utility of the change.

When looking more carefully at builtin/commit.c for the other thread, it
occurred to me that OPT_BOOL might be a better fit for commit's "-v". It
really is a boolean "show the diff or not" and thus unlike the other
"make me more verbose". And OPT_BOOL already has the behavior you want,
I think.

-Peff

  reply	other threads:[~2016-03-17  1:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 23:16 [PATCH/RFC] parse-options.c: make OPTION__COUNTUP consider negative values Pranit Bauva
2016-03-17  1:50 ` Jeff King [this message]
2016-03-17  7:28   ` Eric Sunshine
2016-03-17  8:14     ` Eric Sunshine
2016-03-17 20:22     ` Pranit Bauva
2016-03-18 11:23   ` Pranit Bauva
2016-03-20  4:10     ` Jeff King
2016-03-20  9:07       ` Pranit Bauva

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=20160317015044.GB12830@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=pranit.bauva@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).