cat-file: report an error on multiple --batch options
authorJeff King <peff@peff.net>
Mon, 5 Nov 2018 06:43:44 +0000 (01:43 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Nov 2018 03:55:36 +0000 (12:55 +0900)
The options callback for --batch and --batch-check detects when the two
mutually incompatible options are used. But it simply returns an error
code to parse-options, meaning the program will quit without any kind of
message to the user.

Instead, let's use error() to print something and return -1. Note that
this flips the error return from 1 to -1, but negative values are more
idiomatic here (and parse-options treats them the same).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c
index 4a5289079c59e8166d580413e70f24241a123e74..0f6b692df6bfc5704fd853e7d5ee6222a352d71e 100644 (file)
@@ -596,7 +596,7 @@ static int batch_option_callback(const struct option *opt,
        struct batch_options *bo = opt->value;
 
        if (bo->enabled) {
-               return 1;
+               return error(_("only one batch option may be specified"));
        }
 
        bo->enabled = 1;