commit - 2eb6139c99c62e54720d434e6ab75a5b3b82c57b
commit + 99e30d93bfe048c40e277fed11e065fdb420d51f
blob - 652f3a8089f499bd882469d76a46f4643d670a75
blob + 2f0d8354033636a99c65040e57ebb2ebe81897e2
--- lib/read_gitconfig.c
+++ lib/read_gitconfig.c
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,
if (err)
return err;
TAILQ_FOREACH(node, §ions->fields, link) {
- if (strncasecmp("remote \"", node->field, 8) != 0)
+ if (skip_node(gitconfig, node))
continue;
nalloc++;
}
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];
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");
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");