summaryrefslogtreecommitdiff
path: root/t/t1450-fsck.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-11-28 16:35:29 -0500
committerJunio C Hamano <gitster@pobox.com>2012-11-28 13:52:54 -0800
commit5c17f51270e1b384e03fb9c16b5a0040b115ae8c (patch)
tree0068fb09ecdb92495d3529d918759e16a943dc3c /t/t1450-fsck.sh
parent5d34a4359d51b44483a1e62dc8a1f6ec686c8b6f (diff)
downloadgit-5c17f51270e1b384e03fb9c16b5a0040b115ae8c.tar.gz
fsck: warn about ".git" in trees
Having a ".git" entry inside a tree can cause confusing results on checkout. At the top-level, you could not checkout such a tree, as it would complain about overwriting the real ".git" directory. In a subdirectory, you might check it out, but performing operations in the subdirectory would confusingly consider the in-tree ".git" directory as the repository. The regular git tools already make it hard to accidentally add such an entry to a tree, and do not allow such entries to enter the index at all. Teaching fsck about it provides an additional safety check, and let's us avoid propagating any such bogosity when transfer.fsckObjects is on. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1450-fsck.sh')
-rwxr-xr-xt/t1450-fsck.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
index 0b5c30b4d9..d730734fde 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -253,4 +253,19 @@ test_expect_success 'fsck notices "." and ".." in trees' '
)
'
+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