3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test diff of symlinks.
10 . "$TEST_DIRECTORY"/diff-lib.sh
12 test_expect_success SYMLINKS '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) &&
34 git update-index --add frotz nitfol &&
35 GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
36 compare_diff_patch expected current
39 test_expect_success SYMLINKS 'diff unchanged symlink and file' '
40 tree=$(git write-tree) &&
41 git update-index frotz nitfol &&
42 test -z "$(git diff-index --name-only $tree)"
45 test_expect_success SYMLINKS 'diff removed symlink and file' '
46 cat >expected <<-\EOF &&
47 diff --git a/frotz b/frotz
48 deleted file mode 120000
49 index 7c465af..0000000
54 \ No newline at end of file
55 diff --git a/nitfol b/nitfol
56 deleted file mode 100644
57 index 7c465af..0000000
65 git diff-index -M -p $tree >current &&
66 compare_diff_patch expected current
69 test_expect_success SYMLINKS 'diff identical, but newly created symlink and file' '
73 test-chmtime +10 nitfol &&
75 git diff-index -M -p $tree >current &&
76 compare_diff_patch expected current &&
79 git diff-index -M -p -w $tree >current &&
80 compare_diff_patch expected current
83 test_expect_success SYMLINKS 'diff different symlink and file' '
84 cat >expected <<-\EOF &&
85 diff --git a/frotz b/frotz
86 index 7c465af..df1db54 120000
91 \ No newline at end of file
93 \ No newline at end of file
94 diff --git a/nitfol b/nitfol
95 index 7c465af..df1db54 100644
104 echo yxyyz >nitfol &&
105 git diff-index -M -p $tree >current &&
106 compare_diff_patch expected current
109 test_expect_success SYMLINKS 'diff symlinks with non-existing targets' '
111 ln -s take\ over brain &&
112 test_must_fail git diff --no-index pinky brain >output 2>output.err &&
117 test_expect_success SYMLINKS 'setup symlinks with attributes' '
118 echo "*.bin diff=bin" >>.gitattributes &&
119 echo content >file.bin &&
120 ln -s file.bin link.bin &&
121 git add -N file.bin link.bin
124 test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
125 cat >expect <<-\EOF &&
126 diff --git a/file.bin b/file.bin
127 index e69de29..d95f3ad 100644
128 Binary files a/file.bin and b/file.bin differ
129 diff --git a/link.bin b/link.bin
130 index e69de29..dce41ec 120000
135 \ No newline at end of file
137 git config diff.bin.binary true &&
138 git diff file.bin link.bin >actual &&
139 test_cmp expect actual