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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2017, 03:40 UTC
Message-ID
<xmqqvaiealsv.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20171112153659.lt77rn6h6faeqfpb@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
>> @@ -47,6 +48,7 @@ static int show_origin;
>>  #define ACTION_GET_COLOR (1<<13)
>>  #define ACTION_GET_COLORBOOL (1<<14)
>>  #define ACTION_GET_URLMATCH (1<<15)
>> +#define ACTION_GET_COLORORDEFAULT (1<<16)
>
> I'm not sure I understand this part, though. Providing a default should
> be something that goes along with a "get" action, but isn't its own
> action.
I agree that it is not.

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.

Previous: Jeff KingNext: Jeff King
Message 4 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.