Commit Diff


commit - b624328edd13c021ae254c221e3ebbfebb49ff6a
commit + d4fbd6eb2ce77846055692cfe05c18e8fabe2dca
blob - 0a66f6c60ab7ddde4e975a741714b22ada064ea2
blob + 99d9089dac46fe448e4697e91a93e3a1a19a634b
--- lib/read_gitconfig.c
+++ lib/read_gitconfig.c
@@ -51,6 +51,18 @@ get_boolean_val(char *val)
 	strcmp(val, "1") == 0);
 }
 
+static int
+skip_node(struct got_gitconfig *gitconfig,
+    struct got_gitconfig_list_node *node)
+{
+	/*
+	 * Skip config nodes which do not describe remotes, and remotes
+	 * which do not have a fetch URL defined (as used by git-annex).
+	 */
+	return (strncasecmp("remote \"", node->field, 8) != 0 ||
+	    got_gitconfig_get_str(gitconfig, node->field, "url") == NULL);
+}
+
 const struct got_error *
 got_repo_read_gitconfig(int *gitconfig_repository_format_version,
     char **gitconfig_author_name, char **gitconfig_author_email,
@@ -179,7 +191,7 @@ got_repo_read_gitconfig(int *gitconfig_repository_form
 		if (err)
 			return err;
 		TAILQ_FOREACH(node, &sections->fields, link) {
-			if (strncasecmp("remote \"", node->field, 8) != 0)
+			if (skip_node(gitconfig, node))
 				continue;
 			nalloc++;
 		}
@@ -196,7 +208,7 @@ got_repo_read_gitconfig(int *gitconfig_repository_form
 			char *name, *end, *mirror;
 			const char *fetch_url, *send_url;
 
-			if (strncasecmp("remote \"", node->field, 8) != 0)
+			if (skip_node(gitconfig, node) != 0)
 				continue;
 
 			remote = &(*remotes)[i];
@@ -213,12 +225,6 @@ got_repo_read_gitconfig(int *gitconfig_repository_form
 
 			fetch_url = got_gitconfig_get_str(gitconfig,
 			    node->field, "url");
-			if (fetch_url == NULL) {
-				err = got_error(GOT_ERR_GITCONFIG_SYNTAX);
-				free(remote->name);
-				remote->name = NULL;
-				goto done;
-			}
 			remote->fetch_url = strdup(fetch_url);
 			if (remote->fetch_url == NULL) {
 				err = got_error_from_errno("strdup");
@@ -232,14 +238,6 @@ got_repo_read_gitconfig(int *gitconfig_repository_form
 			if (send_url == NULL)
 				send_url = got_gitconfig_get_str(gitconfig,
 				    node->field, "url");
-			if (send_url == NULL) {
-				err = got_error(GOT_ERR_GITCONFIG_SYNTAX);
-				free(remote->name);
-				remote->name = NULL;
-				free(remote->fetch_url);
-				remote->fetch_url = NULL;
-				goto done;
-			}
 			remote->send_url = strdup(send_url);
 			if (remote->send_url == NULL) {
 				err = got_error_from_errno("strdup");