[PATCH 0/8] builtin/config: introduce subcommands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

the UI of git-config(1) is quite arcane and does not really conform to
the more modern UIs that we have nowadays in Git:

  - While it does have modes, those modes come in the form of switches.
    E.g. you have to say git config --get-all to execute the "get-all"
    mode.

  - Its interface depends on the number of args. Given one arg it will
    print the value of the corresponding config key, given two args it
    will set that key. Did you know you can even give it three args? I
    didn't. Now guess what this mode does.

This patch series overhauls git-config(1) by introducing subcommands.
This results in the following UI that matches more closely what we have
in other Git commands which are more modern:

  - `git config foo.bar` -> `git config get foo.bar`

  - `git config foo.bar value` -> `git config set foo.bar value`

  - `git config foo.bar value value-pattern` -> `git config set-all
    foo.bar value value-pattern`

  - `git config --get-urlmatch` -> `git config get-urlmatch`.

Most importantly, this should help discoverability quite a lot by now
also having a proper synopsis in both the manpage, but also in `git
config -h`.

Of course, backwards compatibility is a big concern. We don't want to
just switch over to the new syntax and break all existing scripts and
muscle memory. This patch series thus abuses the fact that the implicit
modes (`git config foo.bar`, `git config foo.bar value` and `git config
foo.bar value value-pattern`) all require a key as first argument. As
keys _must_ have a dot, this allows us to unambiguously discern those
from actual subcommands.

Thus, git-config(1) now supports both old and new style arguments in a
completely backwards compatible way, which is also demonstrated by the
adapted tests. Eventually, I think we should consider dropping the old
style syntax with e.g. Git v3.0.

We could of course iterate further from here and keep on improving the
UI of the new subcommands, e.g. by merging closely related subcommands.
But for the time being I think it's easier to stop at this point and
revisit the result at a later point in time.

Also, note that I see this as kind of an experiment for how to modernize
our UI slowly over time so that things become more consistent and thus
hopefully easier to use in the long term.

Patrick

Patrick Steinhardt (8):
  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: move modes into separate functions
  builtin/config: track subcommands by action
  builtin/config: introduce subcommands
  t1300: exercise both old- and new-style modes
  Documentation/git-config: update to new-style syntax

 Documentation/git-config.txt | 204 +++++-----
 builtin/config.c             | 671 +++++++++++++++++++-------------
 t/t0450/txt-help-mismatches  |   1 -
 t/t1300-config.sh            | 734 ++++++++++++++++++-----------------
 4 files changed, 900 insertions(+), 710 deletions(-)

-- 
2.44.0

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux