aboutsummaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-06-14 06:31:22 -0400
committerJunio C Hamano <gitster@pobox.com>2024-06-14 09:34:38 -0700
commit9badf97c42474df3f0474a851bdc2e62e59da403 (patch)
treeca49a533faa022d695f1aedde428e54c10a73ad2 /remote.c
parentbd1b88dc7aedb44561559e88cde0dd7bad78e2ae (diff)
downloadgit-9badf97c42474df3f0474a851bdc2e62e59da403.tar.xz
remote: allow resetting url list
Because remote.*.url is treated as a multi-valued key, there is no way to override previous config. So for example if you have remote.origin.url set to some wrong value, doing: git -c remote.origin.url=right fetch would not work. It would append "right" to the list, which means we'd still fetch from "wrong" (since subsequent values are used only as push urls). Let's provide a mechanism to reset the list, like we do for other multi-valued keys (e.g., credential.helper, http.extraheaders, and merge.suppressDest all use this "empty string means reset" pattern). Reported-by: Mathew George <mathewegeorge@gmail.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/remote.c b/remote.c
index 9417d83e51..b7262964fb 100644
--- a/remote.c
+++ b/remote.c
@@ -63,12 +63,18 @@ static char *alias_url(const char *url, struct rewrites *r)
static void add_url(struct remote *remote, const char *url)
{
- strvec_push(&remote->url, url);
+ if (*url)
+ strvec_push(&remote->url, url);
+ else
+ strvec_clear(&remote->url);
}
static void add_pushurl(struct remote *remote, const char *pushurl)
{
- strvec_push(&remote->pushurl, pushurl);
+ if (*pushurl)
+ strvec_push(&remote->pushurl, pushurl);
+ else
+ strvec_clear(&remote->pushurl);
}
static void add_pushurl_alias(struct remote_state *remote_state,