@@ -16,6 +16,11 @@ test_expect_success 'setup' '
16
16
echo 1 >non/git/b
17
17
'
18
18
19
+ test_expect_success ' git diff --no-index --exit-code' '
20
+ git diff --no-index --exit-code a/1 non/git/a &&
21
+ test_expect_code 1 git diff --no-index --exit-code a/1 a/2
22
+ '
23
+
19
24
test_expect_success ' git diff --no-index directories' '
20
25
test_expect_code 1 git diff --no-index a b >cnt &&
21
26
test_line_count = 14 cnt
@@ -144,4 +149,59 @@ test_expect_success 'diff --no-index allows external diff' '
144
149
test_cmp expect actual
145
150
'
146
151
152
+ test_expect_success ' diff --no-index normalizes mode: no changes' '
153
+ echo foo >x &&
154
+ cp x y &&
155
+ git diff --no-index x y >out &&
156
+ test_must_be_empty out
157
+ '
158
+
159
+ test_expect_success POSIXPERM ' diff --no-index normalizes mode: chmod +x' '
160
+ chmod +x y &&
161
+ cat >expected <<-\EOF &&
162
+ diff --git a/x b/y
163
+ old mode 100644
164
+ new mode 100755
165
+ EOF
166
+ test_expect_code 1 git diff --no-index x y >actual &&
167
+ test_cmp expected actual
168
+ '
169
+
170
+ test_expect_success POSIXPERM ' diff --no-index normalizes: mode not like git mode' '
171
+ chmod 666 x &&
172
+ chmod 777 y &&
173
+ cat >expected <<-\EOF &&
174
+ diff --git a/x b/y
175
+ old mode 100644
176
+ new mode 100755
177
+ EOF
178
+ test_expect_code 1 git diff --no-index x y >actual &&
179
+ test_cmp expected actual
180
+ '
181
+
182
+ test_expect_success POSIXPERM,SYMLINKS ' diff --no-index normalizes: mode not like git mode (symlink)' '
183
+ ln -s y z &&
184
+ X_OID=$(git hash-object --stdin <x) &&
185
+ Z_OID=$(printf y | git hash-object --stdin) &&
186
+ cat >expected <<-EOF &&
187
+ diff --git a/x b/x
188
+ deleted file mode 100644
189
+ index $X_OID..$ZERO_OID
190
+ --- a/x
191
+ +++ /dev/null
192
+ @@ -1 +0,0 @@
193
+ -foo
194
+ diff --git a/z b/z
195
+ new file mode 120000
196
+ index $ZERO_OID..$Z_OID
197
+ --- /dev/null
198
+ +++ b/z
199
+ @@ -0,0 +1 @@
200
+ +y
201
+ \ No newline at end of file
202
+ EOF
203
+ test_expect_code 1 git -c core.abbrev=no diff --no-index x z >actual &&
204
+ test_cmp expected actual
205
+ '
206
+
147
207
test_done
0 commit comments