Re: [PATCH 3/8] builtin/clone: refactor handling of "--reference{,-if-able}"
- From
Toon Claes <toon@iotcl.com>
- Date
- Aug 28, 2026, 14:52 UTC
- Message-ID
- <877blauwkm.fsf@emacs.iotcl.com>
- In-Reply-To
- <20260825-pks-odb-write-alternates-at-creation-time-v1-3-911513ba95c3@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 18 quoted lines
> diff --git a/builtin/clone.c b/builtin/clone.c
> index 8c990ce0cc..8eae3ac7d9 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -218,14 +220,20 @@ static void copy_alternates(struct strbuf *src, const char *src_repo)
> fclose(in);
> }
>
> -static void setup_reference(void)
> +static void collect_alternates(struct strvec *alternates)
> {
> - int required = 1;
> - for_each_string_list(&option_required_reference,
> - add_one_reference, &required);
> - required = 0;
> - for_each_string_list(&option_optional_reference,
> - add_one_reference, &required);
> + if (option_required_reference.nr || option_optional_reference.nr) {I was about to ask why you're adding this guard, but it looks a lot more clean with the next commit on top.
Show 12 quoted lines
> + struct add_one_alternate_data data = {
> + .alternates = alternates,
> + .required = 1,
> + };
> +
> + for_each_string_list(&option_required_reference,
> + add_one_alternate, &data);
> + data.required = 0;
> + for_each_string_list(&option_optional_reference,
> + add_one_alternate, &data);
> + }
> }-- Laters, Toon