Merge branch 'jc/optional-path'

Configuration variables that take a pathname as a value
(e.g. blame.ignorerevsfile) can be marked as optional by prefixing
":(optoinal)" before its value.

* jc/optional-path:
  parseopt: values of pathname type can be prefixed with :(optional)
  config: values of pathname type can be prefixed with :(optional)
  t7500: fix GIT_EDITOR shell snippet
  t7500: make each piece more independent
This commit is contained in:
Junio C Hamano
2025-10-14 12:56:09 -07:00
7 changed files with 95 additions and 25 deletions

View File

@@ -357,7 +357,9 @@ compiled without runtime prefix support, the compiled-in prefix will be
substituted instead. In the unlikely event that a literal path needs to
be specified that should _not_ be expanded, it needs to be prefixed by
`./`, like so: `./%(prefix)/bin`.
+
If prefixed with `:(optional)`, the configuration variable is treated
as if it does not exist, if the named path does not exist.
Variables
~~~~~~~~~

View File

@@ -216,6 +216,20 @@ $ git describe --abbrev=10 HEAD # correct
$ git describe --abbrev 10 HEAD # NOT WHAT YOU MEANT
----------------------------
Magic filename options
~~~~~~~~~~~~~~~~~~~~~~
Options that take a filename allow a prefix `:(optional)`. For example:
----------------------------
git commit -F :(optional)COMMIT_EDITMSG
# if COMMIT_EDITMSG does not exist, equivalent to
git commit
----------------------------
Like with configuration values, if the named file is missing Git behaves as if
the option was not given at all. See "Values" in linkgit:git-config[1].
NOTES ON FREQUENTLY CONFUSED OPTIONS
------------------------------------