|
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;
|
@@ -2884,6 +2885,20 @@ int git_config_set_gently(const char *key, const char *value)
|
2884 | 2885 | return git_config_set_multivar_gently(key, value, NULL, 0);
|
2885 | 2886 | }
|
2886 | 2887 |
|
| 2888 | +int repo_config_set_worktree_gently(struct repository *r, |
| 2889 | + const char *key, const char *value) |
| 2890 | +{ |
| 2891 | + /* Only use worktree-specific config if it is is already enabled. */ |
| 2892 | + if (repository_format_worktree_config) { |
| 2893 | + char *file = repo_git_path(r, "config.worktree"); |
| 2894 | + int ret = git_config_set_multivar_in_file_gently( |
| 2895 | + file, key, value, NULL, 0); |
| 2896 | + free(file); |
| 2897 | + return ret; |
| 2898 | + } |
| 2899 | + return repo_config_set_multivar_gently(r, key, value, NULL, 0); |
| 2900 | +} |
| 2901 | + |
2887 | 2902 | void git_config_set(const char *key, const char *value)
|
2888 | 2903 | {
|
2889 | 2904 | git_config_set_multivar(key, value, NULL, 0);
|
@@ -3181,14 +3196,28 @@ void git_config_set_multivar_in_file(const char *config_filename,
|
3181 | 3196 | int git_config_set_multivar_gently(const char *key, const char *value,
|
3182 | 3197 | const char *value_pattern, unsigned flags)
|
3183 | 3198 | {
|
3184 |
| - return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern, |
3185 |
| - flags); |
| 3199 | + return repo_config_set_multivar_gently(the_repository, key, value, |
| 3200 | + value_pattern, flags); |
| 3201 | +} |
| 3202 | + |
| 3203 | +int repo_config_set_multivar_gently(struct repository *r, const char *key, |
| 3204 | + const char *value, |
| 3205 | + const char *value_pattern, unsigned flags) |
| 3206 | +{ |
| 3207 | + char *file = repo_git_path(r, "config"); |
| 3208 | + int res = git_config_set_multivar_in_file_gently(file, |
| 3209 | + key, value, |
| 3210 | + value_pattern, |
| 3211 | + flags); |
| 3212 | + free(file); |
| 3213 | + return res; |
3186 | 3214 | }
|
3187 | 3215 |
|
3188 | 3216 | void git_config_set_multivar(const char *key, const char *value,
|
3189 | 3217 | const char *value_pattern, unsigned flags)
|
3190 | 3218 | {
|
3191 |
| - git_config_set_multivar_in_file(NULL, key, value, value_pattern, |
| 3219 | + git_config_set_multivar_in_file(git_path("config"), |
| 3220 | + key, value, value_pattern, |
3192 | 3221 | flags);
|
3193 | 3222 | }
|
3194 | 3223 |
|
|
0 commit comments