t7450: test verify_path() handling of gitmodules
Commit 10ecfa7649 (verify_path: disallow symlinks in .gitmodules, 2018-05-04) made it impossible to load a symlink .gitmodules file into the index. However, there are no tests of this behavior. Let's make sure this case is covered. We can easily reuse the test setup created by the matching b7b1fca175 (fsck: complain when .gitmodules is a symlink, 2018-05-04). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 3, 2021 at 16:43 UTC
a1ca398ba7da82622a9485400f88e62f3b756d1b
1 file changed
+16
-3
t/t7450-bad-git-dotfiles.sh
+16
-3
@@ -139,7 +139,7 @@ test_expect_success 'index-pack --strict works for non-repo pack' '
139
grep gitmodulesName output
140
'
141
142
-test_expect_success 'fsck detects symlinked .gitmodules file' '
142
+test_expect_success 'set up repo with symlinked .gitmodules file' '
143
git init symlink &&
144
(
145
cd symlink &&
@@ -155,8 +155,14 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
155
{
156
printf "100644 blob $content\t$tricky\n" &&
157
printf "120000 blob $target\t.gitmodules\n"
158
- } >bad-tree &&
159
- tree=$(git mktree <bad-tree) &&
158
+ } >bad-tree
159
+ ) &&
160
+ tree=$(git -C symlink mktree <symlink/bad-tree)
161
+'
162
+
163
+test_expect_success 'fsck detects symlinked .gitmodules file' '
164
+ (
165
+ cd symlink &&
166
167
# Check not only that we fail, but that it is due to the
168
# symlink detector
@@ -165,6 +171,13 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
171
)
172
'
173
174
+test_expect_success 'refuse to load symlinked .gitmodules into index' '
175
+ test_must_fail git -C symlink read-tree $tree 2>err &&
176
+ grep "invalid path.*gitmodules" err &&
177
+ git -C symlink ls-files >out &&
178
+ test_must_be_empty out
179
+'
180
+
181
test_expect_success 'fsck detects non-blob .gitmodules' '
182
git init non-blob &&
183
(