From: Patrick Steinhardt <ps@pks.im>
To: git@vger.kernel.org
Cc: "Kristoffer Haugsbakk" <code@khaugsbakk.name>,
"Taylor Blau" <me@ttaylorr.com>,
"Jean-Noël AVILA" <jn.avila@free.fr>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Junio C Hamano" <gitster@pobox.com>
Subject: [PATCH v3 00/13] builtin/config: introduce subcommands
Date: Wed, 27 Mar 2024 09:46:09 +0100 [thread overview]
Message-ID: <cover.1711527811.git.ps@pks.im> (raw)
In-Reply-To: <cover.1709724089.git.ps@pks.im>
[-- Attachment #1: Type: text/plain, Size: 10430 bytes --]
Hi,
this is the third version of my patch series that aims to add
subcommands to git-config(1) in a backwards-compatible manner.
There's only been a few changes compared to v2 based on Eric's comments:
- Touched up a commit message to explain why I had to add cleanups
to tests.
- Reformulate "implicit modes" in a comment to clarify that this
refers to the legacy-style modes.
- Reformulated documentation of the "get" subcommand.
- Use `BUG` instead of `echo >&2 && exit 1`.
- Removed duplicate example in the documentation.
- Fixed conflicts with 86f9ce7dd6 (docs: fix typo in git-config
`--default`, 2024-03-16) and 7823a51203 (docs: clarify file
options in git-config `--edit`, 2024-03-16) by rebasing onto
latest `master`.
Thanks!
Patrick
Patrick Steinhardt (13):
builtin/config: move option array around
builtin/config: move "fixed-value" option to correct group
builtin/config: use `OPT_CMDMODE()` to specify modes
builtin/config: pull out function to handle config location
builtin/config: pull out function to handle `--null`
builtin/config: introduce "list" subcommand
builtin/config: introduce "get" subcommand
builtin/config: introduce "set" subcommand
builtin/config: introduce "unset" subcommand
builtin/config: introduce "rename-section" subcommand
builtin/config: introduce "remove-section" subcommand
builtin/config: introduce "edit" subcommand
builtin/config: display subcommand help
Documentation/git-config.txt | 219 +++++++++-------
builtin/config.c | 496 ++++++++++++++++++++++++++++-------
t/t0450/txt-help-mismatches | 1 -
t/t1300-config.sh | 416 ++++++++++++++++++-----------
4 files changed, 785 insertions(+), 347 deletions(-)
Range-diff against v2:
1: 1f21e7fa0d = 1: bfcb50e393 builtin/config: move option array around
2: 54e536394a = 2: ff428d8a22 builtin/config: move "fixed-value" option to correct group
3: 49d190ac24 = 3: e049c05713 builtin/config: use `OPT_CMDMODE()` to specify modes
4: 80093f3908 = 4: 41585803bf builtin/config: pull out function to handle config location
5: 283a199578 = 5: 95f661f267 builtin/config: pull out function to handle `--null`
6: 53401299fa ! 6: b50f32d074 builtin/config: introduce "list" subcommand
@@ Commit message
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>
@@ Documentation/git-config.txt: Valid `<type>`'s include:
--show-origin::
@@ Documentation/git-config.txt: Valid `<type>`'s include:
When using `--get`, and the requested variable is not found, behave as if
- <value> were the value assigned to the that variable.
+ <value> were the value assigned to that variable.
+DEPRECATED MODES
+----------------
@@ builtin/config.c: int cmd_config(int argc, const char **argv, const char *prefix
+ * has been specified. If so, we re-parse it a second time, but this
+ * time we drop KEEP_ARGV0. This is so that we don't munge the command
+ * line in case no subcommand was given, which would otherwise confuse
-+ * us when parsing the implicit modes.
++ * us when parsing the legacy-style modes that don't use subcommands.
+ */
+ argc = parse_options(argc, argv, prefix, builtin_subcommand_options, builtin_config_usage,
+ PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_NO_INTERNAL_HELP|PARSE_OPT_KEEP_ARGV0|PARSE_OPT_KEEP_UNKNOWN_OPT);
@@ t/t1300-config.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+ mode_prefix=""
+ ;;
+*)
-+ echo "unknown mode $mode" >&2
-+ exit 1;;
++ BUG "unknown mode $mode";;
+esac
+
test_expect_success 'clear default config' '
7: 8ceced0fc5 ! 7: eee1fae50c builtin/config: introduce "get" subcommand
@@ Documentation/git-config.txt: COMMANDS
List all variables set in config file, along with their values.
+get::
-+ Get value for one or more config options. Values can be filtered by
-+ regexes and URLs.Returns error code 1 if the key was not found and the
-+ last value if multiple key values were found. If `--all` is set, then
-+ all values will be shown.
++ Emits the value of the specified key. If key is present multiple times
++ in the configuration, emits the last value. If `--all` is specified,
++ emits all values associated with key. Returns error code 1 if key is
++ not present.
+
[[OPTIONS]]
OPTIONS
@@ Documentation/git-config.txt: OPTIONS
---get-all::
- Like get, but returns all values for a multi-valued key.
+--all::
-+ With "get", Return all values for a multi-valued key.
++ With `get`, Return all values for a multi-valued key.
---get-regexp::
- Like --get-all, but interprets the name as a regular expression and
@@ Documentation/git-config.txt: OPTIONS
- in which section and variable names are lowercased, but subsection
- names are not.
+---regexp::
-+ With "get", interpret the name as a regular expression. Regular
++ With `get`, interpret the name as a regular expression. Regular
+ expression matching is currently case-sensitive and done against a
+ canonicalized version of the key in which section and variable names
+ are lowercased, but subsection names are not.
@@ Documentation/git-config.txt: Valid `<type>`'s include:
--default <value>::
- When using `--get`, and the requested variable is not found, behave as if
+ When using `get`, and the requested variable is not found, behave as if
- <value> were the value assigned to the that variable.
+ <value> were the value assigned to that variable.
DEPRECATED MODES
@@ Documentation/git-config.txt: DEPRECATED MODES
@@ Documentation/git-config.txt: you have to provide a regex matching the value of
------------
-% git config --get core.filemode
-+% git config get core.filemode
- ------------
-
- or
-
- ------------
+-------------
+-
+-or
+-
+-------------
-% git config core.filemode
+% git config get core.filemode
------------
@@ t/t1300-config.sh: do
+ mode_get_regexp="get --regexp --all --show-names"
;;
*)
- echo "unknown mode $mode" >&2
+ BUG "unknown mode $mode";;
@@ t/t1300-config.sh: test_expect_success 'multi-valued get-all returns all' '
wow
wow2 for me
8: aa5c9743ad ! 8: e2815affab builtin/config: introduce "set" subcommand
@@ Documentation/git-config.txt: You can query/set/replace/unset options with this
lines, a `value-pattern` (which is an extended regular expression,
unless the `--fixed-value` option is given) needs to be given. Only the
@@ Documentation/git-config.txt: get::
- last value if multiple key values were found. If `--all` is set, then
- all values will be shown.
+ emits all values associated with key. Returns error code 1 if key is
+ not present.
+set::
+ Set value for one or more config options. By default, this command
@@ Documentation/git-config.txt: OPTIONS
+ values. This is the same as providing '--value=^$' in `set`.
--all::
- With "get", Return all values for a multi-valued key.
+ With `get`, Return all values for a multi-valued key.
@@ Documentation/git-config.txt: recommended to migrate to the new syntax.
'git config <name>'::
Replaced by `git config get <name>`.
@@ t/t1300-config.sh: legacy)
+ mode_replace_all="set --all"
;;
*)
- echo "unknown mode $mode" >&2
+ BUG "unknown mode $mode";;
@@ t/t1300-config.sh: cat > expect << EOF
penguin = little blue
EOF
9: c8a44b6189 ! 9: 90f055ae1d builtin/config: introduce "unset" subcommand
@@ t/t1300-config.sh: subcommands)
+ mode_unset_all="unset --all"
;;
*)
- echo "unknown mode $mode" >&2
+ BUG "unknown mode $mode";;
@@ t/t1300-config.sh: foo = bar
EOF
10: a3c66431b0 = 10: 3e360b1f47 builtin/config: introduce "rename-section" subcommand
11: 6314d51cec = 11: d610b5fda1 builtin/config: introduce "remove-section" subcommand
12: 12011714e3 ! 12: 4a6512c88a builtin/config: introduce "edit" subcommand
@@ Documentation/git-config.txt: rename-section::
+edit::
+ Opens an editor to modify the specified config file; either
-+ `--system`, `--global`, or repository (default).
++ `--system`, `--global`, `--local` (default), `--worktree`, or
++ `--file <config-file>`.
+
[[OPTIONS]]
OPTIONS
@@ Documentation/git-config.txt: Valid `<type>`'s include:
--e::
---edit::
- Opens an editor to modify the specified config file; either
-- `--system`, `--global`, or repository (default).
+- `--system`, `--global`, `--local` (default), `--worktree`, or
+- `--file <config-file>`.
-
--[no-]includes::
Respect `include.*` directives in config files when looking up
13: 2046f6652a ! 13: 657d1355b5 builtin/config: display subcommand help
@@ builtin/config.c: static const char *const builtin_config_usage[] = {
};
@@ builtin/config.c: int cmd_config(int argc, const char **argv, const char *prefix)
- * us when parsing the implicit modes.
+ * us when parsing the legacy-style modes that don't use subcommands.
*/
argc = parse_options(argc, argv, prefix, builtin_subcommand_options, builtin_config_usage,
- PARSE_OPT_SUBCOMMAND_OPTIONAL|PARSE_OPT_NO_INTERNAL_HELP|PARSE_OPT_KEEP_ARGV0|PARSE_OPT_KEEP_UNKNOWN_OPT);
base-commit: c75fd8d8150afdf836b63a8e0534d9b9e3e111ba
--
2.44.GIT
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-03-27 8:46 UTC|newest]
Thread overview: 116+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-06 11:31 [PATCH 0/8] builtin/config: introduce subcommands Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 1/8] builtin/config: move option array around Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 2/8] builtin/config: move "fixed-value" option to correct group Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 3/8] builtin/config: use `OPT_CMDMODE()` to specify modes Patrick Steinhardt
2024-03-06 23:52 ` Taylor Blau
2024-03-07 7:02 ` Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 4/8] builtin/config: move modes into separate functions Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 5/8] builtin/config: track subcommands by action Patrick Steinhardt
2024-03-06 21:54 ` Jean-Noël AVILA
2024-03-07 6:37 ` Patrick Steinhardt
2024-03-07 0:10 ` Taylor Blau
2024-03-07 6:36 ` Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 6/8] builtin/config: introduce subcommands Patrick Steinhardt
2024-03-06 21:38 ` Karthik Nayak
2024-03-07 7:14 ` Patrick Steinhardt
2024-03-06 11:31 ` [PATCH 7/8] t1300: exercise both old- and new-style modes Patrick Steinhardt
2024-03-06 11:32 ` [PATCH 8/8] Documentation/git-config: update to new-style syntax Patrick Steinhardt
2024-03-07 6:57 ` Eric Sunshine
2024-03-07 7:33 ` Patrick Steinhardt
2024-03-06 17:06 ` [PATCH 0/8] builtin/config: introduce subcommands Junio C Hamano
2024-03-06 23:46 ` Taylor Blau
2024-03-06 23:52 ` Junio C Hamano
2024-03-07 0:13 ` Taylor Blau
2024-03-07 0:31 ` Dragan Simic
2024-03-07 6:31 ` Patrick Steinhardt
2024-03-07 13:22 ` Junio C Hamano
2024-03-06 22:49 ` Kristoffer Haugsbakk
2024-03-11 23:19 ` [PATCH v2 00/13] " Patrick Steinhardt
2024-03-11 23:19 ` [PATCH v2 01/13] builtin/config: move option array around Patrick Steinhardt
2024-03-11 23:19 ` [PATCH v2 02/13] builtin/config: move "fixed-value" option to correct group Patrick Steinhardt
2024-03-11 23:20 ` [PATCH v2 03/13] builtin/config: use `OPT_CMDMODE()` to specify modes Patrick Steinhardt
2024-03-11 23:20 ` [PATCH v2 04/13] builtin/config: pull out function to handle config location Patrick Steinhardt
2024-03-11 23:20 ` [PATCH v2 05/13] builtin/config: pull out function to handle `--null` Patrick Steinhardt
2024-03-11 23:20 ` [PATCH v2 06/13] builtin/config: introduce "list" subcommand Patrick Steinhardt
2024-03-13 2:45 ` Eric Sunshine
2024-03-27 8:42 ` Patrick Steinhardt
2024-03-11 23:20 ` [PATCH v2 07/13] builtin/config: introduce "get" subcommand Patrick Steinhardt
2024-03-13 3:11 ` Eric Sunshine
2024-03-27 8:42 ` Patrick Steinhardt
2024-03-11 23:20 ` [PATCH v2 08/13] builtin/config: introduce "set" subcommand Patrick Steinhardt
2024-03-11 23:21 ` [PATCH v2 09/13] builtin/config: introduce "unset" subcommand Patrick Steinhardt
2024-03-11 23:21 ` [PATCH v2 10/13] builtin/config: introduce "rename-section" subcommand Patrick Steinhardt
2024-03-11 23:21 ` [PATCH v2 11/13] builtin/config: introduce "remove-section" subcommand Patrick Steinhardt
2024-03-11 23:21 ` [PATCH v2 12/13] builtin/config: introduce "edit" subcommand Patrick Steinhardt
2024-03-11 23:21 ` [PATCH v2 13/13] builtin/config: display subcommand help Patrick Steinhardt
2024-03-27 8:46 ` Patrick Steinhardt [this message]
2024-03-27 8:46 ` [PATCH v3 01/13] builtin/config: move option array around Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 02/13] builtin/config: move "fixed-value" option to correct group Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 03/13] builtin/config: use `OPT_CMDMODE()` to specify modes Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 04/13] builtin/config: pull out function to handle config location Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 05/13] builtin/config: pull out function to handle `--null` Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 06/13] builtin/config: introduce "list" subcommand Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 07/13] builtin/config: introduce "get" subcommand Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 08/13] builtin/config: introduce "set" subcommand Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 09/13] builtin/config: introduce "unset" subcommand Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 10/13] builtin/config: introduce "rename-section" subcommand Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 11/13] builtin/config: introduce "remove-section" subcommand Patrick Steinhardt
2024-03-27 8:46 ` [PATCH v3 12/13] builtin/config: introduce "edit" subcommand Patrick Steinhardt
2024-03-27 8:47 ` [PATCH v3 13/13] builtin/config: display subcommand help Patrick Steinhardt
2024-03-27 8:53 ` [PATCH v3 00/13] builtin/config: introduce subcommands Eric Sunshine
2024-03-27 9:16 ` Patrick Steinhardt
2024-05-03 9:56 ` [PATCH v4 00/14] " Patrick Steinhardt
2024-05-03 9:56 ` [PATCH v4 01/14] config: clarify memory ownership when preparing comment strings Patrick Steinhardt
2024-05-03 10:13 ` Kristoffer Haugsbakk
2024-05-03 9:56 ` [PATCH v4 02/14] builtin/config: move option array around Patrick Steinhardt
2024-05-03 9:56 ` [PATCH v4 03/14] builtin/config: move "fixed-value" option to correct group Patrick Steinhardt
2024-05-03 12:28 ` Karthik Nayak
2024-05-06 9:34 ` Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 04/14] builtin/config: use `OPT_CMDMODE()` to specify modes Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 05/14] builtin/config: pull out function to handle config location Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 06/14] builtin/config: pull out function to handle `--null` Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 07/14] builtin/config: introduce "list" subcommand Patrick Steinhardt
2024-05-03 13:08 ` Karthik Nayak
2024-05-03 13:13 ` rsbecker
2024-05-03 16:01 ` Junio C Hamano
2024-05-06 7:51 ` Patrick Steinhardt
2024-05-06 17:13 ` Junio C Hamano
2024-05-06 18:33 ` rsbecker
2024-05-06 18:45 ` Dragan Simic
2024-05-07 6:20 ` Kristoffer Haugsbakk
2024-05-06 21:33 ` Git 3.0? Junio C Hamano
2024-05-07 4:18 ` Patrick Steinhardt
2024-05-07 4:02 ` [PATCH v4 07/14] builtin/config: introduce "list" subcommand Patrick Steinhardt
2024-05-06 7:58 ` Patrick Steinhardt
2024-05-06 11:26 ` Karthik Nayak
2024-05-03 9:57 ` [PATCH v4 08/14] builtin/config: introduce "get" subcommand Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 09/14] builtin/config: introduce "set" subcommand Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 10/14] builtin/config: introduce "unset" subcommand Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 11/14] builtin/config: introduce "rename-section" subcommand Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 12/14] builtin/config: introduce "remove-section" subcommand Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 13/14] builtin/config: introduce "edit" subcommand Patrick Steinhardt
2024-05-03 9:57 ` [PATCH v4 14/14] builtin/config: display subcommand help Patrick Steinhardt
2024-05-03 13:36 ` [PATCH v4 00/14] builtin/config: introduce subcommands Dragan Simic
2024-05-03 16:09 ` Junio C Hamano
2024-05-06 8:55 ` [PATCH v5 " Patrick Steinhardt
2024-05-06 8:55 ` [PATCH v5 01/14] config: clarify memory ownership when preparing comment strings Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 02/14] builtin/config: move option array around Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 03/14] builtin/config: move "fixed-value" option to correct group Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 04/14] builtin/config: use `OPT_CMDMODE()` to specify modes Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 05/14] builtin/config: pull out function to handle config location Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 06/14] builtin/config: pull out function to handle `--null` Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 07/14] builtin/config: introduce "list" subcommand Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 08/14] builtin/config: introduce "get" subcommand Patrick Steinhardt
2025-08-03 18:19 ` SZEDER Gábor
2025-08-03 22:30 ` Junio C Hamano
2025-09-11 11:05 ` Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 09/14] builtin/config: introduce "set" subcommand Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 10/14] builtin/config: introduce "unset" subcommand Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 11/14] builtin/config: introduce "rename-section" subcommand Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 12/14] builtin/config: introduce "remove-section" subcommand Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 13/14] builtin/config: introduce "edit" subcommand Patrick Steinhardt
2024-05-06 8:56 ` [PATCH v5 14/14] builtin/config: display subcommand help Patrick Steinhardt
2024-05-06 11:30 ` [PATCH v5 00/14] builtin/config: introduce subcommands Karthik Nayak
2024-05-06 20:21 ` Taylor Blau
2024-05-06 20:38 ` rsbecker
2024-05-07 4:07 ` Patrick Steinhardt
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1711527811.git.ps@pks.im \
--to=ps@pks.im \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jn.avila@free.fr \
--cc=me@ttaylorr.com \
--cc=sunshine@sunshineco.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.