The parseopt parsing for OPT__QUIET() is implemented in terms of
OPT_BOOLEAN aka OPT_COUNTUP, so a user _could_ theoretically have
used it to make "git cmd -q -q" and "git cmd -q" behave differently.

However, no existing user does so (a summary of the audit at the
end).  Use OPT_BOOL to make sure our choices are either 0 or 1.


        quiet is passed to create_branch() in branch.c and
        delete_branches().  The former passes it to setup_tracking()
        which is used as a bool to decide use of BRANCH_CONFIG_VERBOSE.
        The latter uses it as a bool to give a single printf() for
        reporting the names of deleted branches.


        all users of quiet use it as a bool.


        quiet is assigned to state.quite and only the latter is used
        throughout the program.  It is a single-bit bitfield.


        quiet is stored in checkout_opts.quiet which is of type int.  It
        is used in many places:

        - reset_tree() uses it as a bool;

        - merge_working_tree() uses it twice, as a bool at both

        - update_refs_for_switch() uses it three times, all as a bool.
          It also passes it to create_branch() which we already verified

        - switch_branches() and switch_unborn_to_new_branch() use it
          once each, as a bool at both places.

Signed-off-by: Junio C Hamano <>
 parse-options.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse-options.h b/parse-options.h
index c378b75..f2b01ee 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -231,7 +231,7 @@ extern int parse_opt_string_list(const struct option *, 
const char *, int);
 extern int parse_opt_noop_cb(const struct option *, const char *, int);
 #define OPT__VERBOSE(var, h)  OPT_BOOLEAN('v', "verbose", (var), (h))
-#define OPT__QUIET(var, h)    OPT_BOOLEAN('q', "quiet",   (var), (h))
+#define OPT__QUIET(var, h)    OPT_BOOL('q', "quiet",   (var), (h))
 #define OPT__VERBOSITY(var) \
        { OPTION_CALLBACK, 'v', "verbose", (var), NULL, N_("be more verbose"), \
          PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }, \

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to