@@ -9,19 +9,32 @@ test_description='Test diff of symlinks.
9
9
. ./test-lib.sh
10
10
. " $TEST_DIRECTORY " /diff-lib.sh
11
11
12
+ # Print the short OID of a symlink with the given name.
13
+ symlink_oid () {
14
+ local oid=$( printf " %s" " $1 " | git hash-object --stdin) &&
15
+ git rev-parse --short " $oid "
16
+ }
17
+
18
+ # Print the short OID of the given file.
19
+ short_oid () {
20
+ local oid=$( git hash-object " $1 " ) &&
21
+ git rev-parse --short " $oid "
22
+ }
23
+
12
24
test_expect_success ' diff new symlink and file' '
13
- cat >expected <<-\EOF &&
25
+ symlink=$(symlink_oid xyzzy) &&
26
+ cat >expected <<-EOF &&
14
27
diff --git a/frotz b/frotz
15
28
new file mode 120000
16
- index 0000000..7c465af
29
+ index 0000000..$symlink
17
30
--- /dev/null
18
31
+++ b/frotz
19
32
@@ -0,0 +1 @@
20
33
+xyzzy
21
34
\ No newline at end of file
22
35
diff --git a/nitfol b/nitfol
23
36
new file mode 100644
24
- index 0000000..7c465af
37
+ index 0000000..$symlink
25
38
--- /dev/null
26
39
+++ b/nitfol
27
40
@@ -0,0 +1 @@
@@ -46,18 +59,18 @@ test_expect_success 'diff unchanged symlink and file' '
46
59
'
47
60
48
61
test_expect_success ' diff removed symlink and file' '
49
- cat >expected <<-\ EOF &&
62
+ cat >expected <<-EOF &&
50
63
diff --git a/frotz b/frotz
51
64
deleted file mode 120000
52
- index 7c465af ..0000000
65
+ index $symlink ..0000000
53
66
--- a/frotz
54
67
+++ /dev/null
55
68
@@ -1 +0,0 @@
56
69
-xyzzy
57
70
\ No newline at end of file
58
71
diff --git a/nitfol b/nitfol
59
72
deleted file mode 100644
60
- index 7c465af ..0000000
73
+ index $symlink ..0000000
61
74
--- a/nitfol
62
75
+++ /dev/null
63
76
@@ -1 +0,0 @@
@@ -90,9 +103,10 @@ test_expect_success 'diff identical, but newly created symlink and file' '
90
103
'
91
104
92
105
test_expect_success ' diff different symlink and file' '
93
- cat >expected <<-\EOF &&
106
+ new=$(symlink_oid yxyyz) &&
107
+ cat >expected <<-EOF &&
94
108
diff --git a/frotz b/frotz
95
- index 7c465af..df1db54 120000
109
+ index $symlink..$new 120000
96
110
--- a/frotz
97
111
+++ b/frotz
98
112
@@ -1 +1 @@
@@ -101,7 +115,7 @@ test_expect_success 'diff different symlink and file' '
101
115
+yxyyz
102
116
\ No newline at end of file
103
117
diff --git a/nitfol b/nitfol
104
- index 7c465af..df1db54 100644
118
+ index $symlink..$new 100644
105
119
--- a/nitfol
106
120
+++ b/nitfol
107
121
@@ -1 +1 @@
@@ -137,14 +151,16 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
137
151
'
138
152
139
153
test_expect_success SYMLINKS ' symlinks do not respect userdiff config by path' '
140
- cat >expect <<-\EOF &&
154
+ file=$(short_oid file.bin) &&
155
+ link=$(symlink_oid file.bin) &&
156
+ cat >expect <<-EOF &&
141
157
diff --git a/file.bin b/file.bin
142
158
new file mode 100644
143
- index 0000000..d95f3ad
159
+ index 0000000..$file
144
160
Binary files /dev/null and b/file.bin differ
145
161
diff --git a/link.bin b/link.bin
146
162
new file mode 120000
147
- index 0000000..dce41ec
163
+ index 0000000..$link
148
164
--- /dev/null
149
165
+++ b/link.bin
150
166
@@ -0,0 +1 @@
0 commit comments