Skip to content

Commit 70836a6

Browse files
j6tgitster
authored andcommitted
t4011: remove SYMLINKS prerequisite
The part of the test that is about symbolic links in the index does not require that the corresponding file system entry is actually a symbolic link. Use test_ln_s_add to insert a symbolic link in the index. When the file system does not support symbolic links, we actually have a regular file in the worktree, which we can update as if it were a symbolic link. diff-index picks up the symbolic link property from the index. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bfd7804 commit 70836a6

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

t/t4011-diff-symlink.sh

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test_description='Test diff of symlinks.
99
. ./test-lib.sh
1010
. "$TEST_DIRECTORY"/diff-lib.sh
1111

12-
test_expect_success SYMLINKS 'diff new symlink and file' '
12+
test_expect_success 'diff new symlink and file' '
1313
cat >expected <<-\EOF &&
1414
diff --git a/frotz b/frotz
1515
new file mode 120000
@@ -27,22 +27,25 @@ test_expect_success SYMLINKS 'diff new symlink and file' '
2727
@@ -0,0 +1 @@
2828
+xyzzy
2929
EOF
30-
ln -s xyzzy frotz &&
31-
echo xyzzy >nitfol &&
30+
31+
# the empty tree
3232
git update-index &&
3333
tree=$(git write-tree) &&
34-
git update-index --add frotz nitfol &&
34+
35+
test_ln_s_add xyzzy frotz &&
36+
echo xyzzy >nitfol &&
37+
git update-index --add nitfol &&
3538
GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
3639
compare_diff_patch expected current
3740
'
3841

39-
test_expect_success SYMLINKS 'diff unchanged symlink and file' '
42+
test_expect_success 'diff unchanged symlink and file' '
4043
tree=$(git write-tree) &&
4144
git update-index frotz nitfol &&
4245
test -z "$(git diff-index --name-only $tree)"
4346
'
4447

45-
test_expect_success SYMLINKS 'diff removed symlink and file' '
48+
test_expect_success 'diff removed symlink and file' '
4649
cat >expected <<-\EOF &&
4750
diff --git a/frotz b/frotz
4851
deleted file mode 120000
@@ -66,12 +69,18 @@ test_expect_success SYMLINKS 'diff removed symlink and file' '
6669
compare_diff_patch expected current
6770
'
6871

69-
test_expect_success SYMLINKS 'diff identical, but newly created symlink and file' '
72+
test_expect_success 'diff identical, but newly created symlink and file' '
7073
>expected &&
7174
rm -f frotz nitfol &&
7275
echo xyzzy >nitfol &&
7376
test-chmtime +10 nitfol &&
74-
ln -s xyzzy frotz &&
77+
if test_have_prereq SYMLINKS
78+
then
79+
ln -s xyzzy frotz
80+
else
81+
printf xyzzy >frotz
82+
# the symlink property propagates from the index
83+
fi &&
7584
git diff-index -M -p $tree >current &&
7685
compare_diff_patch expected current &&
7786
@@ -80,7 +89,7 @@ test_expect_success SYMLINKS 'diff identical, but newly created symlink and file
8089
compare_diff_patch expected current
8190
'
8291

83-
test_expect_success SYMLINKS 'diff different symlink and file' '
92+
test_expect_success 'diff different symlink and file' '
8493
cat >expected <<-\EOF &&
8594
diff --git a/frotz b/frotz
8695
index 7c465af..df1db54 120000
@@ -100,7 +109,13 @@ test_expect_success SYMLINKS 'diff different symlink and file' '
100109
+yxyyz
101110
EOF
102111
rm -f frotz &&
103-
ln -s yxyyz frotz &&
112+
if test_have_prereq SYMLINKS
113+
then
114+
ln -s yxyyz frotz
115+
else
116+
printf yxyyz >frotz
117+
# the symlink property propagates from the index
118+
fi &&
104119
echo yxyyz >nitfol &&
105120
git diff-index -M -p $tree >current &&
106121
compare_diff_patch expected current

0 commit comments

Comments
 (0)