@@ -3178,21 +3178,39 @@ static void maybe_remove_section(struct config_store_data *store,
3178
3178
* end_offset = store -> parsed [store -> parsed_nr - 1 ].end ;
3179
3179
}
3180
3180
3181
+ int repo_config_set_in_file_gently (struct repository * r , const char * config_filename ,
3182
+ const char * key , const char * comment , const char * value )
3183
+ {
3184
+ return repo_config_set_multivar_in_file_gently (r , config_filename , key , value , NULL , comment , 0 );
3185
+ }
3186
+
3181
3187
int git_config_set_in_file_gently (const char * config_filename ,
3182
3188
const char * key , const char * comment , const char * value )
3183
3189
{
3184
- return git_config_set_multivar_in_file_gently (config_filename , key , value , NULL , comment , 0 );
3190
+ return repo_config_set_in_file_gently (the_repository , config_filename ,
3191
+ key , comment , value );
3192
+ }
3193
+
3194
+ void repo_config_set_in_file (struct repository * r , const char * config_filename ,
3195
+ const char * key , const char * value )
3196
+ {
3197
+ repo_config_set_multivar_in_file (r , config_filename , key , value , NULL , 0 );
3185
3198
}
3186
3199
3187
3200
void git_config_set_in_file (const char * config_filename ,
3188
3201
const char * key , const char * value )
3189
3202
{
3190
- git_config_set_multivar_in_file (config_filename , key , value , NULL , 0 );
3203
+ repo_config_set_in_file (the_repository , config_filename , key , value );
3204
+ }
3205
+
3206
+ int repo_config_set_gently (struct repository * r , const char * key , const char * value )
3207
+ {
3208
+ return repo_config_set_multivar_gently (r , key , value , NULL , 0 );
3191
3209
}
3192
3210
3193
3211
int git_config_set_gently (const char * key , const char * value )
3194
3212
{
3195
- return git_config_set_multivar_gently ( key , value , NULL , 0 );
3213
+ return repo_config_set_gently ( the_repository , key , value );
3196
3214
}
3197
3215
3198
3216
int repo_config_set_worktree_gently (struct repository * r ,
@@ -3209,13 +3227,18 @@ int repo_config_set_worktree_gently(struct repository *r,
3209
3227
return repo_config_set_multivar_gently (r , key , value , NULL , 0 );
3210
3228
}
3211
3229
3212
- void git_config_set ( const char * key , const char * value )
3230
+ void repo_config_set ( struct repository * r , const char * key , const char * value )
3213
3231
{
3214
- git_config_set_multivar ( key , value , NULL , 0 );
3232
+ repo_config_set_multivar ( r , key , value , NULL , 0 );
3215
3233
3216
3234
trace2_cmd_set_config (key , value );
3217
3235
}
3218
3236
3237
+ void git_config_set (const char * key , const char * value )
3238
+ {
3239
+ repo_config_set (the_repository , key , value );
3240
+ }
3241
+
3219
3242
char * git_config_prepare_comment_string (const char * comment )
3220
3243
{
3221
3244
size_t leading_blanks ;
@@ -3293,11 +3316,12 @@ static void validate_comment_string(const char *comment)
3293
3316
* - the config file is removed and the lock file rename()d to it.
3294
3317
*
3295
3318
*/
3296
- int git_config_set_multivar_in_file_gently (const char * config_filename ,
3297
- const char * key , const char * value ,
3298
- const char * value_pattern ,
3299
- const char * comment ,
3300
- unsigned flags )
3319
+ int repo_config_set_multivar_in_file_gently (struct repository * r ,
3320
+ const char * config_filename ,
3321
+ const char * key , const char * value ,
3322
+ const char * value_pattern ,
3323
+ const char * comment ,
3324
+ unsigned flags )
3301
3325
{
3302
3326
int fd = -1 , in_fd = -1 ;
3303
3327
int ret ;
@@ -3317,7 +3341,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
3317
3341
store .multi_replace = (flags & CONFIG_FLAGS_MULTI_REPLACE ) != 0 ;
3318
3342
3319
3343
if (!config_filename )
3320
- config_filename = filename_buf = git_pathdup ( "config" );
3344
+ config_filename = filename_buf = repo_git_path ( r , "config" );
3321
3345
3322
3346
/*
3323
3347
* The lock serves a purpose in addition to locking: the new
@@ -3526,7 +3550,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
3526
3550
ret = 0 ;
3527
3551
3528
3552
/* Invalidate the config cache */
3529
- git_config_clear ( );
3553
+ repo_config_clear ( r );
3530
3554
3531
3555
out_free :
3532
3556
rollback_lock_file (& lock );
@@ -3543,19 +3567,39 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
3543
3567
goto out_free ;
3544
3568
}
3545
3569
3546
- void git_config_set_multivar_in_file (const char * config_filename ,
3547
- const char * key , const char * value ,
3548
- const char * value_pattern , unsigned flags )
3570
+ int git_config_set_multivar_in_file_gently (const char * config_filename ,
3571
+ const char * key , const char * value ,
3572
+ const char * value_pattern ,
3573
+ const char * comment ,
3574
+ unsigned flags )
3549
3575
{
3550
- if (!git_config_set_multivar_in_file_gently (config_filename , key , value ,
3551
- value_pattern , NULL , flags ))
3576
+ return repo_config_set_multivar_in_file_gently (the_repository , config_filename ,
3577
+ key , value , value_pattern ,
3578
+ comment , flags );
3579
+ }
3580
+
3581
+ void repo_config_set_multivar_in_file (struct repository * r ,
3582
+ const char * config_filename ,
3583
+ const char * key , const char * value ,
3584
+ const char * value_pattern , unsigned flags )
3585
+ {
3586
+ if (!repo_config_set_multivar_in_file_gently (r , config_filename , key , value ,
3587
+ value_pattern , NULL , flags ))
3552
3588
return ;
3553
3589
if (value )
3554
3590
die (_ ("could not set '%s' to '%s'" ), key , value );
3555
3591
else
3556
3592
die (_ ("could not unset '%s'" ), key );
3557
3593
}
3558
3594
3595
+ void git_config_set_multivar_in_file (const char * config_filename ,
3596
+ const char * key , const char * value ,
3597
+ const char * value_pattern , unsigned flags )
3598
+ {
3599
+ repo_config_set_multivar_in_file (the_repository , config_filename ,
3600
+ key , value , value_pattern , flags );
3601
+ }
3602
+
3559
3603
int git_config_set_multivar_gently (const char * key , const char * value ,
3560
3604
const char * value_pattern , unsigned flags )
3561
3605
{
@@ -3576,12 +3620,21 @@ int repo_config_set_multivar_gently(struct repository *r, const char *key,
3576
3620
return res ;
3577
3621
}
3578
3622
3623
+ void repo_config_set_multivar (struct repository * r ,
3624
+ const char * key , const char * value ,
3625
+ const char * value_pattern , unsigned flags )
3626
+ {
3627
+ char * file = repo_git_path (r , "config" );
3628
+ git_config_set_multivar_in_file (file , key , value ,
3629
+ value_pattern , flags );
3630
+ free (file );
3631
+ }
3632
+
3579
3633
void git_config_set_multivar (const char * key , const char * value ,
3580
3634
const char * value_pattern , unsigned flags )
3581
3635
{
3582
- git_config_set_multivar_in_file (git_path ("config" ),
3583
- key , value , value_pattern ,
3584
- flags );
3636
+ repo_config_set_multivar (the_repository , key , value ,
3637
+ value_pattern , flags );
3585
3638
}
3586
3639
3587
3640
static size_t section_name_match (const char * buf , const char * name )
0 commit comments