diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2020-05-25 19:59:01 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-05-27 10:07:06 -0700 |
commit | bb095d087557b9ded2245270d3fac64ddc774af6 (patch) | |
tree | 3f1606b6d03d075e166b20242266e66b8f7e65ce /builtin/receive-pack.c | |
parent | connect: detect algorithm when fetching refs (diff) | |
download | tgif-bb095d087557b9ded2245270d3fac64ddc774af6.tar.xz |
builtin/receive-pack: detect when the server doesn't support our hash
Detect when the server doesn't support our hash algorithm and abort.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/receive-pack.c')
-rw-r--r-- | builtin/receive-pack.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index a4159b559e..0da8ca5134 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1624,6 +1624,8 @@ static struct command *read_head_info(struct packet_reader *reader, linelen = strlen(reader->line); if (linelen < reader->pktlen) { const char *feature_list = reader->line + linelen + 1; + const char *hash = NULL; + int len = 0; if (parse_feature_request(feature_list, "report-status")) report_status = 1; if (parse_feature_request(feature_list, "side-band-64k")) @@ -1636,6 +1638,13 @@ static struct command *read_head_info(struct packet_reader *reader, if (advertise_push_options && parse_feature_request(feature_list, "push-options")) use_push_options = 1; + hash = parse_feature_value(feature_list, "object-format", &len, NULL); + if (!hash) { + hash = hash_algos[GIT_HASH_SHA1].name; + len = strlen(hash); + } + if (xstrncmpz(the_hash_algo->name, hash, len)) + die("error: unsupported object format '%s'", hash); } if (!strcmp(reader->line, "push-cert")) { |