Skip to content

Commit 798ddd9

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 f9aa0ee commit 798ddd9

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
@@ -5010,9 +5010,10 @@ int cmd_pack_objects(int argc,
50105010
strvec_push(&rp, "--unpacked");
50115011
}
50125012

5013-
if (exclude_promisor_objects && exclude_promisor_objects_best_effort)
5014-
die(_("options '%s' and '%s' cannot be used together"),
5015-
"--exclude-promisor-objects", "--exclude-promisor-objects-best-effort");
5013+
die_for_incompatible_opt2(exclude_promisor_objects,
5014+
"--exclude-promisor-objects",
5015+
exclude_promisor_objects_best_effort,
5016+
"--exclude-promisor-objects-best-effort");
50165017
if (exclude_promisor_objects) {
50175018
use_internal_rev_list = 1;
50185019
fetch_if_missing = 0;
@@ -5050,22 +5051,23 @@ int cmd_pack_objects(int argc,
50505051
if (!pack_to_stdout && thin)
50515052
die(_("--thin cannot be used to build an indexable pack"));
50525053

5053-
if (keep_unreachable && unpack_unreachable)
5054-
die(_("options '%s' and '%s' cannot be used together"), "--keep-unreachable", "--unpack-unreachable");
5054+
die_for_incompatible_opt2(keep_unreachable, "--keep-unreachable",
5055+
unpack_unreachable, "--unpack-unreachable");
50555056
if (!rev_list_all || !rev_list_reflog || !rev_list_index)
50565057
unpack_unreachable_expiration = 0;
50575058

5058-
if (stdin_packs && filter_options.choice)
5059-
die(_("cannot use --filter with --stdin-packs"));
5059+
die_for_incompatible_opt2(stdin_packs, "--stdin-packs",
5060+
filter_options.choice, "--filter");
5061+
50605062

50615063
if (stdin_packs && use_internal_rev_list)
50625064
die(_("cannot use internal rev list with --stdin-packs"));
50635065

50645066
if (cruft) {
50655067
if (use_internal_rev_list)
50665068
die(_("cannot use internal rev list with --cruft"));
5067-
if (stdin_packs)
5068-
die(_("cannot use --stdin-packs with --cruft"));
5069+
die_for_incompatible_opt2(stdin_packs, "--stdin-packs",
5070+
cruft, "--cruft");
50695071
}
50705072

50715073
/*

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)