@@ -9,85 +9,81 @@ test_description='Test diff of symlinks.
99. ./test-lib.sh
1010. " $TEST_DIRECTORY " /diff-lib.sh
1111
12- cat > expected << EOF
13- diff --git a/frotz b/frotz
14- new file mode 120000
15- index 0000000..7c465af
16- --- /dev/null
17- +++ b/frotz
18- @@ -0,0 +1 @@
19- +xyzzy
20- \ No newline at end of file
21- EOF
22-
23- test_expect_success SYMLINKS \
24- ' diff new symlink' \
25- ' ln -s xyzzy frotz &&
26- git update-index &&
27- tree=$(git write-tree) &&
28- git update-index --add frotz &&
29- GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current &&
30- compare_diff_patch current expected'
31-
32- test_expect_success SYMLINKS \
33- ' diff unchanged symlink' \
34- ' tree=$(git write-tree) &&
35- git update-index frotz &&
36- test -z "$(git diff-index --name-only $tree)"'
37-
38- cat > expected << EOF
39- diff --git a/frotz b/frotz
40- deleted file mode 120000
41- index 7c465af..0000000
42- --- a/frotz
43- +++ /dev/null
44- @@ -1 +0,0 @@
45- -xyzzy
46- \ No newline at end of file
47- EOF
48-
49- test_expect_success SYMLINKS \
50- ' diff removed symlink' \
51- ' mv frotz frotz2 &&
52- git diff-index -M -p $tree > current &&
53- compare_diff_patch current expected'
12+ test_expect_success SYMLINKS ' diff new symlink' '
13+ cat >expected <<-\EOF &&
14+ diff --git a/frotz b/frotz
15+ new file mode 120000
16+ index 0000000..7c465af
17+ --- /dev/null
18+ +++ b/frotz
19+ @@ -0,0 +1 @@
20+ +xyzzy
21+ \ No newline at end of file
22+ EOF
23+ ln -s xyzzy frotz &&
24+ git update-index &&
25+ tree=$(git write-tree) &&
26+ git update-index --add frotz &&
27+ GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
28+ compare_diff_patch expected current
29+ '
5430
55- cat > expected << EOF
56- diff --git a/frotz b/frotz
57- EOF
31+ test_expect_success SYMLINKS ' diff unchanged symlink' '
32+ tree=$(git write-tree) &&
33+ git update-index frotz &&
34+ test -z "$(git diff-index --name-only $tree)"
35+ '
5836
59- test_expect_success SYMLINKS \
60- ' diff identical, but newly created symlink' \
61- ' ln -s xyzzy frotz &&
62- git diff-index -M -p $tree > current &&
63- compare_diff_patch current expected'
37+ test_expect_success SYMLINKS ' diff removed symlink' '
38+ cat >expected <<-\EOF &&
39+ diff --git a/frotz b/frotz
40+ deleted file mode 120000
41+ index 7c465af..0000000
42+ --- a/frotz
43+ +++ /dev/null
44+ @@ -1 +0,0 @@
45+ -xyzzy
46+ \ No newline at end of file
47+ EOF
48+ mv frotz frotz2 &&
49+ git diff-index -M -p $tree >current &&
50+ compare_diff_patch expected current
51+ '
6452
65- cat > expected << EOF
66- diff --git a/frotz b/frotz
67- index 7c465af..df1db54 120000
68- --- a/frotz
69- +++ b/frotz
70- @@ -1 +1 @@
71- -xyzzy
72- \ No newline at end of file
73- +yxyyz
74- \ No newline at end of file
75- EOF
53+ test_expect_success SYMLINKS ' diff identical, but newly created symlink' '
54+ cat >expected <<-\EOF &&
55+ diff --git a/frotz b/frotz
56+ EOF
57+ ln -s xyzzy frotz &&
58+ git diff-index -M -p $tree >current &&
59+ compare_diff_patch expected current
60+ '
7661
77- test_expect_success SYMLINKS \
78- ' diff different symlink' \
79- ' rm frotz &&
80- ln -s yxyyz frotz &&
81- git diff-index -M -p $tree > current &&
82- compare_diff_patch current expected'
62+ test_expect_success SYMLINKS ' diff different symlink' '
63+ cat >expected <<-\EOF &&
64+ diff --git a/frotz b/frotz
65+ index 7c465af..df1db54 120000
66+ --- a/frotz
67+ +++ b/frotz
68+ @@ -1 +1 @@
69+ -xyzzy
70+ \ No newline at end of file
71+ +yxyyz
72+ \ No newline at end of file
73+ EOF
74+ rm -f frotz &&
75+ ln -s yxyyz frotz &&
76+ git diff-index -M -p $tree >current &&
77+ compare_diff_patch expected current
78+ '
8379
84- test_expect_success SYMLINKS \
85- ' diff symlinks with non-existing targets ' \
86- ' ln -s narf pinky &&
87- ln -s take\ over brain &&
88- test_must_fail git diff --no-index pinky brain > output 2> output.err &&
89- grep narf output &&
90- ! grep error output.err '
80+ test_expect_success SYMLINKS ' diff symlinks with non-existing targets ' '
81+ ln -s narf pinky &&
82+ ln -s take\ over brain &&
83+ test_must_fail git diff --no-index pinky brain >output 2>output.err &&
84+ grep narf output &&
85+ ! test -s output.err
86+ '
9187
9288test_expect_success SYMLINKS ' setup symlinks with attributes' '
9389 echo "*.bin diff=bin" >>.gitattributes &&
@@ -96,19 +92,19 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
9692 git add -N file.bin link.bin
9793'
9894
99- cat > expect << 'EOF '
100- diff --git a/file.bin b/file.bin
101- index e69de29..d95f3ad 100644
102- Binary files a/file.bin and b/file.bin differ
103- diff --git a/link.bin b/link.bin
104- index e69de29..dce41ec 120000
105- --- a/link.bin
106- +++ b/link.bin
107- @@ -0,0 +1 @@
108- +file.bin
109- \ No newline at end of file
110- EOF
11195test_expect_success SYMLINKS ' symlinks do not respect userdiff config by path' '
96+ cat >expect <<-\EOF &&
97+ diff --git a/file.bin b/file.bin
98+ index e69de29..d95f3ad 100644
99+ Binary files a/file.bin and b/file.bin differ
100+ diff --git a/link.bin b/link.bin
101+ index e69de29..dce41ec 120000
102+ --- a/link.bin
103+ +++ b/link.bin
104+ @@ -0,0 +1 @@
105+ +file.bin
106+ \ No newline at end of file
107+ EOF
112108 git config diff.bin.binary true &&
113109 git diff file.bin link.bin >actual &&
114110 test_cmp expect actual
0 commit comments