3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test diff of symlinks.
10 . "$TEST_DIRECTORY"/diff-lib.sh
12 test_expect_success 'diff new symlink and file' '
13 cat >expected <<-\EOF &&
14 diff --git a/frotz b/frotz
16 index 0000000..7c465af
21 \ No newline at end of file
22 diff --git a/nitfol b/nitfol
24 index 0000000..7c465af
33 tree=$(git write-tree) &&
35 test_ln_s_add xyzzy frotz &&
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
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)"
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
52 index 7c465af..0000000
57 \ No newline at end of file
58 diff --git a/nitfol b/nitfol
59 deleted file mode 100644
60 index 7c465af..0000000
68 git diff-index -M -p $tree >current &&
69 compare_diff_patch expected current
72 test_expect_success 'diff identical, but newly created symlink and file' '
76 test-tool chmtime +10 nitfol &&
77 if test_have_prereq SYMLINKS
82 # the symlink property propagates from the index
84 git diff-index -M -p $tree >current &&
85 compare_diff_patch expected current &&
88 git diff-index -M -p -w $tree >current &&
89 compare_diff_patch expected current
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 \ No newline at end of file
102 \ No newline at end of file
103 diff --git a/nitfol b/nitfol
104 index 7c465af..df1db54 100644
112 if test_have_prereq SYMLINKS
117 # the symlink property propagates from the index
119 echo yxyyz >nitfol &&
120 git diff-index -M -p $tree >current &&
121 compare_diff_patch expected current
124 test_expect_success SYMLINKS 'diff symlinks with non-existing targets' '
126 ln -s take\ over brain &&
127 test_must_fail git diff --no-index pinky brain >output 2>output.err &&
132 test_expect_success SYMLINKS 'setup symlinks with attributes' '
133 echo "*.bin diff=bin" >>.gitattributes &&
134 echo content >file.bin &&
135 ln -s file.bin link.bin &&
136 git add -N file.bin link.bin
139 test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
140 cat >expect <<-\EOF &&
141 diff --git a/file.bin b/file.bin
142 index e69de29..d95f3ad 100644
143 Binary files a/file.bin and b/file.bin differ
144 diff --git a/link.bin b/link.bin
145 index e69de29..dce41ec 120000
150 \ No newline at end of file
152 git config diff.bin.binary true &&
153 git diff file.bin link.bin >actual &&
154 test_cmp expect actual