Re: [PATCH v2 31/39] bundle: add new version for use with SHA-256
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Jul 13, 2020, 15:56 UTC
- Message-ID
- <20200713155617.GF11341@szeder.dev>
- In-Reply-To
- <20200713024909.3714837-32-sandals@crustytoothpaste.net>
On Mon, Jul 13, 2020 at 02:49:01AM +0000, brian m. carlson wrote:
Show 24 quoted lines
> @@ -23,17 +24,20 @@ static void add_to_ref_list(const struct object_id *oid, const char *name,
> list->nr++;
> }
>
> -static const struct git_hash_algo *detect_hash_algo(struct strbuf *buf)
> +static int parse_capability(struct bundle_header *header, const char *capability)
> {
> - size_t len = strcspn(buf->buf, " \n");
> - int algo;
> -
> - algo = hash_algo_by_length(len / 2);
> - if (algo == GIT_HASH_UNKNOWN)
> - return NULL;
> - return &hash_algos[algo];
> + const char *arg;
> + if (skip_prefix(capability, "object-format=", &arg)) {
> + int algo = hash_algo_by_name(arg);
> + if (algo == GIT_HASH_UNKNOWN)
> + return error(_("unable to detect hash algorithm"));
> + header->hash_algo = &hash_algos[algo];
> + return 0;
> + }
> + return error(_("unknown capability '%s'"), capability);
> }Show 6 quoted lines
> +test_expect_success 'git bundle v3 rejects unknown extensions' ' > + head -n2 bundle >new && > + echo "@unknown=silly" >>new && > + sed "1,2d" >>new && > + test_must_fail git bundle verify new 2>output && > + grep "unknown capability .unknown=silly." output
This "unknown capability" error message is translated, so it should be checked with 'test_i18ngrep'.
> +' > + > test_done