[PATCH 7/7] submodule-config: cleanup backward compatibility helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use one callback per configuration setting to handle the generic options
which have to be supported for backward compatibility.

This removes some duplication and some support code at the cost of
parsing the .gitmodules file twice when calling the fetch command.

Signed-off-by: Antonio Ospite <ao2@xxxxxx>
---
 submodule-config.c | 39 +++++++++++++++------------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/submodule-config.c b/submodule-config.c
index ce204fb53..0a5274891 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -681,36 +681,20 @@ void submodule_free(struct repository *r)
 		submodule_cache_clear(r->submodule_cache);
 }
 
-struct fetch_config {
-	int *max_children;
-	int *recurse_submodules;
-};
-
-static int gitmodules_fetch_config(const char *var, const char *value, void *cb)
+static int gitmodules_recurse_submodules_config(const char *var,
+						const char *value, void *cb)
 {
-	struct fetch_config *config = cb;
-	if (!strcmp(var, "submodule.fetchjobs")) {
-		*(config->max_children) = parse_submodule_fetchjobs(var, value);
-		return 0;
-	} else if (!strcmp(var, "fetch.recursesubmodules")) {
-		*(config ->recurse_submodules) = parse_fetch_recurse_submodules_arg(var, value);
+	int *recurse_submodules = cb;
+	if (!strcmp(var, "fetch.recursesubmodules")) {
+		*recurse_submodules = parse_fetch_recurse_submodules_arg(var, value);
 		return 0;
 	}
 
 	return 0;
 }
 
-void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
-{
-	struct fetch_config config = {
-		.max_children = max_children,
-		.recurse_submodules = recurse_submodules
-	};
-	config_from_gitmodules(gitmodules_fetch_config, the_repository, &config);
-}
-
-static int gitmodules_update_clone_config(const char *var, const char *value,
-					  void *cb)
+static int gitmodules_fetchobjs_config(const char *var, const char *value,
+				       void *cb)
 {
 	int *max_jobs = cb;
 	if (!strcmp(var, "submodule.fetchjobs"))
@@ -718,7 +702,14 @@ static int gitmodules_update_clone_config(const char *var, const char *value,
 	return 0;
 }
 
+
+void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
+{
+	config_from_gitmodules(gitmodules_fetchobjs_config, the_repository, &max_children);
+	config_from_gitmodules(gitmodules_recurse_submodules_config, the_repository, &recurse_submodules);
+}
+
 void update_clone_config_from_gitmodules(int *max_jobs)
 {
-	config_from_gitmodules(gitmodules_update_clone_config, the_repository, &max_jobs);
+	config_from_gitmodules(gitmodules_fetchobjs_config, the_repository, &max_jobs);
 }
-- 
2.18.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux