@@ -162,7 +162,7 @@ static int get_value(const char *key_, const char *regex_)
162
162
char * global = NULL , * repo_config = NULL ;
163
163
const char * system_wide = NULL , * local ;
164
164
165
- local = config_exclusive_filename ;
165
+ local = given_config_file ;
166
166
if (!local ) {
167
167
const char * home = getenv ("HOME" );
168
168
local = repo_config = git_pathdup ("config" );
@@ -301,7 +301,8 @@ static void get_color(const char *def_color)
301
301
{
302
302
get_color_found = 0 ;
303
303
parsed_color [0 ] = '\0' ;
304
- git_config (git_get_color_config , NULL );
304
+ git_config_with_options (git_get_color_config , NULL ,
305
+ given_config_file );
305
306
306
307
if (!get_color_found && def_color )
307
308
color_parse (def_color , "command line" , parsed_color );
@@ -328,7 +329,8 @@ static int get_colorbool(int print)
328
329
{
329
330
get_colorbool_found = -1 ;
330
331
get_diff_color_found = -1 ;
331
- git_config (git_get_colorbool_config , NULL );
332
+ git_config_with_options (git_get_colorbool_config , NULL ,
333
+ given_config_file );
332
334
333
335
if (get_colorbool_found < 0 ) {
334
336
if (!strcmp (get_colorbool_slot , "color.diff" ))
@@ -351,7 +353,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
351
353
int nongit = !startup_info -> have_repository ;
352
354
char * value ;
353
355
354
- config_exclusive_filename = getenv (CONFIG_ENVIRONMENT );
356
+ given_config_file = getenv (CONFIG_ENVIRONMENT );
355
357
356
358
argc = parse_options (argc , argv , prefix , builtin_config_options ,
357
359
builtin_config_usage ,
@@ -366,23 +368,23 @@ int cmd_config(int argc, const char **argv, const char *prefix)
366
368
char * home = getenv ("HOME" );
367
369
if (home ) {
368
370
char * user_config = xstrdup (mkpath ("%s/.gitconfig" , home ));
369
- config_exclusive_filename = user_config ;
371
+ given_config_file = user_config ;
370
372
} else {
371
373
die ("$HOME not set" );
372
374
}
373
375
}
374
376
else if (use_system_config )
375
- config_exclusive_filename = git_etc_gitconfig ();
377
+ given_config_file = git_etc_gitconfig ();
376
378
else if (use_local_config )
377
- config_exclusive_filename = git_pathdup ("config" );
379
+ given_config_file = git_pathdup ("config" );
378
380
else if (given_config_file ) {
379
381
if (!is_absolute_path (given_config_file ) && prefix )
380
- config_exclusive_filename =
382
+ given_config_file =
381
383
xstrdup (prefix_filename (prefix ,
382
384
strlen (prefix ),
383
385
given_config_file ));
384
386
else
385
- config_exclusive_filename = given_config_file ;
387
+ given_config_file = given_config_file ;
386
388
}
387
389
388
390
if (end_null ) {
@@ -421,28 +423,29 @@ int cmd_config(int argc, const char **argv, const char *prefix)
421
423
422
424
if (actions == ACTION_LIST ) {
423
425
check_argc (argc , 0 , 0 );
424
- if (git_config (show_all_config , NULL ) < 0 ) {
425
- if (config_exclusive_filename )
426
+ if (git_config_with_options (show_all_config , NULL ,
427
+ given_config_file ) < 0 ) {
428
+ if (given_config_file )
426
429
die_errno ("unable to read config file '%s'" ,
427
- config_exclusive_filename );
430
+ given_config_file );
428
431
else
429
432
die ("error processing config file(s)" );
430
433
}
431
434
}
432
435
else if (actions == ACTION_EDIT ) {
433
436
check_argc (argc , 0 , 0 );
434
- if (!config_exclusive_filename && nongit )
437
+ if (!given_config_file && nongit )
435
438
die ("not in a git directory" );
436
439
git_config (git_default_config , NULL );
437
- launch_editor (config_exclusive_filename ?
438
- config_exclusive_filename : git_path ("config" ),
440
+ launch_editor (given_config_file ?
441
+ given_config_file : git_path ("config" ),
439
442
NULL , NULL );
440
443
}
441
444
else if (actions == ACTION_SET ) {
442
445
int ret ;
443
446
check_argc (argc , 2 , 2 );
444
447
value = normalize_value (argv [0 ], argv [1 ]);
445
- ret = git_config_set ( argv [0 ], value );
448
+ ret = git_config_set_in_file ( given_config_file , argv [0 ], value );
446
449
if (ret == CONFIG_NOTHING_SET )
447
450
error ("cannot overwrite multiple values with a single value\n"
448
451
" Use a regexp, --add or --replace-all to change %s." , argv [0 ]);
@@ -451,17 +454,20 @@ int cmd_config(int argc, const char **argv, const char *prefix)
451
454
else if (actions == ACTION_SET_ALL ) {
452
455
check_argc (argc , 2 , 3 );
453
456
value = normalize_value (argv [0 ], argv [1 ]);
454
- return git_config_set_multivar (argv [0 ], value , argv [2 ], 0 );
457
+ return git_config_set_multivar_in_file (given_config_file ,
458
+ argv [0 ], value , argv [2 ], 0 );
455
459
}
456
460
else if (actions == ACTION_ADD ) {
457
461
check_argc (argc , 2 , 2 );
458
462
value = normalize_value (argv [0 ], argv [1 ]);
459
- return git_config_set_multivar (argv [0 ], value , "^$" , 0 );
463
+ return git_config_set_multivar_in_file (given_config_file ,
464
+ argv [0 ], value , "^$" , 0 );
460
465
}
461
466
else if (actions == ACTION_REPLACE_ALL ) {
462
467
check_argc (argc , 2 , 3 );
463
468
value = normalize_value (argv [0 ], argv [1 ]);
464
- return git_config_set_multivar (argv [0 ], value , argv [2 ], 1 );
469
+ return git_config_set_multivar_in_file (given_config_file ,
470
+ argv [0 ], value , argv [2 ], 1 );
465
471
}
466
472
else if (actions == ACTION_GET ) {
467
473
check_argc (argc , 1 , 2 );
@@ -482,18 +488,22 @@ int cmd_config(int argc, const char **argv, const char *prefix)
482
488
else if (actions == ACTION_UNSET ) {
483
489
check_argc (argc , 1 , 2 );
484
490
if (argc == 2 )
485
- return git_config_set_multivar (argv [0 ], NULL , argv [1 ], 0 );
491
+ return git_config_set_multivar_in_file (given_config_file ,
492
+ argv [0 ], NULL , argv [1 ], 0 );
486
493
else
487
- return git_config_set (argv [0 ], NULL );
494
+ return git_config_set_in_file (given_config_file ,
495
+ argv [0 ], NULL );
488
496
}
489
497
else if (actions == ACTION_UNSET_ALL ) {
490
498
check_argc (argc , 1 , 2 );
491
- return git_config_set_multivar (argv [0 ], NULL , argv [1 ], 1 );
499
+ return git_config_set_multivar_in_file (given_config_file ,
500
+ argv [0 ], NULL , argv [1 ], 1 );
492
501
}
493
502
else if (actions == ACTION_RENAME_SECTION ) {
494
503
int ret ;
495
504
check_argc (argc , 2 , 2 );
496
- ret = git_config_rename_section (argv [0 ], argv [1 ]);
505
+ ret = git_config_rename_section_in_file (given_config_file ,
506
+ argv [0 ], argv [1 ]);
497
507
if (ret < 0 )
498
508
return ret ;
499
509
if (ret == 0 )
@@ -502,7 +512,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
502
512
else if (actions == ACTION_REMOVE_SECTION ) {
503
513
int ret ;
504
514
check_argc (argc , 1 , 1 );
505
- ret = git_config_rename_section (argv [0 ], NULL );
515
+ ret = git_config_rename_section_in_file (given_config_file ,
516
+ argv [0 ], NULL );
506
517
if (ret < 0 )
507
518
return ret ;
508
519
if (ret == 0 )
0 commit comments