Imported Upstream version 2.0.1
[platform/upstream/git.git] / t / t1450-fsck.sh
index 08aa24c..8c739c9 100755 (executable)
@@ -142,6 +142,20 @@ test_expect_success '> in name is reported' '
        grep "error in commit $new" out
 '
 
+# date is 2^64 + 1
+test_expect_success 'integer overflow in timestamps is reported' '
+       git cat-file commit HEAD >basis &&
+       sed "s/^\\(author .*>\\) [0-9]*/\\1 18446744073709551617/" \
+               <basis >bad-timestamp &&
+       new=$(git hash-object -t commit -w --stdin <bad-timestamp) &&
+       test_when_finished "remove_object $new" &&
+       git update-ref refs/heads/bogus "$new" &&
+       test_when_finished "git update-ref -d refs/heads/bogus" &&
+       git fsck 2>out &&
+       cat out &&
+       grep "error in commit $new.*integer overflow" out
+'
+
 test_expect_success 'tag pointing to nonexistent' '
        cat >invalid-tag <<-\EOF &&
        object ffffffffffffffffffffffffffffffffffffffff
@@ -237,4 +251,35 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
        )
 '
 
+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