git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [add-default-config 2/5] adding default to color

From
Jeff King <peff@peff.net>
Date
Nov 13, 2017, 03:55 UTC
Message-ID
<20171113035516.446uznhfl6xlfvmi@sigill.intra.peff.net>
In-Reply-To
<xmqqvaiealsv.fsf@gitster.mtv.corp.google.com>
On Mon, Nov 13, 2017 at 12:40:16PM +0900, Junio C Hamano wrote:
Show 20 quoted lines
> 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
Previous: Junio C HamanoNext: Soukaina NAIT HMID
Message 5 of 14 in “[add-default-config 1/5] add --color option to git config”
  1. Soukaina NAIT HMIDNov 12, 2017
  2. 2/5 adding default to colorSoukaina NAIT HMID, Nov 12, 2017
  3. Jeff KingNov 12, 2017
  4. Junio C HamanoNov 13, 2017
  5. Jeff KingNov 13, 2017
  6. 5/5 fix return code on default + add testsSoukaina NAIT HMID, Nov 12, 2017
  7. Jeff KingNov 12, 2017
  8. 4/5 add defaults for path/int/boolSoukaina NAIT HMID, Nov 12, 2017
  9. Jeff KingNov 12, 2017
  10. 3/5 add same test for new command format with --default and --colorSoukaina NAIT HMID, Nov 12, 2017
  11. Jeff KingNov 12, 2017
  12. Jeff KingNov 12, 2017
  13. [add-default-config] add --default option to git config.Soukaina NAIT HMID, Nov 28, 2017
  14. Philip OakleyDec 2, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.