@@ -108,6 +108,7 @@ struct config_display_options {
108
108
int show_scope ;
109
109
int show_keys ;
110
110
int type ;
111
+ char * default_value ;
111
112
/* Populated via `display_options_init()`. */
112
113
int term ;
113
114
int delim ;
@@ -126,7 +127,6 @@ static regex_t *regexp;
126
127
static int use_key_regexp ;
127
128
static int do_all ;
128
129
static int do_not_match ;
129
- static char * default_value ;
130
130
static int respect_includes_opt = -1 ;
131
131
static int fixed_value ;
132
132
@@ -416,17 +416,18 @@ static int get_value(const struct config_location_options *opts,
416
416
& opts -> source , the_repository ,
417
417
& opts -> options );
418
418
419
- if (!values .nr && default_value ) {
419
+ if (!values .nr && display_opts -> default_value ) {
420
420
struct key_value_info kvi = KVI_INIT ;
421
421
struct strbuf * item ;
422
422
423
423
kvi_from_param (& kvi );
424
424
ALLOC_GROW (values .items , values .nr + 1 , values .alloc );
425
425
item = & values .items [values .nr ++ ];
426
426
strbuf_init (item , 0 );
427
- if (format_config (display_opts , item , key_ , default_value , & kvi ) < 0 )
427
+ if (format_config (display_opts , item , key_ ,
428
+ display_opts -> default_value , & kvi ) < 0 )
428
429
die (_ ("failed to format default config value: %s" ),
429
- default_value );
430
+ display_opts -> default_value );
430
431
}
431
432
432
433
ret = !values .nr ;
@@ -850,7 +851,8 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
850
851
CONFIG_DISPLAY_OPTIONS (display_opts ),
851
852
OPT_GROUP (N_ ("Other" )),
852
853
OPT_BOOL (0 , "includes" , & respect_includes_opt , N_ ("respect include directives on lookup" )),
853
- OPT_STRING (0 , "default" , & default_value , N_ ("value" ), N_ ("use default value when missing entry" )),
854
+ OPT_STRING (0 , "default" , & display_opts .default_value ,
855
+ N_ ("value" ), N_ ("use default value when missing entry" )),
854
856
OPT_END (),
855
857
};
856
858
int ret ;
@@ -861,7 +863,7 @@ static int cmd_config_get(int argc, const char **argv, const char *prefix)
861
863
862
864
if ((flags & CONFIG_FLAGS_FIXED_VALUE ) && !value_pattern )
863
865
die (_ ("--fixed-value only applies with 'value-pattern'" ));
864
- if (default_value && (do_all || url ))
866
+ if (display_opts . default_value && (do_all || url ))
865
867
die (_ ("--default= cannot be used with --all or --url=" ));
866
868
if (url && (do_all || use_key_regexp || value_pattern ))
867
869
die (_ ("--url= cannot be used with --all, --regexp or --value" ));
@@ -1127,7 +1129,8 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1127
1129
OPT_CMDMODE (0 , "get-colorbool" , & actions , N_ ("find the color setting: slot [<stdout-is-tty>]" ), ACTION_GET_COLORBOOL ),
1128
1130
CONFIG_DISPLAY_OPTIONS (display_opts ),
1129
1131
OPT_GROUP (N_ ("Other" )),
1130
- OPT_STRING (0 , "default" , & default_value , N_ ("value" ), N_ ("with --get, use default value when missing entry" )),
1132
+ OPT_STRING (0 , "default" , & display_opts .default_value ,
1133
+ N_ ("value" ), N_ ("with --get, use default value when missing entry" )),
1131
1134
OPT_STRING (0 , "comment" , & comment_arg , N_ ("value" ), N_ ("human-readable comment string (# will be prepended as needed)" )),
1132
1135
OPT_BOOL (0 , "fixed-value" , & fixed_value , N_ ("use string equality when comparing values to 'value-pattern'" )),
1133
1136
OPT_BOOL (0 , "includes" , & respect_includes_opt , N_ ("respect include directives on lookup" )),
@@ -1172,7 +1175,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1172
1175
exit (129 );
1173
1176
}
1174
1177
1175
- if (default_value && !(actions & ACTION_GET )) {
1178
+ if (display_opts . default_value && !(actions & ACTION_GET )) {
1176
1179
error (_ ("--default is only applicable to --get" ));
1177
1180
exit (129 );
1178
1181
}
0 commit comments