5 #include "parse-options.h"
9 static const char *const builtin_config_usage[] = {
10 N_("git config [<options>]"),
15 static regex_t *key_regexp;
16 static regex_t *regexp;
18 static int omit_values;
19 static int use_key_regexp;
21 static int do_not_match;
22 static char delim = '=';
23 static char key_delim = ' ';
24 static char term = '\n';
26 static int use_global_config, use_system_config, use_local_config;
27 static struct git_config_source given_config_source;
28 static int actions, type;
29 static char *default_value;
31 static int respect_includes_opt = -1;
32 static struct config_options config_options;
33 static int show_origin;
35 #define ACTION_GET (1<<0)
36 #define ACTION_GET_ALL (1<<1)
37 #define ACTION_GET_REGEXP (1<<2)
38 #define ACTION_REPLACE_ALL (1<<3)
39 #define ACTION_ADD (1<<4)
40 #define ACTION_UNSET (1<<5)
41 #define ACTION_UNSET_ALL (1<<6)
42 #define ACTION_RENAME_SECTION (1<<7)
43 #define ACTION_REMOVE_SECTION (1<<8)
44 #define ACTION_LIST (1<<9)
45 #define ACTION_EDIT (1<<10)
46 #define ACTION_SET (1<<11)
47 #define ACTION_SET_ALL (1<<12)
48 #define ACTION_GET_COLOR (1<<13)
49 #define ACTION_GET_COLORBOOL (1<<14)
50 #define ACTION_GET_URLMATCH (1<<15)
53 * The actions "ACTION_LIST | ACTION_GET_*" which may produce more than
54 * one line of output and which should therefore be paged.
56 #define PAGING_ACTIONS (ACTION_LIST | ACTION_GET_ALL | \
57 ACTION_GET_REGEXP | ACTION_GET_URLMATCH)
61 #define TYPE_BOOL_OR_INT 3
63 #define TYPE_EXPIRY_DATE 5
66 #define OPT_CALLBACK_VALUE(s, l, v, h, i) \
67 { OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \
68 PARSE_OPT_NONEG, option_parse_type, (i) }
70 static struct option builtin_config_options[];
72 static int option_parse_type(const struct option *opt, const char *arg,
75 int new_type, *to_type;
78 *((int *) opt->value) = 0;
83 * To support '--<type>' style flags, begin with new_type equal to
86 new_type = opt->defval;
88 if (!strcmp(arg, "bool"))
90 else if (!strcmp(arg, "int"))
92 else if (!strcmp(arg, "bool-or-int"))
93 new_type = TYPE_BOOL_OR_INT;
94 else if (!strcmp(arg, "path"))
96 else if (!strcmp(arg, "expiry-date"))
97 new_type = TYPE_EXPIRY_DATE;
98 else if (!strcmp(arg, "color"))
99 new_type = TYPE_COLOR;
101 die(_("unrecognized --type argument, %s"), arg);
104 to_type = opt->value;
105 if (*to_type && *to_type != new_type) {
107 * Complain when there is a new type not equal to the old type.
108 * This allows for combinations like '--int --type=int' and
109 * '--type=int --type=int', but disallows ones like '--type=bool
110 * --int' and '--type=bool
113 error("only one type at a time.");
114 usage_with_options(builtin_config_usage,
115 builtin_config_options);
122 static struct option builtin_config_options[] = {
123 OPT_GROUP(N_("Config file location")),
124 OPT_BOOL(0, "global", &use_global_config, N_("use global config file")),
125 OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
126 OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
127 OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
128 OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
129 OPT_GROUP(N_("Action")),
130 OPT_BIT(0, "get", &actions, N_("get value: name [value-regex]"), ACTION_GET),
131 OPT_BIT(0, "get-all", &actions, N_("get all values: key [value-regex]"), ACTION_GET_ALL),
132 OPT_BIT(0, "get-regexp", &actions, N_("get values for regexp: name-regex [value-regex]"), ACTION_GET_REGEXP),
133 OPT_BIT(0, "get-urlmatch", &actions, N_("get value specific for the URL: section[.var] URL"), ACTION_GET_URLMATCH),
134 OPT_BIT(0, "replace-all", &actions, N_("replace all matching variables: name value [value_regex]"), ACTION_REPLACE_ALL),
135 OPT_BIT(0, "add", &actions, N_("add a new variable: name value"), ACTION_ADD),
136 OPT_BIT(0, "unset", &actions, N_("remove a variable: name [value-regex]"), ACTION_UNSET),
137 OPT_BIT(0, "unset-all", &actions, N_("remove all matches: name [value-regex]"), ACTION_UNSET_ALL),
138 OPT_BIT(0, "rename-section", &actions, N_("rename section: old-name new-name"), ACTION_RENAME_SECTION),
139 OPT_BIT(0, "remove-section", &actions, N_("remove a section: name"), ACTION_REMOVE_SECTION),
140 OPT_BIT('l', "list", &actions, N_("list all"), ACTION_LIST),
141 OPT_BIT('e', "edit", &actions, N_("open an editor"), ACTION_EDIT),
142 OPT_BIT(0, "get-color", &actions, N_("find the color configured: slot [default]"), ACTION_GET_COLOR),
143 OPT_BIT(0, "get-colorbool", &actions, N_("find the color setting: slot [stdout-is-tty]"), ACTION_GET_COLORBOOL),
144 OPT_GROUP(N_("Type")),
145 OPT_CALLBACK('t', "type", &type, "", N_("value is given this type"), option_parse_type),
146 OPT_CALLBACK_VALUE(0, "bool", &type, N_("value is \"true\" or \"false\""), TYPE_BOOL),
147 OPT_CALLBACK_VALUE(0, "int", &type, N_("value is decimal number"), TYPE_INT),
148 OPT_CALLBACK_VALUE(0, "bool-or-int", &type, N_("value is --bool or --int"), TYPE_BOOL_OR_INT),
149 OPT_CALLBACK_VALUE(0, "path", &type, N_("value is a path (file or directory name)"), TYPE_PATH),
150 OPT_CALLBACK_VALUE(0, "expiry-date", &type, N_("value is an expiry date"), TYPE_EXPIRY_DATE),
151 OPT_GROUP(N_("Other")),
152 OPT_BOOL('z', "null", &end_null, N_("terminate values with NUL byte")),
153 OPT_BOOL(0, "name-only", &omit_values, N_("show variable names only")),
154 OPT_BOOL(0, "includes", &respect_includes_opt, N_("respect include directives on lookup")),
155 OPT_BOOL(0, "show-origin", &show_origin, N_("show origin of config (file, standard input, blob, command line)")),
156 OPT_STRING(0, "default", &default_value, N_("value"), N_("with --get, use default value when missing entry")),
160 static void check_argc(int argc, int min, int max) {
161 if (argc >= min && argc <= max)
163 error("wrong number of arguments");
164 usage_with_options(builtin_config_usage, builtin_config_options);
167 static void show_config_origin(struct strbuf *buf)
169 const char term = end_null ? '\0' : '\t';
171 strbuf_addstr(buf, current_config_origin_type());
172 strbuf_addch(buf, ':');
174 strbuf_addstr(buf, current_config_name());
176 quote_c_style(current_config_name(), buf, NULL, 0);
177 strbuf_addch(buf, term);
180 static int show_all_config(const char *key_, const char *value_, void *cb)
183 struct strbuf buf = STRBUF_INIT;
184 show_config_origin(&buf);
185 /* Use fwrite as "buf" can contain \0's if "end_null" is set. */
186 fwrite(buf.buf, 1, buf.len, stdout);
187 strbuf_release(&buf);
189 if (!omit_values && value_)
190 printf("%s%c%s%c", key_, delim, value_, term);
192 printf("%s%c", key_, term);
197 struct strbuf *items;
202 static int format_config(struct strbuf *buf, const char *key_, const char *value_)
205 show_config_origin(buf);
207 strbuf_addstr(buf, key_);
210 strbuf_addch(buf, key_delim);
212 if (type == TYPE_INT)
213 strbuf_addf(buf, "%"PRId64,
214 git_config_int64(key_, value_ ? value_ : ""));
215 else if (type == TYPE_BOOL)
216 strbuf_addstr(buf, git_config_bool(key_, value_) ?
218 else if (type == TYPE_BOOL_OR_INT) {
220 v = git_config_bool_or_int(key_, value_, &is_bool);
222 strbuf_addstr(buf, v ? "true" : "false");
224 strbuf_addf(buf, "%d", v);
225 } else if (type == TYPE_PATH) {
227 if (git_config_pathname(&v, key_, value_) < 0)
229 strbuf_addstr(buf, v);
231 } else if (type == TYPE_EXPIRY_DATE) {
233 if (git_config_expiry_date(&t, key_, value_) < 0)
235 strbuf_addf(buf, "%"PRItime, t);
236 } else if (type == TYPE_COLOR) {
237 char v[COLOR_MAXLEN];
238 if (git_config_color(v, key_, value_) < 0)
240 strbuf_addstr(buf, v);
242 strbuf_addstr(buf, value_);
244 /* Just show the key name; back out delimiter */
246 strbuf_setlen(buf, buf->len - 1);
249 strbuf_addch(buf, term);
253 static int collect_config(const char *key_, const char *value_, void *cb)
255 struct strbuf_list *values = cb;
257 if (!use_key_regexp && strcmp(key_, key))
259 if (use_key_regexp && regexec(key_regexp, key_, 0, NULL, 0))
261 if (regexp != NULL &&
262 (do_not_match ^ !!regexec(regexp, (value_?value_:""), 0, NULL, 0)))
265 ALLOC_GROW(values->items, values->nr + 1, values->alloc);
266 strbuf_init(&values->items[values->nr], 0);
268 return format_config(&values->items[values->nr++], key_, value_);
271 static int get_value(const char *key_, const char *regex_)
273 int ret = CONFIG_GENERIC_ERROR;
274 struct strbuf_list values = {NULL};
277 if (use_key_regexp) {
281 * NEEDSWORK: this naive pattern lowercasing obviously does not
282 * work for more complex patterns like "^[^.]*Foo.*bar".
283 * Perhaps we should deprecate this altogether someday.
287 for (tl = key + strlen(key) - 1;
288 tl >= key && *tl != '.';
291 for (tl = key; *tl && *tl != '.'; tl++)
294 key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
295 if (regcomp(key_regexp, key, REG_EXTENDED)) {
296 error("invalid key pattern: %s", key_);
297 FREE_AND_NULL(key_regexp);
298 ret = CONFIG_INVALID_PATTERN;
302 if (git_config_parse_key(key_, &key, NULL)) {
303 ret = CONFIG_INVALID_KEY;
309 if (regex_[0] == '!') {
314 regexp = (regex_t*)xmalloc(sizeof(regex_t));
315 if (regcomp(regexp, regex_, REG_EXTENDED)) {
316 error("invalid pattern: %s", regex_);
317 FREE_AND_NULL(regexp);
318 ret = CONFIG_INVALID_PATTERN;
323 config_with_options(collect_config, &values,
324 &given_config_source, &config_options);
326 if (!values.nr && default_value) {
328 ALLOC_GROW(values.items, values.nr + 1, values.alloc);
329 item = &values.items[values.nr++];
330 strbuf_init(item, 0);
331 if (format_config(item, key_, default_value) < 0)
332 die(_("failed to format default config value: %s"),
338 for (i = 0; i < values.nr; i++) {
339 struct strbuf *buf = values.items + i;
340 if (do_all || i == values.nr - 1)
341 fwrite(buf->buf, 1, buf->len, stdout);
360 static char *normalize_value(const char *key, const char *value)
365 if (type == 0 || type == TYPE_PATH || type == TYPE_EXPIRY_DATE)
367 * We don't do normalization for TYPE_PATH here: If
368 * the path is like ~/foobar/, we prefer to store
369 * "~/foobar/" in the config file, and to expand the ~
370 * when retrieving the value.
371 * Also don't do normalization for expiry dates.
373 return xstrdup(value);
374 if (type == TYPE_INT)
375 return xstrfmt("%"PRId64, git_config_int64(key, value));
376 if (type == TYPE_BOOL)
377 return xstrdup(git_config_bool(key, value) ? "true" : "false");
378 if (type == TYPE_BOOL_OR_INT) {
380 v = git_config_bool_or_int(key, value, &is_bool);
382 return xstrfmt("%d", v);
384 return xstrdup(v ? "true" : "false");
386 if (type == TYPE_COLOR) {
387 char v[COLOR_MAXLEN];
388 if (git_config_color(v, key, value))
389 die("cannot parse color '%s'", value);
392 * The contents of `v` now contain an ANSI escape
393 * sequence, not suitable for including within a
394 * configuration file. Treat the above as a
395 * "sanity-check", and return the given value, which we
396 * know is representable as valid color code.
398 return xstrdup(value);
401 die("BUG: cannot normalize type %d", type);
404 static int get_color_found;
405 static const char *get_color_slot;
406 static const char *get_colorbool_slot;
407 static char parsed_color[COLOR_MAXLEN];
409 static int git_get_color_config(const char *var, const char *value, void *cb)
411 if (!strcmp(var, get_color_slot)) {
413 config_error_nonbool(var);
414 if (color_parse(value, parsed_color) < 0)
421 static void get_color(const char *var, const char *def_color)
423 get_color_slot = var;
425 parsed_color[0] = '\0';
426 config_with_options(git_get_color_config, NULL,
427 &given_config_source, &config_options);
429 if (!get_color_found && def_color) {
430 if (color_parse(def_color, parsed_color) < 0)
431 die(_("unable to parse default color value"));
434 fputs(parsed_color, stdout);
437 static int get_colorbool_found;
438 static int get_diff_color_found;
439 static int get_color_ui_found;
440 static int git_get_colorbool_config(const char *var, const char *value,
443 if (!strcmp(var, get_colorbool_slot))
444 get_colorbool_found = git_config_colorbool(var, value);
445 else if (!strcmp(var, "diff.color"))
446 get_diff_color_found = git_config_colorbool(var, value);
447 else if (!strcmp(var, "color.ui"))
448 get_color_ui_found = git_config_colorbool(var, value);
452 static int get_colorbool(const char *var, int print)
454 get_colorbool_slot = var;
455 get_colorbool_found = -1;
456 get_diff_color_found = -1;
457 get_color_ui_found = -1;
458 config_with_options(git_get_colorbool_config, NULL,
459 &given_config_source, &config_options);
461 if (get_colorbool_found < 0) {
462 if (!strcmp(get_colorbool_slot, "color.diff"))
463 get_colorbool_found = get_diff_color_found;
464 if (get_colorbool_found < 0)
465 get_colorbool_found = get_color_ui_found;
468 if (get_colorbool_found < 0)
469 /* default value if none found in config */
470 get_colorbool_found = GIT_COLOR_AUTO;
472 get_colorbool_found = want_color(get_colorbool_found);
475 printf("%s\n", get_colorbool_found ? "true" : "false");
478 return get_colorbool_found ? 0 : 1;
481 static void check_write(void)
483 if (!given_config_source.file && !startup_info->have_repository)
484 die("not in a git directory");
486 if (given_config_source.use_stdin)
487 die("writing to stdin is not supported");
489 if (given_config_source.blob)
490 die("writing config blobs is not supported");
493 struct urlmatch_current_candidate_value {
498 static int urlmatch_collect_fn(const char *var, const char *value, void *cb)
500 struct string_list *values = cb;
501 struct string_list_item *item = string_list_insert(values, var);
502 struct urlmatch_current_candidate_value *matched = item->util;
505 matched = xmalloc(sizeof(*matched));
506 strbuf_init(&matched->value, 0);
507 item->util = matched;
509 strbuf_reset(&matched->value);
513 strbuf_addstr(&matched->value, value);
514 matched->value_is_null = 0;
516 matched->value_is_null = 1;
521 static int get_urlmatch(const char *var, const char *url)
525 struct string_list_item *item;
526 struct urlmatch_config config = { STRING_LIST_INIT_DUP };
527 struct string_list values = STRING_LIST_INIT_DUP;
529 config.collect_fn = urlmatch_collect_fn;
530 config.cascade_fn = NULL;
533 if (!url_normalize(url, &config.url))
534 die("%s", config.url.err);
536 config.section = xstrdup_tolower(var);
537 section_tail = strchr(config.section, '.');
539 *section_tail = '\0';
540 config.key = section_tail + 1;
547 config_with_options(urlmatch_config_entry, &config,
548 &given_config_source, &config_options);
552 for_each_string_list_item(item, &values) {
553 struct urlmatch_current_candidate_value *matched = item->util;
554 struct strbuf buf = STRBUF_INIT;
556 format_config(&buf, item->string,
557 matched->value_is_null ? NULL : matched->value.buf);
558 fwrite(buf.buf, 1, buf.len, stdout);
559 strbuf_release(&buf);
561 strbuf_release(&matched->value);
563 string_list_clear(&config.vars, 1);
564 string_list_clear(&values, 1);
565 free(config.url.url);
567 free((void *)config.section);
571 static char *default_user_config(void)
573 struct strbuf buf = STRBUF_INIT;
575 _("# This is Git's per-user configuration file.\n"
577 "# Please adapt and uncomment the following lines:\n"
580 ident_default_name(),
581 ident_default_email());
582 return strbuf_detach(&buf, NULL);
585 int cmd_config(int argc, const char **argv, const char *prefix)
587 int nongit = !startup_info->have_repository;
590 given_config_source.file = getenv(CONFIG_ENVIRONMENT);
592 argc = parse_options(argc, argv, prefix, builtin_config_options,
593 builtin_config_usage,
594 PARSE_OPT_STOP_AT_NON_OPTION);
596 if (use_global_config + use_system_config + use_local_config +
597 !!given_config_source.file + !!given_config_source.blob > 1) {
598 error("only one config file at a time.");
599 usage_with_options(builtin_config_usage, builtin_config_options);
602 if (use_local_config && nongit)
603 die(_("--local can only be used inside a git repository"));
605 if (given_config_source.file &&
606 !strcmp(given_config_source.file, "-")) {
607 given_config_source.file = NULL;
608 given_config_source.use_stdin = 1;
611 if (use_global_config) {
612 char *user_config = expand_user_path("~/.gitconfig", 0);
613 char *xdg_config = xdg_config_home("config");
617 * It is unknown if HOME/.gitconfig exists, so
618 * we do not know if we should write to XDG
619 * location; error out even if XDG_CONFIG_HOME
620 * is set and points at a sane location.
622 die("$HOME not set");
624 if (access_or_warn(user_config, R_OK, 0) &&
625 xdg_config && !access_or_warn(xdg_config, R_OK, 0)) {
626 given_config_source.file = xdg_config;
629 given_config_source.file = user_config;
633 else if (use_system_config)
634 given_config_source.file = git_etc_gitconfig();
635 else if (use_local_config)
636 given_config_source.file = git_pathdup("config");
637 else if (given_config_source.file) {
638 if (!is_absolute_path(given_config_source.file) && prefix)
639 given_config_source.file =
640 prefix_filename(prefix, given_config_source.file);
643 if (respect_includes_opt == -1)
644 config_options.respect_includes = !given_config_source.file;
646 config_options.respect_includes = respect_includes_opt;
648 config_options.commondir = get_git_common_dir();
649 config_options.git_dir = get_git_dir();
658 if ((actions & (ACTION_GET_COLOR|ACTION_GET_COLORBOOL)) && type) {
659 error("--get-color and variable type are incoherent");
660 usage_with_options(builtin_config_usage, builtin_config_options);
663 if (HAS_MULTI_BITS(actions)) {
664 error("only one action at a time.");
665 usage_with_options(builtin_config_usage, builtin_config_options);
669 case 1: actions = ACTION_GET; break;
670 case 2: actions = ACTION_SET; break;
671 case 3: actions = ACTION_SET_ALL; break;
673 usage_with_options(builtin_config_usage, builtin_config_options);
676 !(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {
677 error("--name-only is only applicable to --list or --get-regexp");
678 usage_with_options(builtin_config_usage, builtin_config_options);
681 if (show_origin && !(actions &
682 (ACTION_GET|ACTION_GET_ALL|ACTION_GET_REGEXP|ACTION_LIST))) {
683 error("--show-origin is only applicable to --get, --get-all, "
684 "--get-regexp, and --list.");
685 usage_with_options(builtin_config_usage, builtin_config_options);
688 if (default_value && !(actions & ACTION_GET)) {
689 error("--default is only applicable to --get");
690 usage_with_options(builtin_config_usage,
691 builtin_config_options);
694 if (actions & PAGING_ACTIONS)
695 setup_auto_pager("config", 1);
697 if (actions == ACTION_LIST) {
698 check_argc(argc, 0, 0);
699 if (config_with_options(show_all_config, NULL,
700 &given_config_source,
701 &config_options) < 0) {
702 if (given_config_source.file)
703 die_errno("unable to read config file '%s'",
704 given_config_source.file);
706 die("error processing config file(s)");
709 else if (actions == ACTION_EDIT) {
712 check_argc(argc, 0, 0);
713 if (!given_config_source.file && nongit)
714 die("not in a git directory");
715 if (given_config_source.use_stdin)
716 die("editing stdin is not supported");
717 if (given_config_source.blob)
718 die("editing blobs is not supported");
719 git_config(git_default_config, NULL);
720 config_file = given_config_source.file ?
721 xstrdup(given_config_source.file) :
722 git_pathdup("config");
723 if (use_global_config) {
724 int fd = open(config_file, O_CREAT | O_EXCL | O_WRONLY, 0666);
726 char *content = default_user_config();
727 write_str_in_full(fd, content);
731 else if (errno != EEXIST)
732 die_errno(_("cannot create configuration file %s"), config_file);
734 launch_editor(config_file, NULL, NULL);
737 else if (actions == ACTION_SET) {
740 check_argc(argc, 2, 2);
741 value = normalize_value(argv[0], argv[1]);
743 ret = git_config_set_in_file_gently(given_config_source.file, argv[0], value);
744 if (ret == CONFIG_NOTHING_SET)
745 error(_("cannot overwrite multiple values with a single value\n"
746 " Use a regexp, --add or --replace-all to change %s."), argv[0]);
749 else if (actions == ACTION_SET_ALL) {
751 check_argc(argc, 2, 3);
752 value = normalize_value(argv[0], argv[1]);
754 return git_config_set_multivar_in_file_gently(given_config_source.file,
755 argv[0], value, argv[2], 0);
757 else if (actions == ACTION_ADD) {
759 check_argc(argc, 2, 2);
760 value = normalize_value(argv[0], argv[1]);
762 return git_config_set_multivar_in_file_gently(given_config_source.file,
764 CONFIG_REGEX_NONE, 0);
766 else if (actions == ACTION_REPLACE_ALL) {
768 check_argc(argc, 2, 3);
769 value = normalize_value(argv[0], argv[1]);
771 return git_config_set_multivar_in_file_gently(given_config_source.file,
772 argv[0], value, argv[2], 1);
774 else if (actions == ACTION_GET) {
775 check_argc(argc, 1, 2);
776 return get_value(argv[0], argv[1]);
778 else if (actions == ACTION_GET_ALL) {
780 check_argc(argc, 1, 2);
781 return get_value(argv[0], argv[1]);
783 else if (actions == ACTION_GET_REGEXP) {
787 check_argc(argc, 1, 2);
788 return get_value(argv[0], argv[1]);
790 else if (actions == ACTION_GET_URLMATCH) {
791 check_argc(argc, 2, 2);
792 return get_urlmatch(argv[0], argv[1]);
794 else if (actions == ACTION_UNSET) {
796 check_argc(argc, 1, 2);
798 return git_config_set_multivar_in_file_gently(given_config_source.file,
799 argv[0], NULL, argv[1], 0);
801 return git_config_set_in_file_gently(given_config_source.file,
804 else if (actions == ACTION_UNSET_ALL) {
806 check_argc(argc, 1, 2);
807 return git_config_set_multivar_in_file_gently(given_config_source.file,
808 argv[0], NULL, argv[1], 1);
810 else if (actions == ACTION_RENAME_SECTION) {
813 check_argc(argc, 2, 2);
814 ret = git_config_rename_section_in_file(given_config_source.file,
819 die("No such section!");
821 else if (actions == ACTION_REMOVE_SECTION) {
824 check_argc(argc, 1, 1);
825 ret = git_config_rename_section_in_file(given_config_source.file,
830 die("No such section!");
832 else if (actions == ACTION_GET_COLOR) {
833 check_argc(argc, 1, 2);
834 get_color(argv[0], argv[1]);
836 else if (actions == ACTION_GET_COLORBOOL) {
837 check_argc(argc, 1, 2);
839 color_stdout_is_tty = git_config_bool("command line", argv[1]);
840 return get_colorbool(argv[0], argc == 2);