git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Soukaina NAIT HMID <nhsoukaina@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [add-default-config 2/5] adding default to color
Date: Sun, 12 Nov 2017 15:37:00 +0000	[thread overview]
Message-ID: <20171112153659.lt77rn6h6faeqfpb@sigill.intra.peff.net> (raw)
In-Reply-To: <0102015fb0bf3002-3462777a-2363-40cf-af37-80e26c0db65b-000000@eu-west-1.amazonses.com>

On Sun, Nov 12, 2017 at 03:00:40PM +0000, Soukaina NAIT HMID wrote:

> diff --git a/builtin/config.c b/builtin/config.c
> index 124a682d50fa8..9df2d9c43bcad 100644
> --- a/builtin/config.c
> +++ b/builtin/config.c
> @@ -30,6 +30,7 @@ static int end_null;
>  static int respect_includes_opt = -1;
>  static struct config_options config_options;
>  static int show_origin;
> +static const char *default_value;
> [...]
> +	OPT_STRING(0, "default", &default_value, N_("default-value"), N_("sets default for bool/int/path/color when no value is returned from config")),

These hunks make sense. We're adding a new "--default" option that would
kick in when you try to look up a key and it isn't present.

I think we can skip the "bool/int/path/color" thing in the help string.
We would want this to kick in for every type, right?  The only
constraint is that we are doing a "get" operation. It wouldn't make any
sense to use "--default" when setting a variable, listing, etc. Should
we catch these cases and return an error?

We'd also want to mention this in Documentation/git-config.txt.

> @@ -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.

> +static void get_color_default(const char *var)
> +{
> +	get_color(var, default_value);
> +}
> +

And here we're just applying --default to colors, but we'd eventually
want them for everything. I think that's fixed later in the series, so
I'll keep reading. But I'd expect a function like get_value() to be
detecting the case where we got no hits and filling in the default_value
there, as if we had read it from the config file.

-Peff

  reply	other threads:[~2017-11-12 15:37 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 2/5] adding default to color Soukaina NAIT HMID
2017-11-12 15:37   ` Jeff King [this message]
2017-11-13  3:40     ` Junio C Hamano
2017-11-13  3:55       ` Jeff King
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 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=20171112153659.lt77rn6h6faeqfpb@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --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).