Download raw body.
allow remotes without urls in git config; add tests
On Wed, Jan 24, 2024 at 11:58:46PM -0600, Kyle Ackerman wrote: > With your modification to got-read-gitconfig.c and his new regressions, > your diff throws 2 failed regressions because of "privsep peer process > closed pipe". Thanks Kyle! I see the mistake I made, which Omar also pointed out off-list. This is a fixed version which passes all tests including the ones added by James. Again, this is just a style change relative to the original diff by James. diff /home/stsp/src/got commit - cfcfb026c8c94bb60b400f6b21b89bce7b698873 path + /home/stsp/src/got blob - 99f2a5a5d4fdc582151efa06eb679bf4bfd09a69 file + libexec/got-read-gitconfig/got-read-gitconfig.c --- libexec/got-read-gitconfig/got-read-gitconfig.c +++ libexec/got-read-gitconfig/got-read-gitconfig.c @@ -195,6 +195,17 @@ 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); +} + static const struct got_error * gitconfig_remotes_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig) { @@ -212,7 +223,7 @@ gitconfig_remotes_request(struct imsgbuf *ibuf, struct return err; TAILQ_FOREACH(node, §ions->fields, link) { - if (strncasecmp("remote \"", node->field, 8) != 0) + if (skip_node(gitconfig, node)) continue; nremotes++; } @@ -232,7 +243,7 @@ gitconfig_remotes_request(struct imsgbuf *ibuf, struct TAILQ_FOREACH(node, §ions->fields, link) { char *name, *end, *mirror; - if (strncasecmp("remote \"", node->field, 8) != 0) + if (skip_node(gitconfig, node)) continue; name = strdup(node->field + 8); @@ -247,20 +258,11 @@ gitconfig_remotes_request(struct imsgbuf *ibuf, struct remotes[i].fetch_url = got_gitconfig_get_str(gitconfig, node->field, "url"); - if (remotes[i].fetch_url == NULL) { - err = got_error(GOT_ERR_GITCONFIG_SYNTAX); - goto done; - } remotes[i].send_url = got_gitconfig_get_str(gitconfig, node->field, "pushurl"); if (remotes[i].send_url == NULL) - remotes[i].send_url = got_gitconfig_get_str(gitconfig, - node->field, "url"); - if (remotes[i].send_url == NULL) { - err = got_error(GOT_ERR_GITCONFIG_SYNTAX); - goto done; - } + remotes[i].send_url = remotes[i].fetch_url; remotes[i].mirror_references = 0; mirror = got_gitconfig_get_str(gitconfig, node->field,
allow remotes without urls in git config; add tests