Re: [PATCH v3 30/39] builtin/verify-pack: implement an --object-format option
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jul 23, 2020, 04:54 UTC
- Message-ID
- <CAPig+cT21mc5USWW2Xy1KY0-eRykkmJEkwuTcouBqsPAbUoRfQ@mail.gmail.com>
- In-Reply-To
- <20200723010943.2329634-31-sandals@crustytoothpaste.net>
On Wed, Jul 22, 2020 at 9:10 PM brian m. carlson <sandals@crustytoothpaste.net> wrote:
Show 22 quoted lines
> Since we're not in a repository here, we need to provide git verify-pack
> help to set things up properly. git index-pack already knows an
> --object-format option, so let's accept one as well and pass it down to
> our git index-pack invocation. Since this argument is optional, let's
> dynamically determine the proper location to insert it into the array.
> Finally, let's make t5702 pass the proper argument on down to its git
> verify-pack caller.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
> diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c
> @@ -7,21 +7,27 @@
> +static int verify_one_pack(const char *path, unsigned int flags, const char *hash_algo)
> {
> - const char *argv[] = {"index-pack", NULL, NULL, NULL };
> + const char *argv[] = {"index-pack", NULL, NULL, NULL, NULL };
> + int argno = 1;
>
> + if (hash_algo) {
> + strbuf_addf(&hash_arg, "--object-format=%s", hash_algo);
> + argv[argno++] = hash_arg.buf;
> + }This seems like a good candidate for 'struct argv_array' (but perhaps that's too significant a change or out of scope of this patch?).