git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bert Wesarg <bert.wesarg@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Matthew Rogers via GitGitGadget <gitgitgadget@gmail.com>,
	Git Mailing List <git@vger.kernel.org>,
	Matthew Rogers <mattr94@gmail.com>
Subject: Re: [PATCH v3 4/4] config: add '--show-scope' to print the scope of a config value
Date: Fri, 17 Jan 2020 22:26:48 +0100	[thread overview]
Message-ID: <CAKPyHN2vZbJparPNVQ1C9nOKk5ZrfeOZWxwbcLnTbwbdJWMLgA@mail.gmail.com> (raw)
In-Reply-To: <xmqqsgkddbjz.fsf@gitster-ct.c.googlers.com>

On Fri, Jan 17, 2020 at 10:21 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Matthew Rogers via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > +--show-scope::
> > +     Similar to `--show-origin` in that it augments the output of
> > +     all queried config options with the scope of that value
> > +     (local, global, system, command).
> > +
> >  --get-colorbool name [stdout-is-tty]::
> >
> >       Find the color setting for `name` (e.g. `color.diff`) and output
> > diff --git a/builtin/config.c b/builtin/config.c
> > index 52a904cfb1..d5931061e8 100644
> > --- a/builtin/config.c
> > +++ b/builtin/config.c
> > @@ -33,6 +33,7 @@ static int end_nul;
> >  static int respect_includes_opt = -1;
> >  static struct config_options config_options;
> >  static int show_origin;
> > +static int show_scope;
> >
> >  #define ACTION_GET (1<<0)
> >  #define ACTION_GET_ALL (1<<1)
> > @@ -155,6 +156,7 @@ static struct option builtin_config_options[] = {
> >       OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")),
> >       OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
> >       OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")),
> > +     OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)")),
> >       OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")),
> >       OPT_END(),
> >  };
> > @@ -189,11 +191,43 @@ static void show_config_origin(struct strbuf *buf)
> >       strbuf_addch(buf, term);
> >  }
> >
> > +static const char *scope_to_string(enum config_scope scope)
> > +{
> > +     switch (scope) {
> > +     case CONFIG_SCOPE_LOCAL:
> > +             return "local";
> > +     case CONFIG_SCOPE_GLOBAL:
> > +             return "global";
> > +     case CONFIG_SCOPE_SYSTEM:
> > +             return "system";
> > +     case CONFIG_SCOPE_WORKTREE:
> > +             return "worktree";
> > +     case CONFIG_SCOPE_COMMAND:
> > +             return "command";
> > +     case CONFIG_SCOPE_SUBMODULE:
> > +             return "submodule";
> > +     default:
> > +             return "unknown";
> > +     }
> > +}
>
> It is a shame that with this defined in the main part of the system
> test-tool still needs to carry its own private copy.
>
> I wonder if it results in a better system if we rename this to
>
>         const char *config_scope_name(enum config_scope scope)
>
> made it externally visible, and use it in t/helper/test-config.c
> and get rid of the private copy scope_name() there?
>

+1 and please keep the order in config_scope_name the same as in the
enum definition. Will base my 'remote rename &
branch.<name>.pushRemote'  series on this then.

Bert

> > diff --git a/config.h b/config.h
> > index f383a71404..91f851e925 100644
> > --- a/config.h
> > +++ b/config.h
> > @@ -35,10 +35,21 @@ struct object_id;
> >
> >  #define CONFIG_REGEX_NONE ((void *)1)
> >
> > +enum config_scope {
> > +     CONFIG_SCOPE_UNKNOWN = 0,
> > +     CONFIG_SCOPE_SYSTEM,
> > +     CONFIG_SCOPE_GLOBAL,
> > +     CONFIG_SCOPE_LOCAL,
> > +     CONFIG_SCOPE_WORKTREE,
> > +     CONFIG_SCOPE_COMMAND,
> > +     CONFIG_SCOPE_SUBMODULE,
> > +};
> > +
>
> And this is the logical place to make an external definition, if we
> were to go that route.
>
> > diff --git a/t/t1300-config.sh b/t/t1300-config.sh
> > index 983a0a1583..b654a6d2f9 100755
> > --- a/t/t1300-config.sh
> > +++ b/t/t1300-config.sh
> > @@ -1766,6 +1766,64 @@ test_expect_success !MINGW '--show-origin blob ref' '
> >       test_cmp expect output
> >  '
> >
> > +test_expect_success '--show-scope with --list' '
> > +     cat >expect <<-EOF &&
> > +             global  user.global=true
> > +             global  user.override=global
> > +             global  include.path=$INCLUDE_DIR/absolute.include
> > +             global  user.absolute=include
> > +             local   user.local=true
> > +             local   user.override=local
> > +             local   include.path=../include/relative.include
> > +             local   user.relative=include
> > +             command user.cmdline=true
> > +     EOF
>
> The HERE-DOC is over-indented.  All the body lines should align with
> cat and EOF.  The same comment applies to many "<<-" added by this
> patch---mimick the "<<-" that appear in earlier part of the same
> file.
>
> > +test_expect_success !MINGW '--show-scope with --blob' '
> > +     blob=$(git hash-object -w "$CUSTOM_CONFIG_FILE") &&
> > +     cat >expect <<-EOF &&
> > +             command user.custom=true
> > +     EOF
> > +     git config --blob=$blob --show-scope --list >output &&
> > +     test_cmp expect output
> > +'
>
> Missing blank line between two tests.
>
> I wonder if we want to revamp the tests for --show-origin that wants
> to make sure a funny filename is quoted properly.  For that purpose,
> CUSTOM_CONFIG_FILE is given a funny pathname, and it would have been
> OK to use that only for a single "do we quote properly?" test, but
> instead we use that same funnily-named file as the source in many
> places where we do not *care* how --show-origin quotes the pathname
> at all, and end up having to skip with !MINGW.
>
> It's a bad tradition that started at 45bf3297 ("t1300: fix the new
> --show-origin tests on Windows", 2016-03-23), I guess, and is not a
> new problem introduced by this patch, but it should stop so that we
> can have a better test coverage everywhere.
>
> Other than that, I think that the new feature added by this series
> is a sensible one.  Thanks for working on it.
>

  reply	other threads:[~2020-01-17 21:27 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18  1:11 [PATCH 0/1] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2019-12-18  1:11 ` [PATCH 1/1] " Matthew Rogers via GitGitGadget
2019-12-18 19:46   ` Junio C Hamano
2019-12-19  5:05     ` Jeff King
2019-12-19 17:51       ` Junio C Hamano
2019-12-18 22:45   ` Philip Oakley
2019-12-19  0:12     ` mattr94
2019-12-19 17:56       ` Junio C Hamano
2019-12-20 22:58         ` Matt Rogers
2019-12-21  2:37           ` Junio C Hamano
2019-12-21  3:08             ` Matt Rogers
2019-12-21 23:47               ` Junio C Hamano
2020-01-09 10:16 ` [PATCH v2 0/4] " Matthew Rogers via GitGitGadget
2020-01-09 10:16   ` [PATCH v2 1/4] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-09 19:07     ` Junio C Hamano
2020-01-09 23:22       ` Matt Rogers
2020-01-10 11:55     ` Jeff King
2020-01-09 10:16   ` [PATCH v2 2/4] config: fix config scope enum Matthew Rogers via GitGitGadget
2020-01-09 19:06     ` Junio C Hamano
2020-01-09 23:29       ` Matt Rogers
2020-01-09 10:16   ` [PATCH v2 3/4] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-09 19:13     ` Junio C Hamano
2020-01-09 23:41       ` Matt Rogers
2020-01-09 10:16   ` [PATCH v2 4/4] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-09 19:50     ` Junio C Hamano
2020-01-09 23:47       ` Matt Rogers
2020-01-17 15:31   ` [PATCH v3 0/4] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2020-01-17 15:31     ` [PATCH v3 1/4] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-17 15:31     ` [PATCH v3 2/4] config: refine config scope enum Matthew Rogers via GitGitGadget
2020-01-17 20:44       ` Junio C Hamano
2020-01-18 15:27         ` Matt Rogers
2020-01-18 18:09           ` Junio C Hamano
2020-01-17 15:31     ` [PATCH v3 3/4] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-17 21:00       ` Junio C Hamano
2020-01-18 15:33         ` Matt Rogers
2020-01-17 15:31     ` [PATCH v3 4/4] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-17 21:21       ` Junio C Hamano
2020-01-17 21:26         ` Bert Wesarg [this message]
2020-01-18 15:42         ` Matt Rogers
2020-01-24  0:21     ` [PATCH v4 0/6] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2020-01-24  0:21       ` [PATCH v4 1/6] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-24  0:21       ` [PATCH v4 2/6] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-01-24 18:43         ` Junio C Hamano
2020-01-24  0:21       ` [PATCH v4 3/6] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-01-24 18:45         ` Junio C Hamano
2020-01-24  0:21       ` [PATCH v4 4/6] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-01-24 18:49         ` Junio C Hamano
2020-01-24 19:09         ` Junio C Hamano
2020-01-24  0:21       ` [PATCH v4 5/6] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-24  0:21       ` [PATCH v4 6/6] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-24 19:18         ` Junio C Hamano
2020-01-24 20:22         ` Junio C Hamano
2020-01-24 20:49           ` Matt Rogers
2020-01-25  0:10             ` Junio C Hamano
2020-01-24 19:22       ` [PATCH v4 0/6] config: allow user to know scope of config options Junio C Hamano
2020-01-25  0:39       ` [PATCH v5 " Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 1/6] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 2/6] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 3/6] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 4/6] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-01-27 23:09           ` Junio C Hamano
2020-01-25  0:39         ` [PATCH v5 5/6] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-25  0:39         ` [PATCH v5 6/6] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-27 23:12           ` Junio C Hamano
2020-01-28  1:31             ` Matt Rogers
2020-01-29  3:34         ` [PATCH v6 0/6] config: allow user to know scope of config options Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 1/6] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 2/6] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 3/6] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 4/6] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 5/6] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-01-29  3:34           ` [PATCH v6 6/6] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget
2020-01-29  9:08             ` Bert Wesarg
2020-01-29 23:03               ` Matt Rogers
2020-02-05 19:01                 ` Junio C Hamano
2020-01-29  5:29           ` [PATCH v6 0/6] config: allow user to know scope of config options Junio C Hamano
2020-02-10  0:30           ` [PATCH v7 00/10] " Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 01/10] config: fix typo in variable name Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 02/10] t1300: fix over-indented HERE-DOCs Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 03/10] t1300: create custom config file without special characters Matthew Rogers via GitGitGadget
2020-02-10  0:30             ` [PATCH v7 04/10] config: make scope_name non-static and rename it Matthew Rogers via GitGitGadget
2020-02-10 18:02               ` Junio C Hamano
2020-02-10 21:25                 ` Junio C Hamano
2020-02-11  0:30                 ` Matt Rogers
2020-02-11  1:58                   ` Emily Shaffer
2020-02-11  6:10                   ` Junio C Hamano
2020-02-11 12:37                     ` Matt Rogers
2020-02-10  0:30             ` [PATCH v7 05/10] config: split repo scope to local and worktree Matthew Rogers via GitGitGadget
2020-02-10 18:07               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 06/10] config: clarify meaning of command line scoping Matthew Rogers via GitGitGadget
2020-02-10 18:10               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 07/10] config: preserve scope in do_git_config_sequence Matthew Rogers via GitGitGadget
2020-02-10 18:11               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 08/10] config: teach git_config_source to remember its scope Matthew Rogers via GitGitGadget
2020-02-10 18:14               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 09/10] submodule-config: add subomdule config scope Matthew Rogers via GitGitGadget
2020-02-10 18:15               ` Junio C Hamano
2020-02-10  0:30             ` [PATCH v7 10/10] config: add '--show-scope' to print the scope of a config value Matthew Rogers via GitGitGadget

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=CAKPyHN2vZbJparPNVQ1C9nOKk5ZrfeOZWxwbcLnTbwbdJWMLgA@mail.gmail.com \
    --to=bert.wesarg@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=mattr94@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).