On 4/5/2017 1:03 PM, Jonathan Nieder wrote:
Hi,

g...@jeffhostetler.com wrote:

Signed-off-by: Jeff Hostetler <jeffh...@microsoft.com>
---
 builtin/fsck.c  |  1 +
 cache.h         |  2 ++
 read-cache.c    |  7 +++++++
 t/t1450-fsck.sh | 11 +++++++++++
 4 files changed, 21 insertions(+)

Yay!  I love this version.

--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -771,6 +771,7 @@ int cmd_fsck(int argc, const char **argv, const char 
*prefix)
        }

        if (keep_cache_objects) {
+               force_verify_index_checksum = 1;

nit: now that there isn't a config this is overriding, this isn't
"force_verify" so much as "verify".

good point.


[...]
+++ b/t/t1450-fsck.sh
@@ -689,4 +689,15 @@ test_expect_success 'bogus head does not fallback to all 
heads' '
        ! grep $blob out
 '

+test_expect_success PERL 'detect corrupt index file in fsck' '
+       cp .git/index .git/index.backup &&
+       echo zzzzzzzz >zzzzzzzz &&
+       git add zzzzzzzz &&
+       perl -pi -e "s/zzzzzzzz/yyyyyyyy/" .git/index &&
+       test_must_fail git fsck --cache &&
+       rm .git/index &&
+       mv .git/index.backup .git/index &&
+       rm zzzzzzzz
+'

This is great.

optional: you can do the cleanup commands in test_when_finished to
make sure they happen even if the test fails.

Tests don't seem to use "perl -pi" anywhere else.  This instance could
be simplified by using sed.

With whatever subset of the changes below look good,
Reviewed-by: Jonathan Nieder <jrnie...@gmail.com>
[...]

good point.

I just pushed another version.
Thanks,
Jeff


Reply via email to