Merge branch 'ja/directory-attrs'
[gitweb.git] / t / t1450-fsck.sh
index 9c64eefbb3b28305bf850752db3af963b90066f4..d730734fde8e4de69fdf2662915bc67342198fc8 100755 (executable)
@@ -211,4 +211,61 @@ test_expect_success 'rev-list --verify-objects with bad sha1' '
        grep -q "error: sha1 mismatch 63ffffffffffffffffffffffffffffffffffffff" out
 '
 
+_bz='\0'
+_bz5="$_bz$_bz$_bz$_bz$_bz"
+_bz20="$_bz5$_bz5$_bz5$_bz5"
+
+test_expect_success 'fsck notices blob entry pointing to null sha1' '
+       (git init null-blob &&
+        cd null-blob &&
+        sha=$(printf "100644 file$_bz$_bz20" |
+              git hash-object -w --stdin -t tree) &&
+         git fsck 2>out &&
+         cat out &&
+         grep "warning.*null sha1" out
+       )
+'
+
+test_expect_success 'fsck notices submodule entry pointing to null sha1' '
+       (git init null-commit &&
+        cd null-commit &&
+        sha=$(printf "160000 submodule$_bz$_bz20" |
+              git hash-object -w --stdin -t tree) &&
+         git fsck 2>out &&
+         cat out &&
+         grep "warning.*null sha1" out
+       )
+'
+
+test_expect_success 'fsck notices "." and ".." in trees' '
+       (
+               git init dots &&
+               cd dots &&
+               blob=$(echo foo | git hash-object -w --stdin) &&
+               tab=$(printf "\\t") &&
+               git mktree <<-EOF &&
+               100644 blob $blob$tab.
+               100644 blob $blob$tab..
+               EOF
+               git fsck 2>out &&
+               cat out &&
+               grep "warning.*\\." out
+       )
+'
+
+test_expect_success 'fsck notices ".git" in trees' '
+       (
+               git init dotgit &&
+               cd dotgit &&
+               blob=$(echo foo | git hash-object -w --stdin) &&
+               tab=$(printf "\\t") &&
+               git mktree <<-EOF &&
+               100644 blob $blob$tab.git
+               EOF
+               git fsck 2>out &&
+               cat out &&
+               grep "warning.*\\.git" out
+       )
+'
+
 test_done