Skip to content

Commit 1241800

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b3bf470 commit 1241800

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

builtin/repack.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,19 +1203,13 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
12031203
if (delete_redundant && repository_format_precious_objects)
12041204
die(_("cannot delete packs in a precious-objects repo"));
12051205

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");
12091209

1210-
if (pack_everything & PACK_CRUFT) {
1210+
if (pack_everything & PACK_CRUFT)
12111211
pack_everything |= ALL_INTO_ONE;
12121212

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-
12191213
if (write_bitmaps < 0) {
12201214
if (!write_midx &&
12211215
(!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))

0 commit comments

Comments
 (0)