repack: use die_for_incompatible_opt3() for -A/-k/--cruft
The repack option --keep-unreachable is incompatible with -A, --cruft is incompatible with -A and -k, and -k is short for --keep-unreachable. So they are all incompatible with each other. Use the function for checking three mutually incompatible options, die_for_incompatible_opt3(), to perform this check in one place and without repetition. This is shorter and clearer. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Dec 6, 2023 at 12:51 UTC
12418008679e3ab6bd57a8b974ac56b7c1bd5315
1 file changed
+4
-10
builtin/repack.c
+4
-10
@@ -1203,19 +1203,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
1203
if (delete_redundant && repository_format_precious_objects)
1204
die(_("cannot delete packs in a precious-objects repo"));
1205
1206
- if (keep_unreachable &&
1207
- (unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE)))
1208
- die(_("options '%s' and '%s' cannot be used together"), "--keep-unreachable", "-A");
1206
+ die_for_incompatible_opt3(unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE), "-A",
1207
+ keep_unreachable, "-k/--keep-unreachable",
1208
+ pack_everything & PACK_CRUFT, "--cruft");
1209
1210
- if (pack_everything & PACK_CRUFT) {
1210
+ if (pack_everything & PACK_CRUFT)
1211
pack_everything |= ALL_INTO_ONE;
1212
1213
- if (unpack_unreachable || (pack_everything & LOOSEN_UNREACHABLE))
1214
- die(_("options '%s' and '%s' cannot be used together"), "--cruft", "-A");
1215
- if (keep_unreachable)
1216
- die(_("options '%s' and '%s' cannot be used together"), "--cruft", "-k");
1217
- }
1218
-
1213
if (write_bitmaps < 0) {
1214
if (!write_midx &&
1215
(!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))