diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-05-08 20:06:23 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-05-08 20:06:23 -0700 |
commit | 31a3c6bb45aa61e45f1663871620eaf742f0abbb (patch) | |
tree | 5d3fcd7f35999e519a3df485f1c61e9f2c2fed80 /http.c | |
parent | a064ac1bc3f13103f92ae198da7fc44a1452c89d (diff) | |
parent | be885d96fe0ebed47e637f3b0dd24fc5902f7081 (diff) | |
download | git-31a3c6bb45aa61e45f1663871620eaf742f0abbb.tar.gz git-31a3c6bb45aa61e45f1663871620eaf742f0abbb.tar.xz |
Merge branch 'db/learn-HEAD'
* db/learn-HEAD:
Make ls-remote http://... list HEAD, like for git://...
Make walker.fetch_ref() take a struct ref.
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 18 |
1 files changed, 11 insertions, 7 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,15 @@ 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); - else + ret = get_sha1_hex(buffer.buf, ref->old_sha1); + else if (!prefixcmp(buffer.buf, "ref: ")) { + ref->symref = xstrdup(buffer.buf + 5); + ret = 0; + } 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"); |