Skip to content

Commit bb095d0

Browse files
bk2204gitster
authored andcommitted
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>
1 parent 7c601dc commit bb095d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

builtin/receive-pack.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,8 @@ static struct command *read_head_info(struct packet_reader *reader,
16241624
linelen = strlen(reader->line);
16251625
if (linelen < reader->pktlen) {
16261626
const char *feature_list = reader->line + linelen + 1;
1627+
const char *hash = NULL;
1628+
int len = 0;
16271629
if (parse_feature_request(feature_list, "report-status"))
16281630
report_status = 1;
16291631
if (parse_feature_request(feature_list, "side-band-64k"))
@@ -1636,6 +1638,13 @@ static struct command *read_head_info(struct packet_reader *reader,
16361638
if (advertise_push_options
16371639
&& parse_feature_request(feature_list, "push-options"))
16381640
use_push_options = 1;
1641+
hash = parse_feature_value(feature_list, "object-format", &len, NULL);
1642+
if (!hash) {
1643+
hash = hash_algos[GIT_HASH_SHA1].name;
1644+
len = strlen(hash);
1645+
}
1646+
if (xstrncmpz(the_hash_algo->name, hash, len))
1647+
die("error: unsupported object format '%s'", hash);
16391648
}
16401649

16411650
if (!strcmp(reader->line, "push-cert")) {

0 commit comments

Comments
 (0)