Thread (13 messages) flat view 13 messages, 3 authors, 2016-06-15
STALE3730d

[PATCH v3 07/10] config: Disallow --getcolor* and other actions.

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:46:13
Subsystem: the rest · Maintainer: Linus Torvalds

From: Junio C Hamano <redacted>

So that --get and --get-colorbool are diagnosed as errors.

Signed-off-by: Felipe Contreras <redacted>
---
 builtin-config.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/builtin-config.c b/builtin-config.c
index 45b4a9f..8ee0cd9 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -40,6 +40,8 @@ static int end_null;
 #define ACTION_EDIT (1<<10)
 #define ACTION_SET (1<<11)
 #define ACTION_SET_ALL (1<<12)
+#define ACTION_GET_COLOR (1<<13)
+#define ACTION_GET_COLORBOOL (1<<14)
 
 static struct option builtin_config_options[] = {
 	OPT_GROUP("Config file location"),
@@ -339,6 +341,11 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
 		key_delim = '\n';
 	}
 
+	if (get_color_slot)
+	    actions |= ACTION_GET_COLOR;
+	if (get_colorbool_slot)
+	    actions |= ACTION_GET_COLORBOOL;
+
 	if (HAS_MULTI_BITS(actions)) {
 		error("only one action at a time.");
 		usage_with_options(builtin_config_usage, builtin_config_options);
@@ -432,10 +439,10 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)
 		if (ret == 0)
 			die("No such section!");
 	}
-	else if (get_color_slot) {
+	else if (actions == ACTION_GET_COLOR) {
 		get_color(argv[0]);
 	}
-	else if (get_colorbool_slot) {
+	else if (actions == ACTION_GET_COLORBOOL) {
 		if (argc == 1)
 			stdout_is_tty = git_config_bool("command line", argv[0]);
 		else if (argc == 0)
-- 
1.6.1.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help