diff options
author | Jeff King <peff@peff.net> | 2013-09-28 04:35:10 -0400 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2013-10-14 16:57:04 -0700 |
commit | c65d5692cd3434133c2e8f1a20074a261e0267f0 (patch) | |
tree | 27456795da2f1a648e4268d70687310bb7964b9f /remote-curl.c | |
parent | c93c92f30977adb2eb385a851f9f5e9975da7d5e (diff) | |
download | git-c65d5692cd3434133c2e8f1a20074a261e0267f0.tar.gz |
remote-curl: make refs_url a strbuf
In the discover_refs function, we use a strbuf named
"buffer" for multiple purposes. First we build the info/refs
URL in it, and then detach that to a bare pointer. Then, we
use the same strbuf to store the result of fetching the
refs.
Let's instead keep a separate refs_url strbuf. This is less
confusing, as the "buffer" strbuf is now used for only one
thing.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'remote-curl.c')
-rw-r--r-- | remote-curl.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/remote-curl.c b/remote-curl.c index 8ffd7ff7a7..af087267d6 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -185,8 +185,8 @@ static struct discovery* discover_refs(const char *service, int for_push) struct strbuf exp = STRBUF_INIT; struct strbuf type = STRBUF_INIT; struct strbuf buffer = STRBUF_INIT; + struct strbuf refs_url = STRBUF_INIT; struct discovery *last = last_discovery; - char *refs_url; int http_ret, maybe_smart = 0; struct http_get_options options; @@ -194,24 +194,23 @@ static struct discovery* discover_refs(const char *service, int for_push) return last; free_discovery(last); - strbuf_addf(&buffer, "%sinfo/refs", url); + strbuf_addf(&refs_url, "%sinfo/refs", url); if ((!prefixcmp(url, "http://") || !prefixcmp(url, "https://")) && git_env_bool("GIT_SMART_HTTP", 1)) { maybe_smart = 1; if (!strchr(url, '?')) - strbuf_addch(&buffer, '?'); + strbuf_addch(&refs_url, '?'); else - strbuf_addch(&buffer, '&'); - strbuf_addf(&buffer, "service=%s", service); + strbuf_addch(&refs_url, '&'); + strbuf_addf(&refs_url, "service=%s", service); } - refs_url = strbuf_detach(&buffer, NULL); memset(&options, 0, sizeof(options)); options.content_type = &type; options.no_cache = 1; options.keep_error = 1; - http_ret = http_get_strbuf(refs_url, &buffer, &options); + http_ret = http_get_strbuf(refs_url.buf, &buffer, &options); switch (http_ret) { case HTTP_OK: break; @@ -264,7 +263,7 @@ static struct discovery* discover_refs(const char *service, int for_push) else last->refs = parse_info_refs(last); - free(refs_url); + strbuf_release(&refs_url); strbuf_release(&exp); strbuf_release(&type); strbuf_release(&buffer); |