submodule-config: add helper to get 'update-clone' config from .gitmodules
authorAntonio Ospite <ao2@ao2.it>
Tue, 26 Jun 2018 10:47:07 +0000 (12:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Jun 2018 19:56:12 +0000 (12:56 -0700)
Add a helper function to make it clearer that retrieving 'update-clone'
configuration from the .gitmodules file is a special case supported
solely for backward compatibility purposes.

This change removes one direct use of 'config_from_gitmodules' for
options not strictly related to submodules: "submodule.fetchjobs" does
not describe a property of a submodule, but a behavior of other commands
when dealing with submodules, so it does not really belong to the
.gitmodules file.

This is in the effort to communicate better that .gitmodules is not to
be used as a mechanism to store arbitrary configuration in the
repository that any command can retrieve.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Acked-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
submodule-config.c
submodule-config.h
index 20ae9191ca376841ca2540502d85a3dc150d3417..110a47eca2ffcbd9e656fc8d7b2c3c82b5c36697 100644 (file)
@@ -1706,8 +1706,8 @@ static int update_clone_task_finished(int result,
        return 0;
 }
 
-static int gitmodules_update_clone_config(const char *var, const char *value,
-                                         void *cb)
+static int git_update_clone_config(const char *var, const char *value,
+                                  void *cb)
 {
        int *max_jobs = cb;
        if (!strcmp(var, "submodule.fetchjobs"))
@@ -1757,8 +1757,8 @@ static int update_clone(int argc, const char **argv, const char *prefix)
        };
        suc.prefix = prefix;
 
-       config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
-       git_config(gitmodules_update_clone_config, &max_jobs);
+       update_clone_config_from_gitmodules(&max_jobs);
+       git_config(git_update_clone_config, &max_jobs);
 
        argc = parse_options(argc, argv, prefix, module_update_clone_options,
                             git_submodule_helper_usage, 0);
index f44d6a777575355dae22caa03a737a98bdd57003..9a2b13d8bcabe7c912a15b7d54bf7fc4a1926a54 100644 (file)
@@ -716,3 +716,17 @@ void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
        };
        config_from_gitmodules(gitmodules_fetch_config, &config);
 }
+
+static int gitmodules_update_clone_config(const char *var, const char *value,
+                                         void *cb)
+{
+       int *max_jobs = cb;
+       if (!strcmp(var, "submodule.fetchjobs"))
+               *max_jobs = parse_submodule_fetchjobs(var, value);
+       return 0;
+}
+
+void update_clone_config_from_gitmodules(int *max_jobs)
+{
+       config_from_gitmodules(gitmodules_update_clone_config, &max_jobs);
+}
index cff297a75f64055e88fb4cb133bbb15786c4d433..b6f19d0d42a9610c3e90c56c90642195bc24ef13 100644 (file)
@@ -67,5 +67,6 @@ int check_submodule_name(const char *name);
 extern void config_from_gitmodules(config_fn_t fn, void *data);
 
 extern void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules);
+extern void update_clone_config_from_gitmodules(int *max_jobs);
 
 #endif /* SUBMODULE_CONFIG_H */