aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2015-06-22 17:27:06 +0200
committerJunio C Hamano <gitster@pobox.com>2015-06-23 14:27:36 -0700
commit2becf00ff70b324999d0e3046d828a80884ab561 (patch)
tree55276fe5b8c96bf4e7c4b641b2748a74a6672318
parent4b55b9b4793b2b134fb439161d5407168cd88dcc (diff)
downloadgit-2becf00ff70b324999d0e3046d828a80884ab561.tar.gz
git-2becf00ff70b324999d0e3046d828a80884ab561.tar.xz
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>
-rw-r--r--Documentation/config.txt11
-rw-r--r--builtin/fsck.c12
-rwxr-xr-xt/t1450-fsck.sh11
3 files changed, 34 insertions, 0 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9393f4ee0..1c657675a 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1242,6 +1242,17 @@ filter.<driver>.smudge::
object to a worktree file upon checkout. See
linkgit:gitattributes[5] for details.
+fsck.<msg-id>::
+ Allows overriding the message type (error, warn or ignore) of a
+ specific message ID such as `missingEmail`.
++
+For convenience, fsck prefixes the error/warning with the message ID,
+e.g. "missingEmail: invalid author/committer line - missing email" means
+that setting `fsck.missingEmail = ignore` will hide that issue.
++
+This feature is intended to support working with legacy repositories
+which cannot be repaired without disruptive changes.
+
gc.aggressiveDepth::
The depth parameter used in the delta compression
algorithm used by 'git gc --aggressive'. This defaults
diff --git a/builtin/fsck.c b/builtin/fsck.c
index cea623d3a..6dc2f9487 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -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());
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 7c5b3d518..17271295f 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -287,6 +287,17 @@ test_expect_success 'rev-list --verify-objects with bad sha1' '
grep -q "error: sha1 mismatch 63ffffffffffffffffffffffffffffffffffffff" out
'
+test_expect_success 'force fsck to ignore double author' '
+ git cat-file commit HEAD >basis &&
+ sed "s/^author .*/&,&/" <basis | tr , \\n >multiple-authors &&
+ new=$(git hash-object -t commit -w --stdin <multiple-authors) &&
+ test_when_finished "remove_object $new" &&
+ git update-ref refs/heads/bogus "$new" &&
+ test_when_finished "git update-ref -d refs/heads/bogus" &&
+ test_must_fail git fsck &&
+ git -c fsck.multipleAuthors=ignore fsck
+'
+
_bz='\0'
_bz5="$_bz$_bz$_bz$_bz$_bz"
_bz20="$_bz5$_bz5$_bz5$_bz5"