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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Felipe Contreras
Date: Tuesday, February 17, 2009 - 6:52 am

From: Junio C Hamano <gitster@pobox.com>

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

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v3 01/10] config: Codestyle cleanups., Felipe Contreras, (Tue Feb 17, 6:52 am)
[PATCH v3 02/10] config: Cleanup editor action., Felipe Contreras, (Tue Feb 17, 6:52 am)
[PATCH v3 03/10] config: Make git_config() more flexible., Felipe Contreras, (Tue Feb 17, 6:52 am)
[PATCH v3 05/10] config: Reorganize get_color*., Felipe Contreras, (Tue Feb 17, 6:52 am)
[PATCH v3 06/10] config: Use parseopt., Felipe Contreras, (Tue Feb 17, 6:52 am)
[PATCH v3 07/10] config: Disallow --getcolor* and other ac ..., Felipe Contreras, (Tue Feb 17, 6:52 am)
[PATCH v3 09/10] config: Disallow multiple variable types., Felipe Contreras, (Tue Feb 17, 6:52 am)
Re: [PATCH v3 01/10] config: Codestyle cleanups., Sverre Rabbelier, (Tue Feb 17, 9:33 am)
Re: [PATCH v3 01/10] config: Codestyle cleanups., Felipe Contreras, (Wed Feb 18, 2:18 am)
Re: [PATCH v3 03/10] config: Make git_config() more flexible, Felipe Contreras, (Wed Feb 18, 2:30 pm)