Skip to content

Commit a1ca398

Browse files
peffgitster
authored andcommitted
t7450: test verify_path() handling of gitmodules
Commit 10ecfa7 (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 b7b1fca (fsck: complain when .gitmodules is a symlink, 2018-05-04). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43a2220 commit a1ca398

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

t/t7450-bad-git-dotfiles.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ test_expect_success 'index-pack --strict works for non-repo pack' '
139139
grep gitmodulesName output
140140
'
141141

142-
test_expect_success 'fsck detects symlinked .gitmodules file' '
142+
test_expect_success 'set up repo with symlinked .gitmodules file' '
143143
git init symlink &&
144144
(
145145
cd symlink &&
@@ -155,8 +155,14 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
155155
{
156156
printf "100644 blob $content\t$tricky\n" &&
157157
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 &&
160166
161167
# Check not only that we fail, but that it is due to the
162168
# symlink detector
@@ -165,6 +171,13 @@ test_expect_success 'fsck detects symlinked .gitmodules file' '
165171
)
166172
'
167173

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+
168181
test_expect_success 'fsck detects non-blob .gitmodules' '
169182
git init non-blob &&
170183
(

0 commit comments

Comments
 (0)