builtin/config: introduce "list" subcommand

While git-config(1) has several modes, those modes are not exposed with subcommands but instead by specifying action flags like `--unset` or `--list`. This user interface is not really in line with how our more modern commands work, where it is a lot more customary to say e.g. `git remote list`. Furthermore, to add to the confusion, git-config(1) also allows the user to request modes implicitly by just specifying the correct number of arguments. Thus, `git config foo.bar` will retrieve the value of "foo.bar" while `git config foo.bar baz` will set it to "baz". Overall, this makes for a confusing interface that could really use a makeover. It hurts discoverability of what you can do with git-config(1) and is comparatively easy to get wrong. Converting the command to have subcommands instead would go a long way to help address these issues. One concern in this context is backwards compatibility. Luckily, we can introduce subcommands without breaking backwards compatibility at all. This is because all the implicit modes of git-config(1) require that the first argument is a properly formatted config key. And as config keys _must_ have a dot in their name, any value without a dot would have been discarded by git-config(1) previous to this change. Thus, given that none of the subcommands do have a dot, they are unambiguous. Introduce the first such new subcommand, which is "git config list". To retain backwards compatibility we only conditionally use subcommands and will fall back to the old syntax in case no subcommand was detected. This should help to transition to the new-style syntax until we eventually deprecate and remove the old-style syntax. Note that the way we handle this we're duplicating some functionality across old and new syntax. While this isn't pretty, it helps us to ensure that there really is no change in behaviour for the old syntax. Amend tests such that we run them both with old and new style syntax. As tests are now run twice, state from the first run may be still be around in the second run and thus cause tests to fail. Add cleanup logic as required to fix such tests. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed May 6, 2024 at 10:56 UTC 14970509c6266d2347fe1a15dbdc0b9b697d2e1a
3 files changed +162 -64
Documentation/git-config.txt
+19 -7
@@ -9,6 +9,7 @@ git-config - Get and set repository or global options
9 SYNOPSIS
10 --------
11 [verse]
12 +'git config list' [<file-option>] [<display-option>] [--includes]
13 'git config' [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]]
14 'git config' [<file-option>] [--type=<type>] [--comment=<message>] --add <name> <value>
15 'git config' [<file-option>] [--type=<type>] [--comment=<message>] [--fixed-value] --replace-all <name> <value> [<value-pattern>]
@@ -20,7 +21,6 @@ SYNOPSIS
21 'git config' [<file-option>] [--fixed-value] --unset-all <name> [<value-pattern>]
22 'git config' [<file-option>] --rename-section <old-name> <new-name>
23 'git config' [<file-option>] --remove-section <name>
23 -'git config' [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list
24 'git config' [<file-option>] --get-color <name> [<default>]
25 'git config' [<file-option>] --get-colorbool <name> [<stdout-is-tty>]
26 'git config' [<file-option>] -e | --edit
@@ -74,6 +74,12 @@ On success, the command returns the exit code 0.
74 A list of all available configuration variables can be obtained using the
75 `git help --config` command.
76
77 +COMMANDS
78 +--------
79 +
80 +list::
81 + List all variables set in config file, along with their values.
82 +
83 [[OPTIONS]]
84 OPTIONS
85 -------
@@ -190,10 +196,6 @@ See also <<FILES>>.
196 --unset-all::
197 Remove all lines matching the key from config file.
198
193 --l::
194 ---list::
195 - List all variables set in config file, along with their values.
196 -
199 --fixed-value::
200 When used with the `value-pattern` argument, treat `value-pattern` as
201 an exact string instead of a regular expression. This will restrict
@@ -248,7 +250,7 @@ Valid `<type>`'s include:
250 contain line breaks.
251
252 --name-only::
251 - Output only the names of config variables for `--list` or
253 + Output only the names of config variables for `list` or
254 `--get-regexp`.
255
256 --show-origin::
@@ -300,10 +302,20 @@ Valid `<type>`'s include:
302 When using `--get`, and the requested variable is not found, behave as if
303 <value> were the value assigned to that variable.
304
305 +DEPRECATED MODES
306 +----------------
307 +
308 +The following modes have been deprecated in favor of subcommands. It is
309 +recommended to migrate to the new syntax.
310 +
311 +-l::
312 +--list::
313 + Replaced by `git config list`.
314 +
315 CONFIGURATION
316 -------------
317 `pager.config` is only respected when listing configuration, i.e., when
306 -using `--list` or any of the `--get-*` which may return multiple results.
318 +using `list` or any of the `--get-*` which may return multiple results.
319 The default is to use a pager.
320
321 [[FILES]]
builtin/config.c
+78 -12
@@ -16,10 +16,16 @@
16 #include "worktree.h"
17
18 static const char *const builtin_config_usage[] = {
19 + N_("git config list [<file-option>] [<display-option>] [--includes]"),
20 N_("git config [<options>]"),
21 NULL
22 };
23
24 +static const char *const builtin_config_list_usage[] = {
25 + N_("git config list [<file-option>] [<display-option>] [--includes]"),
26 + NULL
27 +};
28 +
29 static char *key;
30 static regex_t *key_regexp;
31 static const char *value_pattern;
@@ -33,6 +39,7 @@ static char delim = '=';
39 static char key_delim = ' ';
40 static char term = '\n';
41
42 +static parse_opt_subcommand_fn *subcommand;
43 static int use_global_config, use_system_config, use_local_config;
44 static int use_worktree_config;
45 static struct git_config_source given_config_source;
@@ -706,14 +713,24 @@ static void handle_nul(void) {
713 }
714 }
715
716 +#define CONFIG_LOCATION_OPTIONS \
717 + OPT_GROUP(N_("Config file location")), \
718 + OPT_BOOL(0, "global", &use_global_config, N_("use global config file")), \
719 + OPT_BOOL(0, "system", &use_system_config, N_("use system config file")), \
720 + OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")), \
721 + OPT_BOOL(0, "worktree", &use_worktree_config, N_("use per-worktree config file")), \
722 + OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")), \
723 + OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object"))
724 +
725 +#define CONFIG_DISPLAY_OPTIONS \
726 + OPT_GROUP(N_("Display options")), \
727 + OPT_BOOL('z', "null", &end_nul, N_("terminate values with NUL byte")), \
728 + OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")), \
729 + OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")), \
730 + OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)"))
731 +
732 static struct option builtin_config_options[] = {
710 - OPT_GROUP(N_("Config file location")),
711 - OPT_BOOL(0, "global", &use_global_config, N_("use global config file")),
712 - OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
713 - OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
714 - OPT_BOOL(0, "worktree", &use_worktree_config, N_("use per-worktree config file")),
715 - OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
716 - OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
733 + CONFIG_LOCATION_OPTIONS,
734 OPT_GROUP(N_("Action")),
735 OPT_CMDMODE(0, "get", &actions, N_("get value: name [<value-pattern>]"), ACTION_GET),
736 OPT_CMDMODE(0, "get-all", &actions, N_("get all values: key [<value-pattern>]"), ACTION_GET_ALL),
@@ -737,15 +754,12 @@ static struct option builtin_config_options[] = {
754 OPT_CALLBACK_VALUE(0, "bool-or-str", &type, N_("value is --bool or string"), TYPE_BOOL_OR_STR),
755 OPT_CALLBACK_VALUE(0, "path", &type, N_("value is a path (file or directory name)"), TYPE_PATH),
756 OPT_CALLBACK_VALUE(0, "expiry-date", &type, N_("value is an expiry date"), TYPE_EXPIRY_DATE),
757 + CONFIG_DISPLAY_OPTIONS,
758 OPT_GROUP(N_("Other")),
741 - OPT_BOOL('z', "null", &end_nul, N_("terminate values with NUL byte")),
742 - OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")),
743 - OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
744 - OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")),
745 - OPT_BOOL(0, "show-scope", &show_scope, N_("show scope of config (worktree, local, global, system, command)")),
759 OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")),
760 OPT_STRING(0, "comment", &comment_arg, N_("value"), N_("human-readable comment string (# will be prepended as needed)")),
761 OPT_BOOL(0, "fixed-value", &fixed_value, N_("use string equality when comparing values to 'value-pattern'")),
762 + OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
763 OPT_END(),
764 };
765
@@ -754,6 +768,42 @@ static NORETURN void usage_builtin_config(void)
768 usage_with_options(builtin_config_usage, builtin_config_options);
769 }
770
771 +static int cmd_config_list(int argc, const char **argv, const char *prefix)
772 +{
773 + struct option opts[] = {
774 + CONFIG_LOCATION_OPTIONS,
775 + CONFIG_DISPLAY_OPTIONS,
776 + OPT_GROUP(N_("Other")),
777 + OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
778 + OPT_END(),
779 + };
780 +
781 + argc = parse_options(argc, argv, prefix, opts, builtin_config_list_usage, 0);
782 + check_argc(argc, 0, 0);
783 +
784 + handle_config_location(prefix);
785 + handle_nul();
786 +
787 + setup_auto_pager("config", 1);
788 +
789 + if (config_with_options(show_all_config, NULL,
790 + &given_config_source, the_repository,
791 + &config_options) < 0) {
792 + if (given_config_source.file)
793 + die_errno(_("unable to read config file '%s'"),
794 + given_config_source.file);
795 + else
796 + die(_("error processing config file(s)"));
797 + }
798 +
799 + return 0;
800 +}
801 +
802 +static struct option builtin_subcommand_options[] = {
803 + OPT_SUBCOMMAND("list", &subcommand, cmd_config_list),
804 + OPT_END(),
805 +};
806 +
807 int cmd_config(int argc, const char **argv, const char *prefix)
808 {
809 char *value = NULL, *comment = NULL;
@@ -763,6 +813,22 @@ int cmd_config(int argc, const char **argv, const char *prefix)
813
814 given_config_source.file = xstrdup_or_null(getenv(CONFIG_ENVIRONMENT));
815
816 + /*
817 + * This is somewhat hacky: we first parse the command line while
818 + * keeping all args intact in order to determine whether a subcommand
819 + * has been specified. If so, we re-parse it a second time, but this
820 + * time we drop KEEP_ARGV0. This is so that we don't munge the command
821 + * line in case no subcommand was given, which would otherwise confuse
822 + * us when parsing the legacy-style modes that don't use subcommands.
823 + */
824 + argc = parse_options(argc, argv, prefix, builtin_subcommand_options, builtin_config_usage,
825 + PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_NO_INTERNAL_HELP|PARSE_OPT_KEEP_ARGV0|PARSE_OPT_KEEP_UNKNOWN_OPT);
826 + if (subcommand) {
827 + argc = parse_options(argc, argv, prefix, builtin_subcommand_options, builtin_config_usage,
828 + PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_NO_INTERNAL_HELP|PARSE_OPT_KEEP_UNKNOWN_OPT);
829 + return subcommand(argc, argv, prefix);
830 + }
831 +
832 argc = parse_options(argc, argv, prefix, builtin_config_options,
833 builtin_config_usage,
834 PARSE_OPT_STOP_AT_NON_OPTION);
t/t1300-config.sh
+65 -45
@@ -11,6 +11,20 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
13
14 +for mode in legacy subcommands
15 +do
16 +
17 +case "$mode" in
18 +legacy)
19 + mode_prefix="--"
20 + ;;
21 +subcommands)
22 + mode_prefix=""
23 + ;;
24 +*)
25 + BUG "unknown mode $mode";;
26 +esac
27 +
28 test_expect_success 'setup whitespace config' '
29 sed -e "s/^|//" \
30 -e "s/[$]$//" \
@@ -460,11 +474,11 @@ version.1.2.3eX.alpha=beta
474 EOF
475
476 test_expect_success 'working --list' '
463 - git config --list > output &&
477 + git config ${mode_prefix}list > output &&
478 test_cmp expect output
479 '
480 test_expect_success '--list without repo produces empty output' '
467 - git --git-dir=nonexistent config --list >output &&
481 + git --git-dir=nonexistent config ${mode_prefix}list >output &&
482 test_must_be_empty output
483 '
484
@@ -476,7 +490,7 @@ version.1.2.3eX.alpha
490 EOF
491
492 test_expect_success '--name-only --list' '
479 - git config --name-only --list >output &&
493 + git config ${mode_prefix}list --name-only >output &&
494 test_cmp expect output
495 '
496
@@ -614,17 +628,17 @@ ein.bahn=strasse
628 EOF
629
630 test_expect_success 'alternative GIT_CONFIG' '
617 - GIT_CONFIG=other-config git config --list >output &&
631 + GIT_CONFIG=other-config git config ${mode_prefix}list >output &&
632 test_cmp expect output
633 '
634
635 test_expect_success 'alternative GIT_CONFIG (--file)' '
622 - git config --file other-config --list >output &&
636 + git config ${mode_prefix}list --file other-config >output &&
637 test_cmp expect output
638 '
639
640 test_expect_success 'alternative GIT_CONFIG (--file=-)' '
627 - git config --file - --list <other-config >output &&
641 + git config ${mode_prefix}list --file - <other-config >output &&
642 test_cmp expect output
643 '
644
@@ -637,6 +651,7 @@ test_expect_success 'editing stdin is an error' '
651 '
652
653 test_expect_success 'refer config from subdirectory' '
654 + test_when_finished "rm -r x" &&
655 mkdir x &&
656 test_cmp_config -C x strasse --file=../other-config --get ein.bahn
657 '
@@ -847,7 +862,7 @@ test_expect_success 'line number is reported correctly' '
862 '
863
864 test_expect_success 'invalid stdin config' '
850 - echo "[broken" | test_must_fail git config --list --file - >output 2>&1 &&
865 + echo "[broken" | test_must_fail git config ${mode_prefix}list --file - >output 2>&1 &&
866 test_grep "bad config line 1 in standard input" output
867 '
868
@@ -1139,7 +1154,7 @@ section.quotecont=cont;inued
1154 EOF
1155
1156 test_expect_success 'value continued on next line' '
1142 - git config --list > result &&
1157 + git config ${mode_prefix}list > result &&
1158 test_cmp expect result
1159 '
1160
@@ -1163,7 +1178,7 @@ Qsection.sub=section.val4
1178 Qsection.sub=section.val5Q
1179 EOF
1180 test_expect_success '--null --list' '
1166 - git config --null --list >result.raw &&
1181 + git config ${mode_prefix}list --null >result.raw &&
1182 nul_to_q <result.raw >result &&
1183 echo >>result &&
1184 test_cmp expect result
@@ -1198,6 +1213,7 @@ test_expect_success 'inner whitespace kept verbatim, horizontal tabs and spaces'
1213 '
1214
1215 test_expect_success SYMLINKS 'symlinked configuration' '
1216 + test_when_finished "rm myconfig" &&
1217 ln -s notyet myconfig &&
1218 git config --file=myconfig test.frotz nitfol &&
1219 test -h myconfig &&
@@ -1218,10 +1234,11 @@ test_expect_success SYMLINKS 'symlinked configuration' '
1234 '
1235
1236 test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
1237 + test_when_finished "rm linktonada linktolinktonada" &&
1238 ln -s doesnotexist linktonada &&
1239 ln -s linktonada linktolinktonada &&
1223 - test_must_fail git config --file=linktonada --list &&
1224 - test_must_fail git config --file=linktolinktonada --list
1240 + test_must_fail git config ${mode_prefix}list --file=linktonada &&
1241 + test_must_fail git config ${mode_prefix}list --file=linktolinktonada
1242 '
1243
1244 test_expect_success 'check split_cmdline return' '
@@ -1478,7 +1495,7 @@ do
1495 done
1496
1497 test_expect_success 'git -c is not confused by empty environment' '
1481 - GIT_CONFIG_PARAMETERS="" git -c x.one=1 config --list
1498 + GIT_CONFIG_PARAMETERS="" git -c x.one=1 config ${mode_prefix}list
1499 '
1500
1501 test_expect_success 'GIT_CONFIG_PARAMETERS handles old-style entries' '
@@ -1669,31 +1686,31 @@ test_expect_success 'git config ignores pairs with empty count' '
1686 '
1687
1688 test_expect_success 'git config fails with invalid count' '
1672 - test_must_fail env GIT_CONFIG_COUNT=10a git config --list 2>error &&
1689 + test_must_fail env GIT_CONFIG_COUNT=10a git config ${mode_prefix}list 2>error &&
1690 test_grep "bogus count" error &&
1674 - test_must_fail env GIT_CONFIG_COUNT=9999999999999999 git config --list 2>error &&
1691 + test_must_fail env GIT_CONFIG_COUNT=9999999999999999 git config ${mode_prefix}list 2>error &&
1692 test_grep "too many entries" error
1693 '
1694
1695 test_expect_success 'git config fails with missing config key' '
1696 test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_VALUE_0="value" \
1680 - git config --list 2>error &&
1697 + git config ${mode_prefix}list 2>error &&
1698 test_grep "missing config key" error
1699 '
1700
1701 test_expect_success 'git config fails with missing config value' '
1702 test_must_fail env GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="pair.one" \
1686 - git config --list 2>error &&
1703 + git config ${mode_prefix}list 2>error &&
1704 test_grep "missing config value" error
1705 '
1706
1707 test_expect_success 'git config fails with invalid config pair key' '
1708 test_must_fail env GIT_CONFIG_COUNT=1 \
1709 GIT_CONFIG_KEY_0= GIT_CONFIG_VALUE_0=value \
1693 - git config --list &&
1710 + git config ${mode_prefix}list &&
1711 test_must_fail env GIT_CONFIG_COUNT=1 \
1712 GIT_CONFIG_KEY_0=missing-section GIT_CONFIG_VALUE_0=value \
1696 - git config --list
1713 + git config ${mode_prefix}list
1714 '
1715
1716 test_expect_success 'environment overrides config file' '
@@ -1733,7 +1750,7 @@ test_expect_success 'git config --edit works' '
1750 git config -f tmp test.value no &&
1751 echo test.value=yes >expect &&
1752 GIT_EDITOR="echo [test]value=yes >" git config -f tmp --edit &&
1736 - git config -f tmp --list >actual &&
1753 + git config ${mode_prefix}list -f tmp >actual &&
1754 test_cmp expect actual
1755 '
1756
@@ -1742,7 +1759,7 @@ test_expect_success 'git config --edit respects core.editor' '
1759 echo test.value=yes >expect &&
1760 test_config core.editor "echo [test]value=yes >" &&
1761 git config -f tmp --edit &&
1745 - git config -f tmp --list >actual &&
1762 + git config ${mode_prefix}list -f tmp >actual &&
1763 test_cmp expect actual
1764 '
1765
@@ -2093,7 +2110,7 @@ test_expect_success '--show-origin with --list' '
2110 command line: user.cmdline=true
2111 EOF
2112 GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=user.environ GIT_CONFIG_VALUE_0=true\
2096 - git -c user.cmdline=true config --list --show-origin >output &&
2113 + git -c user.cmdline=true config ${mode_prefix}list --show-origin >output &&
2114 test_cmp expect output
2115 '
2116
@@ -2110,7 +2127,7 @@ test_expect_success '--show-origin with --list --null' '
2127 includeQcommand line:Quser.cmdline
2128 trueQ
2129 EOF
2113 - git -c user.cmdline=true config --null --list --show-origin >output.raw &&
2130 + git -c user.cmdline=true config ${mode_prefix}list --null --show-origin >output.raw &&
2131 nul_to_q <output.raw >output &&
2132 # The here-doc above adds a newline that the --null output would not
2133 # include. Add it here to make the two comparable.
@@ -2124,7 +2141,7 @@ test_expect_success '--show-origin with single file' '
2141 file:.git/config user.override=local
2142 file:.git/config include.path=../include/relative.include
2143 EOF
2127 - git config --local --list --show-origin >output &&
2144 + git config ${mode_prefix}list --local --show-origin >output &&
2145 test_cmp expect output
2146 '
2147
@@ -2162,7 +2179,7 @@ test_expect_success !MINGW '--show-origin escape special file name characters' '
2179 cat >expect <<-\EOF &&
2180 file:"file\" (dq) and spaces.conf" user.custom=true
2181 EOF
2165 - git config --file "$WEIRDLY_NAMED_FILE" --show-origin --list >output &&
2182 + git config ${mode_prefix}list --file "$WEIRDLY_NAMED_FILE" --show-origin >output &&
2183 test_cmp expect output
2184 '
2185
@@ -2170,7 +2187,7 @@ test_expect_success '--show-origin stdin' '
2187 cat >expect <<-\EOF &&
2188 standard input: user.custom=true
2189 EOF
2173 - git config --file - --show-origin --list <"$CUSTOM_CONFIG_FILE" >output &&
2190 + git config ${mode_prefix}list --file - --show-origin <"$CUSTOM_CONFIG_FILE" >output &&
2191 test_cmp expect output
2192 '
2193
@@ -2197,7 +2214,7 @@ test_expect_success '--show-origin blob' '
2214 cat >expect <<-EOF &&
2215 blob:$blob user.custom=true
2216 EOF
2200 - git config --blob=$blob --show-origin --list >output &&
2217 + git config ${mode_prefix}list --blob=$blob --show-origin >output &&
2218 test_cmp expect output
2219 )
2220 '
@@ -2213,7 +2230,7 @@ test_expect_success '--show-origin blob ref' '
2230 cp "$CUSTOM_CONFIG_FILE" custom.conf &&
2231 git add custom.conf &&
2232 git commit -m "new config file" &&
2216 - git config --blob=main:custom.conf --show-origin --list >output &&
2233 + git config ${mode_prefix}list --blob=main:custom.conf --show-origin >output &&
2234 test_cmp expect output
2235 )
2236 '
@@ -2239,13 +2256,14 @@ test_expect_success '--show-scope with --list' '
2256 worktree user.worktree=true
2257 command user.cmdline=true
2258 EOF
2259 + test_when_finished "git worktree remove wt1" &&
2260 git worktree add wt1 &&
2261 # We need these to test for worktree scope, but outside of this
2262 # test, this is just noise
2263 test_config core.repositoryformatversion 1 &&
2264 test_config extensions.worktreeConfig true &&
2265 git config --worktree user.worktree true &&
2248 - git -c user.cmdline=true config --list --show-scope >output &&
2266 + git -c user.cmdline=true config ${mode_prefix}list --show-scope >output &&
2267 test_cmp expect output
2268 '
2269
@@ -2254,7 +2272,7 @@ test_expect_success !MINGW '--show-scope with --blob' '
2272 cat >expect <<-EOF &&
2273 command user.custom=true
2274 EOF
2257 - git config --blob=$blob --show-scope --list >output &&
2275 + git config ${mode_prefix}list --blob=$blob --show-scope >output &&
2276 test_cmp expect output
2277 '
2278
@@ -2264,7 +2282,7 @@ test_expect_success '--show-scope with --local' '
2282 local user.override=local
2283 local include.path=../include/relative.include
2284 EOF
2267 - git config --local --list --show-scope >output &&
2285 + git config ${mode_prefix}list --local --show-scope >output &&
2286 test_cmp expect output
2287 '
2288
@@ -2288,7 +2306,7 @@ test_expect_success '--show-scope with --show-origin' '
2306 local file:.git/../include/relative.include user.relative=include
2307 command command line: user.cmdline=true
2308 EOF
2291 - git -c user.cmdline=true config --list --show-origin --show-scope >output &&
2309 + git -c user.cmdline=true config ${mode_prefix}list --show-origin --show-scope >output &&
2310 test_cmp expect output
2311 '
2312
@@ -2329,7 +2347,7 @@ test_expect_success 'override global and system config' '
2347 global home.config=true
2348 local local.config=true
2349 EOF
2332 - git config --show-scope --list >output &&
2350 + git config ${mode_prefix}list --show-scope >output &&
2351 test_cmp expect output &&
2352
2353 cat >expect <<-EOF &&
@@ -2338,20 +2356,20 @@ test_expect_success 'override global and system config' '
2356 local local.config=true
2357 EOF
2358 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=custom-system-config GIT_CONFIG_GLOBAL=custom-global-config \
2341 - git config --show-scope --list >output &&
2359 + git config ${mode_prefix}list --show-scope >output &&
2360 test_cmp expect output &&
2361
2362 cat >expect <<-EOF &&
2363 local local.config=true
2364 EOF
2365 GIT_CONFIG_NOSYSTEM=false GIT_CONFIG_SYSTEM=/dev/null GIT_CONFIG_GLOBAL=/dev/null \
2348 - git config --show-scope --list >output &&
2366 + git config ${mode_prefix}list --show-scope >output &&
2367 test_cmp expect output
2368 '
2369
2370 test_expect_success 'override global and system config with missing file' '
2353 - test_must_fail env GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=/dev/null git config --global --list &&
2354 - test_must_fail env GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=does-not-exist git config --system --list &&
2371 + test_must_fail env GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=/dev/null git config ${mode_prefix}list --global &&
2372 + test_must_fail env GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=does-not-exist git config ${mode_prefix}list --system &&
2373 GIT_CONFIG_GLOBAL=does-not-exist GIT_CONFIG_SYSTEM=does-not-exist git version
2374 '
2375
@@ -2478,7 +2496,7 @@ test_expect_success 'set all config with value-pattern' '
2496 # no match => add new entry
2497 cp initial config &&
2498 git config --file=config abc.key two a+ &&
2481 - git config --file=config --list >actual &&
2499 + git config ${mode_prefix}list --file=config >actual &&
2500 cat >expect <<-\EOF &&
2501 abc.key=one
2502 abc.key=two
@@ -2491,7 +2509,7 @@ test_expect_success 'set all config with value-pattern' '
2509
2510 # multiple values, no match => add
2511 git config --file=config abc.key three a+ &&
2494 - git config --file=config --list >actual &&
2512 + git config ${mode_prefix}list --file=config >actual &&
2513 cat >expect <<-\EOF &&
2514 abc.key=one
2515 abc.key=two
@@ -2501,7 +2519,7 @@ test_expect_success 'set all config with value-pattern' '
2519
2520 # single match => replace
2521 git config --file=config abc.key four h+ &&
2504 - git config --file=config --list >actual &&
2522 + git config ${mode_prefix}list --file=config >actual &&
2523 cat >expect <<-\EOF &&
2524 abc.key=one
2525 abc.key=two
@@ -2516,7 +2534,7 @@ test_expect_success '--replace-all and value-pattern' '
2534 git config --file=config --add abc.key two &&
2535 git config --file=config --add abc.key three &&
2536 git config --file=config --replace-all abc.key four "o+" &&
2519 - git config --file=config --list >actual &&
2537 + git config ${mode_prefix}list --file=config >actual &&
2538 cat >expect <<-\EOF &&
2539 abc.key=four
2540 abc.key=three
@@ -2534,7 +2552,7 @@ test_expect_success 'refuse --fixed-value for incompatible actions' '
2552 test_must_fail git config --file=config --fixed-value --get-urlmatch dev.null bogus &&
2553 test_must_fail git config --file=config --fixed-value --rename-section dev null &&
2554 test_must_fail git config --file=config --fixed-value --remove-section dev &&
2537 - test_must_fail git config --file=config --fixed-value --list &&
2555 + test_must_fail git config ${mode_prefix}list --file=config --fixed-value &&
2556 test_must_fail git config --file=config --fixed-value --get-color dev.null &&
2557 test_must_fail git config --file=config --fixed-value --get-colorbool dev.null &&
2558
@@ -2555,7 +2573,7 @@ test_expect_success '--fixed-value uses exact string matching' '
2573
2574 cp initial config &&
2575 git config --file=config fixed.test bogus "$META" &&
2558 - git config --file=config --list >actual &&
2576 + git config ${mode_prefix}list --file=config >actual &&
2577 cat >expect <<-EOF &&
2578 fixed.test=$META
2579 fixed.test=bogus
@@ -2564,7 +2582,7 @@ test_expect_success '--fixed-value uses exact string matching' '
2582
2583 cp initial config &&
2584 git config --file=config --fixed-value fixed.test bogus "$META" &&
2567 - git config --file=config --list >actual &&
2585 + git config ${mode_prefix}list --file=config >actual &&
2586 cat >expect <<-\EOF &&
2587 fixed.test=bogus
2588 EOF
@@ -2582,7 +2600,7 @@ test_expect_success '--fixed-value uses exact string matching' '
2600
2601 cp initial config &&
2602 git config --file=config --replace-all fixed.test bogus "$META" &&
2585 - git config --file=config --list >actual &&
2603 + git config ${mode_prefix}list --file=config >actual &&
2604 cat >expect <<-EOF &&
2605 fixed.test=$META
2606 fixed.test=bogus
@@ -2590,7 +2608,7 @@ test_expect_success '--fixed-value uses exact string matching' '
2608 test_cmp expect actual &&
2609
2610 git config --file=config --fixed-value --replace-all fixed.test bogus "$META" &&
2593 - git config --file=config --list >actual &&
2611 + git config ${mode_prefix}list --file=config >actual &&
2612 cat >expect <<-EOF &&
2613 fixed.test=bogus
2614 fixed.test=bogus
@@ -2751,4 +2769,6 @@ test_expect_success 'specifying multiple modes causes failure' '
2769 test_cmp expect err
2770 '
2771
2772 +done
2773 +
2774 test_done