From 45f5ef3d77ec3d2465641cd219b2f3874fa72083 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 5 Oct 2018 15:05:53 +0200 Subject: submodule: factor out a config_set_in_gitmodules_file_gently function Introduce a new config_set_in_gitmodules_file_gently() function to write config values to the .gitmodules file. This is in preparation for a future change which will use the function to write to the .gitmodules file in a more controlled way instead of using "git config -f .gitmodules". The purpose of the change is mainly to centralize the code that writes to the .gitmodules file to avoid some duplication. The naming follows git_config_set_in_file_gently() but the git_ prefix is removed to communicate that this is not a generic git-config API. Signed-off-by: Antonio Ospite Signed-off-by: Junio C Hamano --- submodule-config.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'submodule-config.c') diff --git a/submodule-config.c b/submodule-config.c index 5aaf7ac00e..9faf141e47 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -707,6 +707,18 @@ int print_config_from_gitmodules(struct repository *repo, const char *key) return 0; } +int config_set_in_gitmodules_file_gently(const char *key, const char *value) +{ + int ret; + + ret = git_config_set_in_file_gently(GITMODULES_FILE, key, value); + if (ret < 0) + /* Maybe the user already did that, don't error out here */ + warning(_("Could not update .gitmodules entry %s"), key); + + return ret; +} + struct fetch_config { int *max_children; int *recurse_submodules; -- cgit v1.3