@matheusbsbs / matheus-bagliano / commits / 0adc6a3d49
Fork 0

fsck: fix bogus commit header check

daae1922 (fsck: check ident lines in commit objects, 2010-04-24) taught fsck to expect commit objects to have the form tree <object name> <parents> author <valid ident string> committer <valid ident string> log message The check is overly strict: for example, it errors out with the message “expected blank line” for perfectly valid commits with an "encoding ISO-8859-1" line. Later it might make sense to teach fsck about the rest of the header and warn about unrecognized header lines, but for simplicity, let’s accept arbitrary trailing lines for now. Reported-by: Tuncer Ayaz <tuncer.ayaz@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed May 26, 2010 at 16:50 UTC 0adc6a3d49a46436780b2dd636918c9840d82236
2 files changed +8 -2
fsck.c
-2
@@ -311,8 +311,6 @@ static int fsck_commit(struct commit *commit, fsck_error error_func)
311 err = fsck_ident(&buffer, &commit->object, error_func);
312 if (err)
313 return err;
314 - if (*buffer != '\n')
315 - return error_func(&commit->object, FSCK_ERROR, "invalid format - expected blank line");
314 if (!commit->tree)
315 return error_func(&commit->object, FSCK_ERROR, "could not load commit's tree %s", sha1_to_hex(tree_sha1));
316
t/t1450-fsck.sh
+8
@@ -5,7 +5,9 @@ test_description='git fsck random collection of tests'
5 . ./test-lib.sh
6
7 test_expect_success setup '
8 + git config i18n.commitencoding ISO-8859-1 &&
9 test_commit A fileA one &&
10 + git config --unset i18n.commitencoding &&
11 git checkout HEAD^0 &&
12 test_commit B fileB two &&
13 git tag -d A B &&
@@ -28,6 +30,12 @@ test_expect_success 'loose objects borrowed from alternate are not missing' '
30 )
31 '
32
33 +test_expect_success 'valid objects appear valid' '
34 + { git fsck 2>out; true; } &&
35 + ! grep error out &&
36 + ! grep fatal out
37 +'
38 +
39 # Corruption tests follow. Make sure to remove all traces of the
40 # specific corruption you test afterwards, lest a later test trip over
41 # it.