summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b408457)
raw | patch | inline | side by side (parent: b408457)
author | Felipe Contreras <felipe.contreras@gmail.com> | |
Sat, 21 Feb 2009 00:48:57 +0000 (02:48 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 22 Feb 2009 04:37:19 +0000 (20:37 -0800) |
In preparation for parseopt.
Also remove some unecessary comments since the usage is described in the
documentation.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Also remove some unecessary comments since the usage is described in the
documentation.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-config.c | patch | blob | history |
diff --git a/builtin-config.c b/builtin-config.c
index 5074c6123ecee476460a34198d19ca4de676b349..a2ef5f7c084515f3ed6bfabb86faa862ef5cfd75 100644 (file)
--- a/builtin-config.c
+++ b/builtin-config.c
return 0;
}
-static int get_color(int argc, const char **argv)
+static void get_color(const char *def_color)
{
- /*
- * grab the color setting for the given slot from the configuration,
- * or parse the default value if missing, and return ANSI color
- * escape sequence.
- *
- * e.g.
- * git config --get-color color.diff.whitespace "blue reverse"
- */
- const char *def_color = NULL;
-
- switch (argc) {
- default:
- usage(git_config_set_usage);
- case 2:
- def_color = argv[1];
- /* fallthru */
- case 1:
- get_color_slot = argv[0];
- break;
- }
-
get_color_found = 0;
parsed_color[0] = '\0';
git_config(git_get_color_config, NULL);
color_parse(def_color, "command line", parsed_color);
fputs(parsed_color, stdout);
- return 0;
}
static int stdout_is_tty;
return 0;
}
-static int get_colorbool(int argc, const char **argv)
+static int get_colorbool(int print)
{
- /*
- * git config --get-colorbool <slot> [<stdout-is-tty>]
- *
- * returns "true" or "false" depending on how <slot>
- * is configured.
- */
-
- if (argc == 2)
- stdout_is_tty = git_config_bool("command line", argv[1]);
- else if (argc == 1)
- stdout_is_tty = isatty(1);
- else
- usage(git_config_set_usage);
get_colorbool_found = -1;
get_diff_color_found = -1;
- get_colorbool_slot = argv[0];
git_config(git_get_colorbool_config, NULL);
if (get_colorbool_found < 0) {
get_colorbool_found = git_use_color_default;
}
- if (argc == 1) {
- return get_colorbool_found ? 0 : 1;
- } else {
+ if (print) {
printf("%s\n", get_colorbool_found ? "true" : "false");
return 0;
- }
+ } else
+ return get_colorbool_found ? 0 : 1;
}
int cmd_config(int argc, const char **argv, const char *unused_prefix)
}
return 0;
} else if (!strcmp(argv[1], "--get-color")) {
- return get_color(argc-2, argv+2);
+ if (argc > 4 || argc < 3)
+ usage(git_config_set_usage);
+ get_color_slot = argv[2];
+ get_color(argv[3]);
+ return 0;
} else if (!strcmp(argv[1], "--get-colorbool")) {
- return get_colorbool(argc-2, argv+2);
+ if (argc == 4)
+ stdout_is_tty = git_config_bool("command line", argv[3]);
+ else if (argc == 3)
+ stdout_is_tty = isatty(1);
+ else
+ usage(git_config_set_usage);
+ get_colorbool_slot = argv[2];
+ return get_colorbool(argc != 3);
} else if (!strcmp(argv[1], "--edit") || !strcmp(argv[1], "-e")) {
if (argc != 2)
usage(git_config_set_usage);