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 <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Jun 7, 2013 at 22:53 UTC 70836a6f8b71a945f074fc796c4241c2183b83a2
1 file changed +25 -10
t/t4011-diff-symlink.sh
+25 -10
@@ -9,7 +9,7 @@ test_description='Test diff of symlinks.
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/diff-lib.sh
11
12 -test_expect_success SYMLINKS 'diff new symlink and file' '
12 +test_expect_success 'diff new symlink and file' '
13 cat >expected <<-\EOF &&
14 diff --git a/frotz b/frotz
15 new file mode 120000
@@ -27,22 +27,25 @@ test_expect_success SYMLINKS 'diff new symlink and file' '
27 @@ -0,0 +1 @@
28 +xyzzy
29 EOF
30 - ln -s xyzzy frotz &&
31 - echo xyzzy >nitfol &&
30 +
31 + # the empty tree
32 git update-index &&
33 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 &&
38 GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
39 compare_diff_patch expected current
40 '
41
39 -test_expect_success SYMLINKS 'diff unchanged symlink and file' '
42 +test_expect_success 'diff unchanged symlink and file' '
43 tree=$(git write-tree) &&
44 git update-index frotz nitfol &&
45 test -z "$(git diff-index --name-only $tree)"
46 '
47
45 -test_expect_success SYMLINKS 'diff removed symlink and file' '
48 +test_expect_success 'diff removed symlink and file' '
49 cat >expected <<-\EOF &&
50 diff --git a/frotz b/frotz
51 deleted file mode 120000
@@ -66,12 +69,18 @@ test_expect_success SYMLINKS 'diff removed symlink and file' '
69 compare_diff_patch expected current
70 '
71
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' '
73 >expected &&
74 rm -f frotz nitfol &&
75 echo xyzzy >nitfol &&
76 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 &&
84 git diff-index -M -p $tree >current &&
85 compare_diff_patch expected current &&
86
@@ -80,7 +89,7 @@ test_expect_success SYMLINKS 'diff identical, but newly created symlink and file
89 compare_diff_patch expected current
90 '
91
83 -test_expect_success SYMLINKS 'diff different symlink and file' '
92 +test_expect_success 'diff different symlink and file' '
93 cat >expected <<-\EOF &&
94 diff --git a/frotz b/frotz
95 index 7c465af..df1db54 120000
@@ -100,7 +109,13 @@ test_expect_success SYMLINKS 'diff different symlink and file' '
109 +yxyyz
110 EOF
111 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 &&
119 echo yxyyz >nitfol &&
120 git diff-index -M -p $tree >current &&
121 compare_diff_patch expected current