Merge branch 'ab/gitweb-link-html-escape'
[gitweb.git] / t / t1450-fsck.sh
index 7ee8ea004f1731b1efbaedf0a8022cdb4946c7cf..8f52da2771c0a26c08b943cf7b9596c5e14afb7d 100755 (executable)
@@ -523,4 +523,26 @@ test_expect_success 'fsck --connectivity-only' '
        )
 '
 
+remove_loose_object () {
+       sha1="$(git rev-parse "$1")" &&
+       remainder=${sha1#??} &&
+       firsttwo=${sha1%$remainder} &&
+       rm .git/objects/$firsttwo/$remainder
+}
+
+test_expect_success 'fsck --name-objects' '
+       rm -rf name-objects &&
+       git init name-objects &&
+       (
+               cd name-objects &&
+               test_commit julius caesar.t &&
+               test_commit augustus &&
+               test_commit caesar &&
+               remove_loose_object $(git rev-parse julius:caesar.t) &&
+               test_must_fail git fsck --name-objects >out &&
+               tree=$(git rev-parse --verify julius:) &&
+               grep "$tree (\(refs/heads/master\|HEAD\)@{[0-9]*}:" out
+       )
+'
+
 test_done