diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-10-18 14:19:14 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-18 14:19:14 +0900 |
commit | b0e5269c4eae3425be3cdc946c6414dfb886ae77 (patch) | |
tree | b0bfbe2bc3cd8677b188864a2e6c0782e2c32ad5 /t | |
parent | Merge branch 'jk/sha1-loose-object-info-fix' into maint (diff) | |
parent | fsck: handle NULL return of lookup_blob() and lookup_tree() (diff) | |
download | tgif-b0e5269c4eae3425be3cdc946c6414dfb886ae77.tar.xz |
Merge branch 'rs/fsck-null-return-from-lookup' into maint
Improve behaviour of "git fsck" upon finding a missing object.
* rs/fsck-null-return-from-lookup:
fsck: handle NULL return of lookup_blob() and lookup_tree()
Diffstat (limited to 't')
-rwxr-xr-x | t/t1450-fsck.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 4087150db1..cb4b66e29d 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -222,6 +222,28 @@ test_expect_success 'unparseable tree object' ' test_i18ngrep ! "fatal: empty filename in tree entry" out ' +hex2oct() { + perl -ne 'printf "\\%03o", hex for /../g' +} + +test_expect_success 'tree entry with type mismatch' ' + test_when_finished "remove_object \$blob" && + test_when_finished "remove_object \$tree" && + test_when_finished "remove_object \$commit" && + test_when_finished "git update-ref -d refs/heads/type_mismatch" && + blob=$(echo blob | git hash-object -w --stdin) && + blob_bin=$(echo $blob | hex2oct) && + tree=$( + printf "40000 dir\0${blob_bin}100644 file\0${blob_bin}" | + git hash-object -t tree --stdin -w --literally + ) && + commit=$(git commit-tree $tree) && + git update-ref refs/heads/type_mismatch $commit && + test_must_fail git fsck >out 2>&1 && + test_i18ngrep "is a blob, not a tree" out && + test_i18ngrep ! "dangling blob" out +' + test_expect_success 'tag pointing to nonexistent' ' cat >invalid-tag <<-\EOF && object ffffffffffffffffffffffffffffffffffffffff |