aboutsummaryrefslogtreecommitdiff
path: root/t/t0614-reftable-fsck.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t0614-reftable-fsck.sh')
-rwxr-xr-xt/t0614-reftable-fsck.sh46
1 files changed, 45 insertions, 1 deletions
diff --git a/t/t0614-reftable-fsck.sh b/t/t0614-reftable-fsck.sh
index 85cc47d67e..d24b87f961 100755
--- a/t/t0614-reftable-fsck.sh
+++ b/t/t0614-reftable-fsck.sh
@@ -20,7 +20,7 @@ test_expect_success "no errors reported on a well formed repository" '
done &&
# The repository should end up with multiple tables.
- test_line_count ">" 1 .git/reftable/tables.list &&
+ test_line_count -gt 1 .git/reftable/tables.list &&
git refs verify 2>err &&
test_must_be_empty err
@@ -55,4 +55,48 @@ for TABLE_NAME in "foo-bar-e4d12d59.ref" \
'
done
+test_expect_success 'worktree stacks can be verified' '
+ test_when_finished "rm -rf repo worktree" &&
+ git init repo &&
+ test_commit -C repo initial &&
+ git -C repo worktree add ../worktree &&
+
+ git -C worktree refs verify 2>err &&
+ test_must_be_empty err &&
+
+ REFTABLE_DIR=$(git -C worktree rev-parse --git-dir)/reftable &&
+ EXISTING_TABLE=$(head -n1 "$REFTABLE_DIR/tables.list") &&
+ mv "$REFTABLE_DIR/$EXISTING_TABLE" "$REFTABLE_DIR/broken.ref" &&
+
+ for d in repo worktree
+ do
+ echo "broken.ref" >"$REFTABLE_DIR/tables.list" &&
+ git -C "$d" refs verify 2>err &&
+ cat >expect <<-EOF &&
+ warning: broken.ref: badReftableTableName: invalid reftable table name
+ EOF
+ test_cmp expect err &&
+
+ echo garbage >"$REFTABLE_DIR/tables.list" &&
+ test_must_fail git -C "$d" refs verify 2>err &&
+ cat >expect <<-EOF &&
+ error: reftable stack for worktree ${SQ}worktree${SQ} is broken
+ EOF
+ test_cmp expect err || return 1
+
+ done
+'
+
+test_expect_success 'invalid symref gets reported' '
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+ test_commit -C repo initial &&
+ git -C repo symbolic-ref refs/heads/symref garbage &&
+ test_must_fail git -C repo refs verify 2>err &&
+ cat >expect <<-EOF &&
+ error: refs/heads/symref: badReferentName: points to invalid refname ${SQ}garbage${SQ}
+ EOF
+ test_cmp expect err
+'
+
test_done