Skip to content

Commit 8b7209e

Browse files
ttaylorrgitster
authored andcommitted
pack-objects: use standard option incompatibility functions
pack-objects has a handful of explicit checks for pairs of command-line options which are mutually incompatible. Many of these pre-date a699367 (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). There is one minor piece of test fallout in t5331 that expects the old format, which has been corrected. Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 77d6ee5 commit 8b7209e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

builtin/pack-objects.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4654,9 +4654,10 @@ int cmd_pack_objects(int argc,
46544654
strvec_push(&rp, "--unpacked");
46554655
}
46564656

4657-
if (exclude_promisor_objects && exclude_promisor_objects_best_effort)
4658-
die(_("options '%s' and '%s' cannot be used together"),
4659-
"--exclude-promisor-objects", "--exclude-promisor-objects-best-effort");
4657+
die_for_incompatible_opt2(exclude_promisor_objects,
4658+
"--exclude-promisor-objects",
4659+
exclude_promisor_objects_best_effort,
4660+
"--exclude-promisor-objects-best-effort");
46604661
if (exclude_promisor_objects) {
46614662
use_internal_rev_list = 1;
46624663
fetch_if_missing = 0;
@@ -4694,22 +4695,23 @@ int cmd_pack_objects(int argc,
46944695
if (!pack_to_stdout && thin)
46954696
die(_("--thin cannot be used to build an indexable pack"));
46964697

4697-
if (keep_unreachable && unpack_unreachable)
4698-
die(_("options '%s' and '%s' cannot be used together"), "--keep-unreachable", "--unpack-unreachable");
4698+
die_for_incompatible_opt2(keep_unreachable, "--keep-unreachable",
4699+
unpack_unreachable, "--unpack-unreachable");
46994700
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
47004701
unpack_unreachable_expiration = 0;
47014702

4702-
if (stdin_packs && filter_options.choice)
4703-
die(_("cannot use --filter with --stdin-packs"));
4703+
die_for_incompatible_opt2(stdin_packs, "--stdin-packs",
4704+
filter_options.choice, "--filter");
4705+
47044706

47054707
if (stdin_packs && use_internal_rev_list)
47064708
die(_("cannot use internal rev list with --stdin-packs"));
47074709

47084710
if (cruft) {
47094711
if (use_internal_rev_list)
47104712
die(_("cannot use internal rev list with --cruft"));
4711-
if (stdin_packs)
4712-
die(_("cannot use --stdin-packs with --cruft"));
4713+
die_for_incompatible_opt2(stdin_packs, "--stdin-packs",
4714+
cruft, "--cruft");
47134715
}
47144716

47154717
/*

t/t5331-pack-objects-stdin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test_expect_success '--stdin-packs is incompatible with --filter' '
6464
cd stdin-packs &&
6565
test_must_fail git pack-objects --stdin-packs --stdout \
6666
--filter=blob:none </dev/null 2>err &&
67-
test_grep "cannot use --filter with --stdin-packs" err
67+
test_grep "options .--stdin-packs. and .--filter. cannot be used together" err
6868
)
6969
'
7070

0 commit comments

Comments
 (0)