diff --git a/Documentation/git-fsck.adoc b/Documentation/git-fsck.adoc index 1751f692d42b8c4864aa9f40b32dd6bbf8395697..f89b9677fe5900166ebc1a9a067996471cb45816 100644 --- a/Documentation/git-fsck.adoc +++ b/Documentation/git-fsck.adoc @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs] - [--[no-]full] [--strict] [--verbose] [--lost-found] + [--[no-]full] [--strict|--minimal] [--verbose] [--lost-found] [--[no-]dangling] [--[no-]progress] [--connectivity-only] [--[no-]name-objects] [--[no-]references] [...] @@ -83,6 +83,13 @@ care about this output and want to speed it up further. objects that trigger this check, but it is recommended to check new projects with this flag. +--minimal:: + Enable minimal checking, this only errors on checks that need to pass + for Git to properly function on the repository. + This can be used on existing repositories, including the Linux kernel + and Git itself. + Cannot be used together with `--strict`. + --verbose:: Be chatty. diff --git a/builtin/fsck.c b/builtin/fsck.c index b1a650c6731d3268c65c2204af1975fe23e6d226..9c5cc7747240b2c3d16e66b919c510e02b882260 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -41,6 +41,7 @@ static int include_reflogs = 1; static int check_full = 1; static int connectivity_only; static int check_strict; +static int check_minimal; static int keep_cache_objects; static struct fsck_options fsck_walk_options = FSCK_OPTIONS_DEFAULT; static struct fsck_options fsck_obj_options = FSCK_OPTIONS_DEFAULT; @@ -917,6 +918,8 @@ static void fsck_refs(struct repository *r) strvec_push(&refs_verify.args, "--verbose"); if (check_strict) strvec_push(&refs_verify.args, "--strict"); + if (check_minimal) + strvec_push(&refs_verify.args, "--minimal"); if (run_command(&refs_verify)) errors_found |= ERROR_REFS; @@ -927,7 +930,7 @@ static void fsck_refs(struct repository *r) static char const * const fsck_usage[] = { N_("git fsck [--tags] [--root] [--unreachable] [--cache] [--no-reflogs]\n" - " [--[no-]full] [--strict] [--verbose] [--lost-found]\n" + " [--[no-]full] [--strict|--minimal] [--verbose] [--lost-found]\n" " [--[no-]dangling] [--[no-]progress] [--connectivity-only]\n" " [--[no-]name-objects] [--[no-]references] [...]"), NULL @@ -944,6 +947,7 @@ static struct option fsck_opts[] = { OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")), OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")), OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")), + OPT_BOOL(0, "minimal", &check_minimal, N_("enable minimal checking")), OPT_BOOL(0, "lost-found", &write_lost_and_found, N_("write dangling objects in .git/lost-found")), OPT_BOOL(0, "progress", &show_progress, N_("show progress")), @@ -972,10 +976,17 @@ int cmd_fsck(int argc, fsck_walk_options.walk = mark_object; fsck_obj_options.walk = mark_used; fsck_obj_options.error_func = fsck_objects_error_func; + + die_for_incompatible_opt2(check_strict, "--strict", + check_minimal, "--minimal"); if (check_strict) fsck_obj_options.strict = 1; + if (check_minimal) + fsck_obj_options.minimal = 1; + if (show_progress == -1) + show_progress = isatty(2); if (verbose) show_progress = 0; diff --git a/builtin/refs.c b/builtin/refs.c index 3064f888b24304ce07dba107be137ad8d420e731..4ae3ea67553df41b0247ad34db943f40a9eec421 100644 --- a/builtin/refs.c +++ b/builtin/refs.c @@ -14,7 +14,7 @@ N_("git refs migrate --ref-format= [--no-reflog] [--dry-run]") #define REFS_VERIFY_USAGE \ - N_("git refs verify [--strict] [--verbose]") + N_("git refs verify [--strict|--minimal] [--verbose]") #define REFS_EXISTS_USAGE \ N_("git refs exists ") @@ -89,6 +89,7 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix, struct option options[] = { OPT_BOOL(0, "verbose", &fsck_refs_options.verbose, N_("be verbose")), OPT_BOOL(0, "strict", &fsck_refs_options.strict, N_("enable strict checking")), + OPT_BOOL(0, "minimal", &fsck_refs_options.minimal, N_("enable minimal checking")), OPT_END(), }; int ret = 0; @@ -97,6 +98,9 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix, if (argc) usage(_("'git refs verify' takes no arguments")); + die_for_incompatible_opt2(fsck_refs_options.strict, "--strict", + fsck_refs_options.minimal, "--minimal"); + repo_config(the_repository, git_fsck_config, &fsck_refs_options); prepare_repo_settings(the_repository); diff --git a/fsck.c b/fsck.c index 341e100d24ece03992d9b10d6c91c5bea089b752..299f060fd3fede6f8717d929e34a8bcc200b5f70 100644 --- a/fsck.c +++ b/fsck.c @@ -111,6 +111,8 @@ static enum fsck_msg_type fsck_msg_type(enum fsck_msg_id msg_id, if (options->strict && msg_type == FSCK_WARN) msg_type = FSCK_ERROR; + if (options->minimal && msg_type == FSCK_ERROR) + msg_type = FSCK_WARN; return msg_type; } diff --git a/fsck.h b/fsck.h index cb6ef32f4f3aaa1ac2ff8a97e38ab9b60b4fadf9..8cdf569fdc4adce9fbe60fc2f71a2ff550023b26 100644 --- a/fsck.h +++ b/fsck.h @@ -170,6 +170,7 @@ struct fsck_options { fsck_walk_func walk; fsck_error error_func; unsigned strict; + unsigned minimal; unsigned verbose; enum fsck_msg_type *msg_type; struct oidset skip_oids;