[PATCH 1/4] OPT__QUIET(): switch from count-up to true bool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

    builtin/branch.c:

	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.

    builtin/check-ignore.c:

	all users of quiet use it as a bool.

    builtin/checkout-index.c:

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

    builtin/checkout.c:

	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
	  places;

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

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

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 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 }, \
-- 
1.8.4-rc1-210-gf6d87e2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]