fsck: support demoting errors to warnings

We already have support in `git receive-pack` to deal with some legacy
repositories which have non-fatal issues.

Let's make `git fsck` itself useful with such repositories, too, by
allowing users to ignore known issues, or at least demote those issues
to mere warnings.

Example: `git -c fsck.missingEmail=ignore fsck` would hide
problems with missing emails in author, committer and tagger lines.

In the same spirit that `git receive-pack`'s usage of the fsck machinery
differs from `git fsck`'s – some of the non-fatal warnings in `git fsck`
are fatal with `git receive-pack` when receive.fsckObjects = true, for
example – we strictly separate the fsck.<msg-id> from the
receive.fsck.<msg-id> settings.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2015-06-22 17:27:06 +02:00
committed by Junio C Hamano
parent 4b55b9b479
commit 2becf00ff7
3 changed files with 34 additions and 0 deletions

View File

@ -46,6 +46,16 @@ static int show_dangling = 1;
#define DIRENT_SORT_HINT(de) ((de)->d_ino)
#endif
static int fsck_config(const char *var, const char *value, void *cb)
{
if (skip_prefix(var, "fsck.", &var)) {
fsck_set_msg_type(&fsck_obj_options, var, value);
return 0;
}
return git_default_config(var, value, cb);
}
static void objreport(struct object *obj, const char *msg_type,
const char *err)
{
@ -640,6 +650,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
include_reflogs = 0;
}
git_config(fsck_config, NULL);
fsck_head_link();
fsck_object_dir(get_object_directory());