Subject: Re: [PATCH v2 1/8] pack-objects: use standard option incompatibility functions

From: Junio C Hamano <[email-masked]>
Date: Mon, 14 Apr 2025 13:41:27 -0700

Taylor Blau <[email-masked]> writes:

> pack-objects has a handful of explicit checks for pairs of command-line
> options which are mutually incompatible. Many of these pre-date
> a699367bb8 (i18n: factorize more 'incompatible options' messages,
> 2022-01-31).
>
> Convert the explicit checks into die_for_incompatible_opt2() calls,
> which simplifies the implementation and standardizes pack-objects'
> output when given incompatible options (e.g., --stdin-packs with
> --filter gives different output than --keep-unreachable with
> --unpack-unreachable).

Makes sense.

> -	if (stdin_packs && filter_options.choice)
> -		die(_("cannot use --filter with --stdin-packs"));
> +	die_for_incompatible_opt2(filter_options.choice, "--filter",
> +				  stdin_packs, "--stdin-packs");

The order of check is now reversed (which does not make any
difference to correctness or performance), but this way, we list the
options in the same order in the message as before, which is nice.

>  		test_must_fail git pack-objects --stdin-packs --stdout \
>  			--filter=blob:none </dev/null 2>err &&
> -		test_grep "cannot use --filter with --stdin-packs" err
> +		test_grep "options .--filter. and .--stdin-packs. cannot be used together" err
>  	)
>  '