@@ -69,8 +69,8 @@ static struct option builtin_config_options[] = {
69
69
OPT_BIT (0 , "remove-section" , & actions , N_ ("remove a section: name" ), ACTION_REMOVE_SECTION ),
70
70
OPT_BIT ('l' , "list" , & actions , N_ ("list all" ), ACTION_LIST ),
71
71
OPT_BIT ('e' , "edit" , & actions , N_ ("open an editor" ), ACTION_EDIT ),
72
- OPT_STRING (0 , "get-color" , & get_color_slot , N_ ("slot" ), N_ ( " find the color configured: [default]" )),
73
- OPT_STRING (0 , "get-colorbool" , & get_colorbool_slot , N_ ("slot" ), N_ ( " find the color setting: [stdout-is-tty]" )),
72
+ OPT_BIT (0 , "get-color" , & actions , N_ ("find the color configured: slot [default]" ), ACTION_GET_COLOR ),
73
+ OPT_BIT (0 , "get-colorbool" , & actions , N_ ("find the color setting: slot [stdout-is-tty]" ), ACTION_GET_COLORBOOL ),
74
74
OPT_GROUP (N_ ("Type" )),
75
75
OPT_BIT (0 , "bool" , & types , N_ ("value is \"true\" or \"false\"" ), TYPE_BOOL ),
76
76
OPT_BIT (0 , "int" , & types , N_ ("value is decimal number" ), TYPE_INT ),
@@ -303,8 +303,9 @@ static int git_get_color_config(const char *var, const char *value, void *cb)
303
303
return 0 ;
304
304
}
305
305
306
- static void get_color (const char * def_color )
306
+ static void get_color (const char * var , const char * def_color )
307
307
{
308
+ get_color_slot = var ;
308
309
get_color_found = 0 ;
309
310
parsed_color [0 ] = '\0' ;
310
311
git_config_with_options (git_get_color_config , NULL ,
@@ -333,8 +334,9 @@ static int git_get_colorbool_config(const char *var, const char *value,
333
334
return 0 ;
334
335
}
335
336
336
- static int get_colorbool (int print )
337
+ static int get_colorbool (const char * var , int print )
337
338
{
339
+ get_colorbool_slot = var ;
338
340
get_colorbool_found = -1 ;
339
341
get_diff_color_found = -1 ;
340
342
get_color_ui_found = -1 ;
@@ -532,12 +534,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
532
534
usage_with_options (builtin_config_usage , builtin_config_options );
533
535
}
534
536
535
- if (get_color_slot )
536
- actions |= ACTION_GET_COLOR ;
537
- if (get_colorbool_slot )
538
- actions |= ACTION_GET_COLORBOOL ;
539
-
540
- if ((get_color_slot || get_colorbool_slot ) && types ) {
537
+ if ((actions & (ACTION_GET_COLOR |ACTION_GET_COLORBOOL )) && types ) {
541
538
error ("--get-color and variable type are incoherent" );
542
539
usage_with_options (builtin_config_usage , builtin_config_options );
543
540
}
@@ -683,12 +680,14 @@ int cmd_config(int argc, const char **argv, const char *prefix)
683
680
die ("No such section!" );
684
681
}
685
682
else if (actions == ACTION_GET_COLOR ) {
686
- get_color (argv [0 ]);
683
+ check_argc (argc , 1 , 2 );
684
+ get_color (argv [0 ], argv [1 ]);
687
685
}
688
686
else if (actions == ACTION_GET_COLORBOOL ) {
689
- if (argc == 1 )
690
- color_stdout_is_tty = git_config_bool ("command line" , argv [0 ]);
691
- return get_colorbool (argc != 0 );
687
+ check_argc (argc , 1 , 2 );
688
+ if (argc == 2 )
689
+ color_stdout_is_tty = git_config_bool ("command line" , argv [1 ]);
690
+ return get_colorbool (argv [0 ], argc == 2 );
692
691
}
693
692
694
693
return 0 ;
0 commit comments