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 List <git@vger.kernel.org>
Subject: Re: parse-options does not recognize "unspecified" behavior
Date: Wed, 16 Mar 2016 17:23:09 -0400	[thread overview]
Message-ID: <20160316212308.GA4538@sigill.intra.peff.net> (raw)
In-Reply-To: <CAFZEwPMa3GZS6pvFwr8PLVDqKm5xmMd307nbjhpZSC_ndpw8vw@mail.gmail.com>

On Thu, Mar 17, 2016 at 02:36:51AM +0530, Pranit Bauva wrote:

> > So I think the caller choosing "-1" here as the "not set" value is the
> > bug.
> >
> > -Peff
> 
> I agree to you on the point that parse-options should not care about
> the value passed to it. But I think plainly incrementing the value of
> the variable is not a very nice way. I have an another approach to it.
> The parse-options will first store a temporary structure. If there is
> some changes (not the "--no-" ones) then it sets the respective
> variable in temporary structure to the set value. If "--no-" is passed
> then it writes the "reset" value to the respective variable in
> temporary structure. If nothing about that options is specified then
> it copies the respective variable from original to temporary. After
> completing the entire process, it can copy temporary structure to the
> original structure.
> 
> What are your opinions about this?

I don't think that would produce the wrong behavior, but it seems like a
very complicated solution to a problem that can easily be solved by just
following the usual conventions (that verbose starts at 0, options make
it go up or down, and "--no-" resets it to zero).

Perhaps it would make more sense if I understood what your goal was in
setting verbose to -1 in the first place.

-Peff

  reply	other threads:[~2016-03-16 21:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 19:51 parse-options does not recognize "unspecified" behavior Pranit Bauva
2016-03-16 20:49 ` Jeff King
2016-03-16 21:06   ` Pranit Bauva
2016-03-16 21:23     ` Jeff King [this message]
2016-03-16 21:37       ` Eric Sunshine
2016-03-16 21:41         ` Pranit Bauva
2016-03-16 21:44         ` Jeff King
2016-03-16 21:53           ` Stefan Beller
2016-03-16 23:16             ` Jeff King
2016-03-16 23:33               ` Stefan Beller
2016-03-17  1:43                 ` Jeff King
2016-03-17  5:32                   ` Eric Sunshine
2016-03-17  5:40                     ` Jeff King
2016-03-19 11:25                   ` SZEDER Gábor
2016-03-19 16:55                     ` Pranit Bauva
2016-03-25 14:58                       ` SZEDER Gábor
2016-03-25 15:03                         ` Pranit Bauva
2016-03-16 21:37       ` 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=20160316212308.GA4538@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).