diff options
author | Daniel Barkalow <barkalow@iabervon.org> | 2008-04-26 15:53:09 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-04-26 17:36:17 -0700 |
commit | c13b2633f49e3e61b37973204793a4d9ef981175 (patch) | |
tree | 54f173438e506190b6bbc02f574ec0ab6b8339d7 /http.c | |
parent | 36c79d2bf893b9957688a6c8c13cc0bf0589e596 (diff) | |
download | git-c13b2633f49e3e61b37973204793a4d9ef981175.tar.gz git-c13b2633f49e3e61b37973204793a4d9ef981175.tar.xz |
Make walker.fetch_ref() take a struct ref.
This simplifies a few things, makes a few things slightly more
complicated, but, more importantly, allows that, when struct ref can
represent a symref, http_fetch_ref() can return one.
Incidentally makes the string that http_fetch_ref() gets include "refs/"
(if appropriate), because that's how the name field of struct ref works.
As far as I can tell, the usage in walker:interpret_target() wouldn't have
worked previously, if it ever would have been used, which it wouldn't
(since the fetch process uses the hash instead of the name of the ref
there).
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -589,8 +589,9 @@ static char *quote_ref_url(const char *base, const char *ref) len += 2; /* extra two hex plus replacement % */ qref = xmalloc(len); memcpy(qref, base, baselen); - memcpy(qref + baselen, "/refs/", 6); - for (cp = ref, dp = qref + baselen + 6; (ch = *cp) != 0; cp++) { + dp = qref + baselen; + *(dp++) = '/'; + for (cp = ref; (ch = *cp) != 0; cp++) { if (needs_quote(ch)) { *dp++ = '%'; *dp++ = hex((ch >> 4) & 0xF); @@ -604,7 +605,7 @@ static char *quote_ref_url(const char *base, const char *ref) return qref; } -int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1) +int http_fetch_ref(const char *base, struct ref *ref) { char *url; struct strbuf buffer = STRBUF_INIT; @@ -612,7 +613,7 @@ int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1) struct slot_results results; int ret; - url = quote_ref_url(base, ref); + url = quote_ref_url(base, ref->name); slot = get_active_slot(); slot->results = &results; curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer); @@ -624,12 +625,12 @@ int http_fetch_ref(const char *base, const char *ref, unsigned char *sha1) if (results.curl_result == CURLE_OK) { strbuf_rtrim(&buffer); if (buffer.len == 40) - ret = get_sha1_hex(buffer.buf, sha1); + ret = get_sha1_hex(buffer.buf, ref->old_sha1); else ret = 1; } else { ret = error("Couldn't get %s for %s\n%s", - url, ref, curl_errorstr); + url, ref->name, curl_errorstr); } } else { ret = error("Unable to start request"); |