]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/var.c
var: do not print usage() with a correct invocation
authorSean Allred <allred.sean@gmail.com>
Sat, 26 Nov 2022 14:17:56 +0000 (14:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 27 Nov 2022 00:35:55 +0000 (09:35 +0900)
commit26b8abc7b14754d32d994f87a45b303873565853
treec52bd0459cd2af00bde5787b3d68459bbf44de3e
parentc000d916380bb59db69c78546928eadd076b9c7d
var: do not print usage() with a correct invocation

Before, git-var could print usage() even if the command was invoked
correctly with a variable defined in git_vars -- provided that its
read() function returned NULL.

Now, we only print usage() only if it was called with a logical
variable that wasn't defined -- regardless of read().

Since we now know the variable is valid when we call read_var(), we
can avoid printing usage() here (and exiting with code 129) and
instead exit quietly with code 1. While exiting with a different code
can be a breaking change, it's far better than changing the exit
status more generally from 'failure' to 'success'.

Signed-off-by: Sean Allred <allred.sean@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-var.txt
builtin/var.c