@@ -24,16 +24,12 @@ test_expect_success setup '
24
24
'
25
25
26
26
test_expect_success ' GIT_EXTERNAL_DIFF environment' '
27
-
28
- GIT_EXTERNAL_DIFF=echo git diff | {
29
- read path oldfile oldhex oldmode newfile newhex newmode &&
30
- test "z$path" = zfile &&
31
- test "z$oldmode" = z100644 &&
32
- test "z$newhex" = "z$ZERO_OID" &&
33
- test "z$newmode" = z100644 &&
34
- oh=$(git rev-parse --verify HEAD:file) &&
35
- test "z$oh" = "z$oldhex"
36
- }
27
+ cat >expect <<-EOF &&
28
+ file $(git rev-parse --verify HEAD:file) 100644 file $(test_oid zero) 100644
29
+ EOF
30
+ GIT_EXTERNAL_DIFF=echo git diff >out &&
31
+ cut -d" " -f1,3- <out >actual &&
32
+ test_cmp expect actual
37
33
38
34
'
39
35
@@ -52,15 +48,14 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' '
52
48
test_expect_success SYMLINKS ' typechange diff' '
53
49
rm -f file &&
54
50
ln -s elif file &&
55
- GIT_EXTERNAL_DIFF=echo git diff | {
56
- read path oldfile oldhex oldmode newfile newhex newmode &&
57
- test "z$path" = zfile &&
58
- test "z$oldmode" = z100644 &&
59
- test "z$newhex" = "z$ZERO_OID" &&
60
- test "z$newmode" = z120000 &&
61
- oh=$(git rev-parse --verify HEAD:file) &&
62
- test "z$oh" = "z$oldhex"
63
- } &&
51
+
52
+ cat >expect <<-EOF &&
53
+ file $(git rev-parse --verify HEAD:file) 100644 $(test_oid zero) 120000
54
+ EOF
55
+ GIT_EXTERNAL_DIFF=echo git diff >out &&
56
+ cut -d" " -f1,3-4,6- <out >actual &&
57
+ test_cmp expect actual &&
58
+
64
59
GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff >actual &&
65
60
git diff >expect &&
66
61
test_cmp expect actual
@@ -70,15 +65,13 @@ test_expect_success 'diff.external' '
70
65
git reset --hard &&
71
66
echo third >file &&
72
67
test_config diff.external echo &&
73
- git diff | {
74
- read path oldfile oldhex oldmode newfile newhex newmode &&
75
- test "z$path" = zfile &&
76
- test "z$oldmode" = z100644 &&
77
- test "z$newhex" = "z$ZERO_OID" &&
78
- test "z$newmode" = z100644 &&
79
- oh=$(git rev-parse --verify HEAD:file) &&
80
- test "z$oh" = "z$oldhex"
81
- }
68
+
69
+ cat >expect <<-EOF &&
70
+ file $(git rev-parse --verify HEAD:file) 100644 $(test_oid zero) 100644
71
+ EOF
72
+ git diff >out &&
73
+ cut -d" " -f1,3-4,6- <out >actual &&
74
+ test_cmp expect actual
82
75
'
83
76
84
77
test_expect_success ! SANITIZE_LEAK ' diff.external should apply only to diff' '
@@ -101,16 +94,12 @@ test_expect_success 'diff attribute' '
101
94
102
95
echo >.gitattributes "file diff=parrot" &&
103
96
104
- git diff | {
105
- read path oldfile oldhex oldmode newfile newhex newmode &&
106
- test "z$path" = zfile &&
107
- test "z$oldmode" = z100644 &&
108
- test "z$newhex" = "z$ZERO_OID" &&
109
- test "z$newmode" = z100644 &&
110
- oh=$(git rev-parse --verify HEAD:file) &&
111
- test "z$oh" = "z$oldhex"
112
- }
113
-
97
+ cat >expect <<-EOF &&
98
+ file $(git rev-parse --verify HEAD:file) 100644 $(test_oid zero) 100644
99
+ EOF
100
+ git diff >out &&
101
+ cut -d" " -f1,3-4,6- <out >actual &&
102
+ test_cmp expect actual
114
103
'
115
104
116
105
test_expect_success ! SANITIZE_LEAK ' diff attribute should apply only to diff' '
@@ -132,16 +121,12 @@ test_expect_success 'diff attribute' '
132
121
133
122
echo >.gitattributes "file diff=color" &&
134
123
135
- git diff | {
136
- read path oldfile oldhex oldmode newfile newhex newmode &&
137
- test "z$path" = zfile &&
138
- test "z$oldmode" = z100644 &&
139
- test "z$newhex" = "z$ZERO_OID" &&
140
- test "z$newmode" = z100644 &&
141
- oh=$(git rev-parse --verify HEAD:file) &&
142
- test "z$oh" = "z$oldhex"
143
- }
144
-
124
+ cat >expect <<-EOF &&
125
+ file $(git rev-parse --verify HEAD:file) 100644 $(test_oid zero) 100644
126
+ EOF
127
+ git diff >out &&
128
+ cut -d" " -f1,3-4,6- <out >actual &&
129
+ test_cmp expect actual
145
130
'
146
131
147
132
test_expect_success ! SANITIZE_LEAK ' diff attribute should apply only to diff' '
@@ -159,14 +144,26 @@ test_expect_success 'diff attribute and --no-ext-diff' '
159
144
test_expect_success ' GIT_EXTERNAL_DIFF trumps diff.external' '
160
145
>.gitattributes &&
161
146
test_config diff.external "echo ext-global" &&
162
- GIT_EXTERNAL_DIFF="echo ext-env" git diff | grep ext-env
147
+
148
+ cat >expect <<-EOF &&
149
+ ext-env file $(git rev-parse --verify HEAD:file) 100644 file $(test_oid zero) 100644
150
+ EOF
151
+ GIT_EXTERNAL_DIFF="echo ext-env" git diff >out &&
152
+ cut -d" " -f1-2,4- <out >actual &&
153
+ test_cmp expect actual
163
154
'
164
155
165
156
test_expect_success ' attributes trump GIT_EXTERNAL_DIFF and diff.external' '
166
157
test_config diff.foo.command "echo ext-attribute" &&
167
158
test_config diff.external "echo ext-global" &&
168
159
echo "file diff=foo" >.gitattributes &&
169
- GIT_EXTERNAL_DIFF="echo ext-env" git diff | grep ext-attribute
160
+
161
+ cat >expect <<-EOF &&
162
+ ext-attribute file $(git rev-parse --verify HEAD:file) 100644 file $(test_oid zero) 100644
163
+ EOF
164
+ GIT_EXTERNAL_DIFF="echo ext-env" git diff >out &&
165
+ cut -d" " -f1-2,4- <out >actual &&
166
+ test_cmp expect actual
170
167
'
171
168
172
169
test_expect_success ' no diff with -diff' '
@@ -212,7 +209,12 @@ test_expect_success 'GIT_EXTERNAL_DIFF generates pretty paths' '
212
209
touch file.ext &&
213
210
git add file.ext &&
214
211
echo with extension > file.ext &&
215
- GIT_EXTERNAL_DIFF=echo git diff file.ext | grep ......_file\.ext &&
212
+
213
+ cat >expect <<-EOF &&
214
+ file.ext file $(git rev-parse --verify HEAD:file) 100644 file.ext $(test_oid zero) 100644
215
+ EOF
216
+ GIT_EXTERNAL_DIFF=echo git diff file.ext >out &&
217
+ cut -d" " -f1,3- <out >actual &&
216
218
git update-index --force-remove file.ext &&
217
219
rm file.ext
218
220
'
0 commit comments