summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2018-05-02 00:25:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-02 04:59:51 (GMT)
commitdd724bcb2f23618b53593230e13c9f352be7a873 (patch)
treeb49cd5f6873833119b4d24f7431e7069d2f58a8e /http.c
parent70c369cde064375483917f4874a6e5670ef48164 (diff)
downloadgit-dd724bcb2f23618b53593230e13c9f352be7a873.zip
git-dd724bcb2f23618b53593230e13c9f352be7a873.tar.gz
git-dd724bcb2f23618b53593230e13c9f352be7a873.tar.bz2
http: eliminate hard-coded constants
Use the_hash_algo to find the right size for parsing pack names. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r--http.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/http.c b/http.c
index 3034d10..312a5e1 100644
--- a/http.c
+++ b/http.c
@@ -2047,7 +2047,8 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head)
int ret = 0, i = 0;
char *url, *data;
struct strbuf buf = STRBUF_INIT;
- unsigned char sha1[20];
+ unsigned char hash[GIT_MAX_RAWSZ];
+ const unsigned hexsz = the_hash_algo->hexsz;
end_url_with_slash(&buf, base_url);
strbuf_addstr(&buf, "objects/info/packs");
@@ -2063,13 +2064,13 @@ int http_get_info_packs(const char *base_url, struct packed_git **packs_head)
switch (data[i]) {
case 'P':
i++;
- if (i + 52 <= buf.len &&
+ if (i + hexsz + 12 <= buf.len &&
starts_with(data + i, " pack-") &&
- starts_with(data + i + 46, ".pack\n")) {
- get_sha1_hex(data + i + 6, sha1);
- fetch_and_setup_pack_index(packs_head, sha1,
+ starts_with(data + i + hexsz + 6, ".pack\n")) {
+ get_sha1_hex(data + i + 6, hash);
+ fetch_and_setup_pack_index(packs_head, hash,
base_url);
- i += 51;
+ i += hexsz + 11;
break;
}
default: