git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Soukaina NAIT HMID <nhsoukaina@gmail.com>, git@vger.kernel.org
Subject: Re: [add-default-config 2/5] adding default to color
Date: Mon, 13 Nov 2017 03:55:17 +0000	[thread overview]
Message-ID: <20171113035516.446uznhfl6xlfvmi@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqvaiealsv.fsf@gitster.mtv.corp.google.com>

On Mon, Nov 13, 2017 at 12:40:16PM +0900, Junio C Hamano wrote:

> As an aside.  Over time we accumulated quite a many actions that are
> all mutually exclusive by nature.  I have a feeling that we might be
> better off to move away from this implementation.  The only thing
> that we are getting from the current one-bit-in-a-flag-word is that
> we can name the variable "actions" (instead of "action") to pretend
> as if we can be given more than one, and then having to check its
> value with HAS_MULTI_BITS(actions) to confuse ourselves.
> 
> Instead, perhaps we should introduce an "enum action" that includes
> ACTION_UNSPECIFIED that is the initial value for the "action"
> variable, which gets set to ACTION_GET, etc. with OPT_SET_INT().  If
> we really care about erroring out when given
> 
> 	$ git config --add --get foo.bar
> 
> instead of the "last one wins" semantics, we can use OPT_CMDMODE.
> 
> The above is of course outside the scope of this series, and I am
> not sure if it should be done as a preparatory or a follow-up
> clean-up.

Yes, I agree that it's a little confusing, and that an enum is a better
representation.  The TYPE constants have the same problem.

I _think_ we could use OPT_CMDMODE() for those, too. Despite the name,
there is nothing in the parse-options error message that would be
inappropriate for something that isn't a cmdmode. Though I care a lot
less about "--bool --int" reporting an error (instead of last-one-wins)
than I do about "--get --set".

-Peff

  reply	other threads:[~2017-11-13  3:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-12 15:00 [add-default-config 1/5] add --color option to git config Soukaina NAIT HMID
2017-11-12 15:00 ` [add-default-config 4/5] add defaults for path/int/bool Soukaina NAIT HMID
2017-11-12 15:45   ` Jeff King
2017-11-12 15:00 ` [add-default-config 5/5] fix return code on default + add tests Soukaina NAIT HMID
2017-11-12 16:04   ` Jeff King
2017-11-12 15:00 ` [add-default-config 2/5] adding default to color Soukaina NAIT HMID
2017-11-12 15:37   ` Jeff King
2017-11-13  3:40     ` Junio C Hamano
2017-11-13  3:55       ` Jeff King [this message]
2017-11-12 15:00 ` [add-default-config 3/5] add same test for new command format with --default and --color Soukaina NAIT HMID
2017-11-12 15:37   ` Jeff King
2017-11-12 15:22 ` [add-default-config 1/5] add --color option to git config Jeff King
2017-11-28 21:43 ` [add-default-config] add --default " Soukaina NAIT HMID
2017-12-02 20:33   ` Philip Oakley

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171113035516.446uznhfl6xlfvmi@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nhsoukaina@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).