|
21 | 21 | #include "dir.h" |
22 | 22 | #include "color.h" |
23 | 23 | #include "refs.h" |
| 24 | +#include "worktree.h" |
24 | 25 |
|
25 | 26 | struct config_source { |
26 | 27 | struct config_source *prev; |
@@ -2294,8 +2295,8 @@ int git_configset_get_string(struct config_set *cs, const char *key, char **dest |
2294 | 2295 | return 1; |
2295 | 2296 | } |
2296 | 2297 |
|
2297 | | -int git_configset_get_string_tmp(struct config_set *cs, const char *key, |
2298 | | - const char **dest) |
| 2298 | +static int git_configset_get_string_tmp(struct config_set *cs, const char *key, |
| 2299 | + const char **dest) |
2299 | 2300 | { |
2300 | 2301 | const char *value; |
2301 | 2302 | if (!git_configset_get_value(cs, key, &value)) { |
@@ -3000,6 +3001,20 @@ int git_config_set_gently(const char *key, const char *value) |
3000 | 3001 | return git_config_set_multivar_gently(key, value, NULL, 0); |
3001 | 3002 | } |
3002 | 3003 |
|
| 3004 | +int repo_config_set_worktree_gently(struct repository *r, |
| 3005 | + const char *key, const char *value) |
| 3006 | +{ |
| 3007 | + /* Only use worktree-specific config if it is is already enabled. */ |
| 3008 | + if (repository_format_worktree_config) { |
| 3009 | + char *file = repo_git_path(r, "config.worktree"); |
| 3010 | + int ret = git_config_set_multivar_in_file_gently( |
| 3011 | + file, key, value, NULL, 0); |
| 3012 | + free(file); |
| 3013 | + return ret; |
| 3014 | + } |
| 3015 | + return repo_config_set_multivar_gently(r, key, value, NULL, 0); |
| 3016 | +} |
| 3017 | + |
3003 | 3018 | void git_config_set(const char *key, const char *value) |
3004 | 3019 | { |
3005 | 3020 | git_config_set_multivar(key, value, NULL, 0); |
@@ -3297,14 +3312,28 @@ void git_config_set_multivar_in_file(const char *config_filename, |
3297 | 3312 | int git_config_set_multivar_gently(const char *key, const char *value, |
3298 | 3313 | const char *value_pattern, unsigned flags) |
3299 | 3314 | { |
3300 | | - return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern, |
3301 | | - flags); |
| 3315 | + return repo_config_set_multivar_gently(the_repository, key, value, |
| 3316 | + value_pattern, flags); |
| 3317 | +} |
| 3318 | + |
| 3319 | +int repo_config_set_multivar_gently(struct repository *r, const char *key, |
| 3320 | + const char *value, |
| 3321 | + const char *value_pattern, unsigned flags) |
| 3322 | +{ |
| 3323 | + char *file = repo_git_path(r, "config"); |
| 3324 | + int res = git_config_set_multivar_in_file_gently(file, |
| 3325 | + key, value, |
| 3326 | + value_pattern, |
| 3327 | + flags); |
| 3328 | + free(file); |
| 3329 | + return res; |
3302 | 3330 | } |
3303 | 3331 |
|
3304 | 3332 | void git_config_set_multivar(const char *key, const char *value, |
3305 | 3333 | const char *value_pattern, unsigned flags) |
3306 | 3334 | { |
3307 | | - git_config_set_multivar_in_file(NULL, key, value, value_pattern, |
| 3335 | + git_config_set_multivar_in_file(git_path("config"), |
| 3336 | + key, value, value_pattern, |
3308 | 3337 | flags); |
3309 | 3338 | } |
3310 | 3339 |
|
|
0 commit comments