]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t1450-fsck.sh
Merge branch 'jk/fsck-indices-in-worktrees'
[thirdparty/git.git] / t / t1450-fsck.sh
index fdb886dfe431f36dfc4ef6bcf24abf6827c2243d..bca46378b256f824708a0fb5bcb0afe3f1de1056 100755 (executable)
@@ -1023,4 +1023,34 @@ test_expect_success 'fsck error on gitattributes with excessive size' '
        test_cmp expected actual
 '
 
+test_expect_success 'fsck detects problems in worktree index' '
+       test_when_finished "git worktree remove -f wt" &&
+       git worktree add wt &&
+
+       echo "this will be removed to break the worktree index" >wt/file &&
+       git -C wt add file &&
+       blob=$(git -C wt rev-parse :file) &&
+       remove_object $blob &&
+
+       test_must_fail git fsck --name-objects >actual 2>&1 &&
+       cat >expect <<-EOF &&
+       missing blob $blob (.git/worktrees/wt/index:file)
+       EOF
+       test_cmp expect actual
+'
+
+test_expect_success 'fsck reports problems in main index without filename' '
+       test_when_finished "rm -f .git/index && git read-tree HEAD" &&
+       echo "this object will be removed to break the main index" >file &&
+       git add file &&
+       blob=$(git rev-parse :file) &&
+       remove_object $blob &&
+
+       test_must_fail git fsck --name-objects >actual 2>&1 &&
+       cat >expect <<-EOF &&
+       missing blob $blob (:file)
+       EOF
+       test_cmp expect actual
+'
+
 test_done