From ccfcaf399ffcc91553395a8de8e833e7685e7cc2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 28 Sep 2025 17:29:16 -0400 Subject: parseopt: values of pathname type can be prefixed with :(optional) In the previous step, we introduced an optional filename that can be given to a configuration variable, and nullify the fact that such a configuration setting even existed if the named path is missing or empty. Let's do the same for command line options that name a pathname. Signed-off-by: Junio C Hamano Signed-off-by: Taylor Blau Signed-off-by: D. Ben Knoble Signed-off-by: Junio C Hamano --- Documentation/gitcli.adoc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Documentation') diff --git a/Documentation/gitcli.adoc b/Documentation/gitcli.adoc index 1ea681b59d..ef2a0a399d 100644 --- a/Documentation/gitcli.adoc +++ b/Documentation/gitcli.adoc @@ -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 ------------------------------------ -- cgit v1.2.3