]>
Commit | Line | Data |
---|---|---|
60b6e220 JN |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test automatic use of a pager.' | |
4 | ||
5 | . ./test-lib.sh | |
678e484b | 6 | . "$TEST_DIRECTORY"/lib-pager.sh |
cc4e48fc | 7 | . "$TEST_DIRECTORY"/lib-terminal.sh |
60b6e220 | 8 | |
60b6e220 | 9 | test_expect_success 'setup' ' |
00648ba0 | 10 | sane_unset GIT_PAGER GIT_PAGER_IN_USE && |
8d68a6d5 | 11 | test_unconfig core.pager && |
fdf1bc48 JN |
12 | |
13 | PAGER="cat >paginated.out" && | |
14 | export PAGER && | |
15 | ||
60b6e220 JN |
16 | test_commit initial |
17 | ' | |
18 | ||
60b6e220 | 19 | test_expect_success TTY 'some commands use a pager' ' |
0d164519 | 20 | rm -f paginated.out && |
2d3ca216 | 21 | test_terminal git log && |
60b6e220 JN |
22 | test -e paginated.out |
23 | ' | |
24 | ||
2cb60093 NTND |
25 | test_expect_failure TTY 'pager runs from subdir' ' |
26 | echo subdir/paginated.out >expected && | |
27 | mkdir -p subdir && | |
28 | rm -f paginated.out subdir/paginated.out && | |
29 | ( | |
30 | cd subdir && | |
31 | test_terminal git log | |
32 | ) && | |
33 | { | |
34 | ls paginated.out subdir/paginated.out || | |
35 | : | |
36 | } >actual && | |
37 | test_cmp expected actual | |
38 | ' | |
39 | ||
e54c1f2d JN |
40 | test_expect_success TTY 'LESS and LV envvars are set for pagination' ' |
41 | ( | |
42 | sane_unset LESS LV && | |
52c02f65 | 43 | PAGER="env >pager-env.out; wc" && |
e54c1f2d JN |
44 | export PAGER && |
45 | ||
46 | test_terminal git log | |
47 | ) && | |
48 | grep ^LESS= pager-env.out && | |
49 | grep ^LV= pager-env.out | |
50 | ' | |
51 | ||
995bc22d EW |
52 | test_expect_success !MINGW,TTY 'LESS and LV envvars set by git-sh-setup' ' |
53 | ( | |
54 | sane_unset LESS LV && | |
55 | PAGER="env >pager-env.out; wc" && | |
56 | export PAGER && | |
57 | PATH="$(git --exec-path):$PATH" && | |
58 | export PATH && | |
59 | test_terminal sh -c ". git-sh-setup && git_pager" | |
60 | ) && | |
61 | grep ^LESS= pager-env.out && | |
62 | grep ^LV= pager-env.out | |
63 | ' | |
64 | ||
60b6e220 | 65 | test_expect_success TTY 'some commands do not use a pager' ' |
0d164519 | 66 | rm -f paginated.out && |
2d3ca216 | 67 | test_terminal git rev-list HEAD && |
60b6e220 JN |
68 | ! test -e paginated.out |
69 | ' | |
70 | ||
60b6e220 | 71 | test_expect_success 'no pager when stdout is a pipe' ' |
0d164519 | 72 | rm -f paginated.out && |
60b6e220 JN |
73 | git log | cat && |
74 | ! test -e paginated.out | |
75 | ' | |
76 | ||
60b6e220 | 77 | test_expect_success 'no pager when stdout is a regular file' ' |
0d164519 | 78 | rm -f paginated.out && |
fdf1bc48 | 79 | git log >file && |
60b6e220 JN |
80 | ! test -e paginated.out |
81 | ' | |
82 | ||
60b6e220 | 83 | test_expect_success TTY 'git --paginate rev-list uses a pager' ' |
0d164519 | 84 | rm -f paginated.out && |
2d3ca216 | 85 | test_terminal git --paginate rev-list HEAD && |
60b6e220 JN |
86 | test -e paginated.out |
87 | ' | |
88 | ||
60b6e220 | 89 | test_expect_success 'no pager even with --paginate when stdout is a pipe' ' |
0d164519 | 90 | rm -f file paginated.out && |
60b6e220 JN |
91 | git --paginate log | cat && |
92 | ! test -e paginated.out | |
93 | ' | |
94 | ||
60b6e220 | 95 | test_expect_success TTY 'no pager with --no-pager' ' |
0d164519 | 96 | rm -f paginated.out && |
2d3ca216 | 97 | test_terminal git --no-pager log && |
60b6e220 JN |
98 | ! test -e paginated.out |
99 | ' | |
100 | ||
ff38d1a9 NTND |
101 | test_expect_success TTY 'configuration can disable pager' ' |
102 | rm -f paginated.out && | |
8d68a6d5 | 103 | test_unconfig pager.grep && |
ff38d1a9 NTND |
104 | test_terminal git grep initial && |
105 | test -e paginated.out && | |
106 | ||
107 | rm -f paginated.out && | |
8d68a6d5 | 108 | test_config pager.grep false && |
ff38d1a9 NTND |
109 | test_terminal git grep initial && |
110 | ! test -e paginated.out | |
111 | ' | |
112 | ||
41bf3bc2 | 113 | test_expect_success TTY 'git config uses a pager if configured to' ' |
3ba7e6e2 | 114 | rm -f paginated.out && |
8d68a6d5 | 115 | test_config pager.config true && |
3ba7e6e2 NTND |
116 | test_terminal git config --list && |
117 | test -e paginated.out | |
118 | ' | |
119 | ||
41bf3bc2 | 120 | test_expect_success TTY 'configuration can enable pager (from subdir)' ' |
2cb60093 NTND |
121 | rm -f paginated.out && |
122 | mkdir -p subdir && | |
8d68a6d5 | 123 | test_config pager.bundle true && |
2cb60093 NTND |
124 | |
125 | git bundle create test.bundle --all && | |
126 | rm -f paginated.out subdir/paginated.out && | |
127 | ( | |
128 | cd subdir && | |
129 | test_terminal git bundle unbundle ../test.bundle | |
130 | ) && | |
131 | { | |
132 | test -e paginated.out || | |
133 | test -e subdir/paginated.out | |
134 | } | |
135 | ' | |
136 | ||
ff1e7248 | 137 | test_expect_success TTY 'git tag -l defaults to paging' ' |
b3ee740c MÅ |
138 | rm -f paginated.out && |
139 | test_terminal git tag -l && | |
ff1e7248 | 140 | test -e paginated.out |
b3ee740c MÅ |
141 | ' |
142 | ||
143 | test_expect_success TTY 'git tag -l respects pager.tag' ' | |
144 | rm -f paginated.out && | |
ff1e7248 MÅ |
145 | test_terminal git -c pager.tag=false tag -l && |
146 | ! test -e paginated.out | |
b3ee740c MÅ |
147 | ' |
148 | ||
149 | test_expect_success TTY 'git tag -l respects --no-pager' ' | |
150 | rm -f paginated.out && | |
151 | test_terminal git -c pager.tag --no-pager tag -l && | |
152 | ! test -e paginated.out | |
153 | ' | |
154 | ||
ff1e7248 | 155 | test_expect_success TTY 'git tag with no args defaults to paging' ' |
b3ee740c MÅ |
156 | # no args implies -l so this should page like -l |
157 | rm -f paginated.out && | |
158 | test_terminal git tag && | |
ff1e7248 | 159 | test -e paginated.out |
b3ee740c MÅ |
160 | ' |
161 | ||
162 | test_expect_success TTY 'git tag with no args respects pager.tag' ' | |
163 | # no args implies -l so this should page like -l | |
164 | rm -f paginated.out && | |
ff1e7248 MÅ |
165 | test_terminal git -c pager.tag=false tag && |
166 | ! test -e paginated.out | |
b3ee740c MÅ |
167 | ' |
168 | ||
ff1e7248 | 169 | test_expect_success TTY 'git tag --contains defaults to paging' ' |
b3ee740c MÅ |
170 | # --contains implies -l so this should page like -l |
171 | rm -f paginated.out && | |
172 | test_terminal git tag --contains && | |
ff1e7248 | 173 | test -e paginated.out |
b3ee740c MÅ |
174 | ' |
175 | ||
176 | test_expect_success TTY 'git tag --contains respects pager.tag' ' | |
177 | # --contains implies -l so this should page like -l | |
178 | rm -f paginated.out && | |
ff1e7248 MÅ |
179 | test_terminal git -c pager.tag=false tag --contains && |
180 | ! test -e paginated.out | |
b3ee740c MÅ |
181 | ' |
182 | ||
183 | test_expect_success TTY 'git tag -a defaults to not paging' ' | |
184 | test_when_finished "git tag -d newtag" && | |
185 | rm -f paginated.out && | |
186 | test_terminal git tag -am message newtag && | |
187 | ! test -e paginated.out | |
188 | ' | |
189 | ||
de121ffe | 190 | test_expect_success TTY 'git tag -a ignores pager.tag' ' |
b3ee740c MÅ |
191 | test_when_finished "git tag -d newtag" && |
192 | rm -f paginated.out && | |
193 | test_terminal git -c pager.tag tag -am message newtag && | |
194 | ! test -e paginated.out | |
195 | ' | |
196 | ||
197 | test_expect_success TTY 'git tag -a respects --paginate' ' | |
198 | test_when_finished "git tag -d newtag" && | |
199 | rm -f paginated.out && | |
200 | test_terminal git --paginate tag -am message newtag && | |
201 | test -e paginated.out | |
202 | ' | |
203 | ||
595d59e2 | 204 | test_expect_success TTY 'git tag as alias ignores pager.tag with -a' ' |
de121ffe MÅ |
205 | test_when_finished "git tag -d newtag" && |
206 | rm -f paginated.out && | |
207 | test_terminal git -c pager.tag -c alias.t=tag t -am message newtag && | |
208 | ! test -e paginated.out | |
209 | ' | |
210 | ||
211 | test_expect_success TTY 'git tag as alias respects pager.tag with -l' ' | |
212 | rm -f paginated.out && | |
ff1e7248 MÅ |
213 | test_terminal git -c pager.tag=false -c alias.t=tag t -l && |
214 | ! test -e paginated.out | |
de121ffe MÅ |
215 | ' |
216 | ||
60b6e220 JN |
217 | # A colored commit log will begin with an appropriate ANSI escape |
218 | # for the first color; the text "commit" comes later. | |
219 | colorful() { | |
fdf1bc48 | 220 | read firstline <$1 |
e0ae1e6f | 221 | ! expr "$firstline" : "[a-zA-Z]" >/dev/null |
60b6e220 JN |
222 | } |
223 | ||
60b6e220 | 224 | test_expect_success 'tests can detect color' ' |
0d164519 | 225 | rm -f colorful.log colorless.log && |
fdf1bc48 JN |
226 | git log --no-color >colorless.log && |
227 | git log --color >colorful.log && | |
60b6e220 JN |
228 | ! colorful colorless.log && |
229 | colorful colorful.log | |
230 | ' | |
231 | ||
60b6e220 | 232 | test_expect_success 'no color when stdout is a regular file' ' |
fdf1bc48 | 233 | rm -f colorless.log && |
0d164519 | 234 | test_config color.ui auto && |
fdf1bc48 | 235 | git log >colorless.log && |
60b6e220 JN |
236 | ! colorful colorless.log |
237 | ' | |
238 | ||
60b6e220 | 239 | test_expect_success TTY 'color when writing to a pager' ' |
fdf1bc48 | 240 | rm -f paginated.out && |
0d164519 | 241 | test_config color.ui auto && |
512477b1 | 242 | test_terminal env TERM=vt100 git log && |
60b6e220 JN |
243 | colorful paginated.out |
244 | ' | |
245 | ||
daa0c3d9 JK |
246 | test_expect_success TTY 'colors are suppressed by color.pager' ' |
247 | rm -f paginated.out && | |
248 | test_config color.ui auto && | |
249 | test_config color.pager false && | |
512477b1 | 250 | test_terminal env TERM=vt100 git log && |
daa0c3d9 JK |
251 | ! colorful paginated.out |
252 | ' | |
253 | ||
60b6e220 | 254 | test_expect_success 'color when writing to a file intended for a pager' ' |
fdf1bc48 | 255 | rm -f colorful.log && |
0d164519 | 256 | test_config color.ui auto && |
fdf1bc48 JN |
257 | ( |
258 | TERM=vt100 && | |
259 | GIT_PAGER_IN_USE=true && | |
260 | export TERM GIT_PAGER_IN_USE && | |
261 | git log >colorful.log | |
262 | ) && | |
60b6e220 JN |
263 | colorful colorful.log |
264 | ' | |
265 | ||
2e6c012e JK |
266 | test_expect_success TTY 'colors are sent to pager for external commands' ' |
267 | test_config alias.externallog "!git log" && | |
268 | test_config color.ui auto && | |
512477b1 | 269 | test_terminal env TERM=vt100 git -p externallog && |
2e6c012e JK |
270 | colorful paginated.out |
271 | ' | |
272 | ||
3c7406d4 JN |
273 | # Use this helper to make it easy for the caller of your |
274 | # terminal-using function to specify whether it should fail. | |
275 | # If you write | |
276 | # | |
277 | # your_test() { | |
278 | # parse_args "$@" | |
279 | # | |
280 | # $test_expectation "$cmd - behaves well" " | |
281 | # ... | |
282 | # $full_command && | |
283 | # ... | |
284 | # " | |
285 | # } | |
286 | # | |
287 | # then your test can be used like this: | |
288 | # | |
289 | # your_test expect_(success|failure) [test_must_fail] 'git foo' | |
290 | # | |
291 | parse_args() { | |
292 | test_expectation="test_$1" | |
293 | shift | |
294 | if test "$1" = test_must_fail | |
295 | then | |
296 | full_command="test_must_fail test_terminal " | |
297 | shift | |
298 | else | |
299 | full_command="test_terminal " | |
300 | fi | |
301 | cmd=$1 | |
302 | full_command="$full_command $1" | |
303 | } | |
fdf1bc48 | 304 | |
8f81449e JN |
305 | test_default_pager() { |
306 | parse_args "$@" | |
307 | ||
996621eb | 308 | $test_expectation SIMPLEPAGER,TTY "$cmd - default pager is used by default" " |
00648ba0 | 309 | sane_unset PAGER GIT_PAGER && |
8d68a6d5 | 310 | test_unconfig core.pager && |
0d164519 | 311 | rm -f default_pager_used && |
8f81449e JN |
312 | cat >\$less <<-\EOF && |
313 | #!/bin/sh | |
314 | wc >default_pager_used | |
315 | EOF | |
316 | chmod +x \$less && | |
317 | ( | |
318 | PATH=.:\$PATH && | |
319 | export PATH && | |
320 | $full_command | |
321 | ) && | |
322 | test -e default_pager_used | |
323 | " | |
324 | } | |
60b6e220 | 325 | |
8f81449e JN |
326 | test_PAGER_overrides() { |
327 | parse_args "$@" | |
fdf1bc48 | 328 | |
8f81449e | 329 | $test_expectation TTY "$cmd - PAGER overrides default pager" " |
00648ba0 | 330 | sane_unset GIT_PAGER && |
8d68a6d5 | 331 | test_unconfig core.pager && |
0d164519 | 332 | rm -f PAGER_used && |
8f81449e JN |
333 | PAGER='wc >PAGER_used' && |
334 | export PAGER && | |
335 | $full_command && | |
336 | test -e PAGER_used | |
337 | " | |
338 | } | |
fdf1bc48 | 339 | |
8f81449e | 340 | test_core_pager_overrides() { |
73e25e7c NTND |
341 | if_local_config= |
342 | used_if_wanted='overrides PAGER' | |
343 | test_core_pager "$@" | |
344 | } | |
60b6e220 | 345 | |
73e25e7c NTND |
346 | test_local_config_ignored() { |
347 | if_local_config='! ' | |
348 | used_if_wanted='is not used' | |
349 | test_core_pager "$@" | |
350 | } | |
fdf1bc48 | 351 | |
73e25e7c | 352 | test_core_pager() { |
8f81449e JN |
353 | parse_args "$@" |
354 | ||
73e25e7c | 355 | $test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" " |
00648ba0 | 356 | sane_unset GIT_PAGER && |
0d164519 | 357 | rm -f core.pager_used && |
8f81449e JN |
358 | PAGER=wc && |
359 | export PAGER && | |
8d68a6d5 | 360 | test_config core.pager 'wc >core.pager_used' && |
8f81449e | 361 | $full_command && |
73e25e7c | 362 | ${if_local_config}test -e core.pager_used |
8f81449e JN |
363 | " |
364 | } | |
365 | ||
bce2c9ae | 366 | test_core_pager_subdir() { |
73e25e7c NTND |
367 | if_local_config= |
368 | used_if_wanted='overrides PAGER' | |
369 | test_pager_subdir_helper "$@" | |
370 | } | |
371 | ||
372 | test_no_local_config_subdir() { | |
373 | if_local_config='! ' | |
374 | used_if_wanted='is not used' | |
375 | test_pager_subdir_helper "$@" | |
376 | } | |
377 | ||
378 | test_pager_subdir_helper() { | |
bce2c9ae JN |
379 | parse_args "$@" |
380 | ||
73e25e7c | 381 | $test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" " |
00648ba0 | 382 | sane_unset GIT_PAGER && |
bce2c9ae | 383 | rm -f core.pager_used && |
0d164519 | 384 | rm -fr sub && |
bce2c9ae JN |
385 | PAGER=wc && |
386 | stampname=\$(pwd)/core.pager_used && | |
387 | export PAGER stampname && | |
8d68a6d5 | 388 | test_config core.pager 'wc >\"\$stampname\"' && |
bce2c9ae JN |
389 | mkdir sub && |
390 | ( | |
391 | cd sub && | |
392 | $full_command | |
393 | ) && | |
73e25e7c | 394 | ${if_local_config}test -e core.pager_used |
bce2c9ae JN |
395 | " |
396 | } | |
397 | ||
8f81449e JN |
398 | test_GIT_PAGER_overrides() { |
399 | parse_args "$@" | |
400 | ||
401 | $test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" " | |
0d164519 | 402 | rm -f GIT_PAGER_used && |
8d68a6d5 | 403 | test_config core.pager wc && |
8f81449e JN |
404 | GIT_PAGER='wc >GIT_PAGER_used' && |
405 | export GIT_PAGER && | |
406 | $full_command && | |
407 | test -e GIT_PAGER_used | |
408 | " | |
409 | } | |
fdf1bc48 | 410 | |
73e25e7c NTND |
411 | test_doesnt_paginate() { |
412 | parse_args "$@" | |
413 | ||
414 | $test_expectation TTY "no pager for '$cmd'" " | |
0d164519 | 415 | rm -f GIT_PAGER_used && |
73e25e7c NTND |
416 | GIT_PAGER='wc >GIT_PAGER_used' && |
417 | export GIT_PAGER && | |
418 | $full_command && | |
419 | ! test -e GIT_PAGER_used | |
420 | " | |
421 | } | |
422 | ||
030149a4 JN |
423 | test_pager_choices() { |
424 | test_default_pager expect_success "$@" | |
425 | test_PAGER_overrides expect_success "$@" | |
426 | test_core_pager_overrides expect_success "$@" | |
427 | test_core_pager_subdir expect_success "$@" | |
428 | test_GIT_PAGER_overrides expect_success "$@" | |
429 | } | |
430 | ||
431 | test_expect_success 'setup: some aliases' ' | |
432 | git config alias.aliasedlog log && | |
433 | git config alias.true "!true" | |
60b6e220 JN |
434 | ' |
435 | ||
030149a4 JN |
436 | test_pager_choices 'git log' |
437 | test_pager_choices 'git -p log' | |
438 | test_pager_choices 'git aliasedlog' | |
439 | ||
440 | test_default_pager expect_success 'git -p aliasedlog' | |
441 | test_PAGER_overrides expect_success 'git -p aliasedlog' | |
442 | test_core_pager_overrides expect_success 'git -p aliasedlog' | |
1a27409a | 443 | test_core_pager_subdir expect_success 'git -p aliasedlog' |
030149a4 JN |
444 | test_GIT_PAGER_overrides expect_success 'git -p aliasedlog' |
445 | ||
446 | test_default_pager expect_success 'git -p true' | |
447 | test_PAGER_overrides expect_success 'git -p true' | |
448 | test_core_pager_overrides expect_success 'git -p true' | |
1a27409a | 449 | test_core_pager_subdir expect_success 'git -p true' |
030149a4 JN |
450 | test_GIT_PAGER_overrides expect_success 'git -p true' |
451 | ||
452 | test_default_pager expect_success test_must_fail 'git -p request-pull' | |
453 | test_PAGER_overrides expect_success test_must_fail 'git -p request-pull' | |
454 | test_core_pager_overrides expect_success test_must_fail 'git -p request-pull' | |
1a27409a | 455 | test_core_pager_subdir expect_success test_must_fail 'git -p request-pull' |
030149a4 | 456 | test_GIT_PAGER_overrides expect_success test_must_fail 'git -p request-pull' |
8f81449e JN |
457 | |
458 | test_default_pager expect_success test_must_fail 'git -p' | |
459 | test_PAGER_overrides expect_success test_must_fail 'git -p' | |
73e25e7c | 460 | test_local_config_ignored expect_failure test_must_fail 'git -p' |
8f81449e JN |
461 | test_GIT_PAGER_overrides expect_success test_must_fail 'git -p' |
462 | ||
1a27409a | 463 | test_expect_success TTY 'core.pager in repo config works and retains cwd' ' |
551d535d JS |
464 | sane_unset GIT_PAGER && |
465 | test_config core.pager "cat >cwd-retained" && | |
466 | ( | |
467 | cd sub && | |
468 | rm -f cwd-retained && | |
469 | test_terminal git -p rev-parse HEAD && | |
470 | test_path_is_file cwd-retained | |
471 | ) | |
472 | ' | |
473 | ||
a9bcf658 | 474 | test_expect_success TTY 'core.pager is found via alias in subdirectory' ' |
3f9c5dfb JS |
475 | sane_unset GIT_PAGER && |
476 | test_config core.pager "cat >via-alias" && | |
477 | ( | |
478 | cd sub && | |
479 | rm -f via-alias && | |
480 | test_terminal git -c alias.r="-p rev-parse" r HEAD && | |
481 | test_path_is_file via-alias | |
482 | ) | |
483 | ' | |
484 | ||
030149a4 | 485 | test_doesnt_paginate expect_failure test_must_fail 'git -p nonsense' |
60b6e220 | 486 | |
773b69bf NTND |
487 | test_pager_choices 'git shortlog' |
488 | test_expect_success 'setup: configure shortlog not to paginate' ' | |
489 | git config pager.shortlog false | |
490 | ' | |
491 | test_doesnt_paginate expect_success 'git shortlog' | |
492 | test_no_local_config_subdir expect_success 'git shortlog' | |
493 | test_default_pager expect_success 'git -p shortlog' | |
494 | test_core_pager_subdir expect_success 'git -p shortlog' | |
495 | ||
d1ea8962 NTND |
496 | test_core_pager_subdir expect_success test_must_fail \ |
497 | 'git -p apply </dev/null' | |
498 | ||
9bad7233 | 499 | test_expect_success TTY 'command-specific pager' ' |
212ad944 | 500 | sane_unset PAGER GIT_PAGER && |
9bad7233 JK |
501 | echo "foo:initial" >expect && |
502 | >actual && | |
8d68a6d5 JK |
503 | test_unconfig core.pager && |
504 | test_config pager.log "sed s/^/foo:/ >actual" && | |
9bad7233 JK |
505 | test_terminal git log --format=%s -1 && |
506 | test_cmp expect actual | |
507 | ' | |
508 | ||
509 | test_expect_success TTY 'command-specific pager overrides core.pager' ' | |
212ad944 | 510 | sane_unset PAGER GIT_PAGER && |
9bad7233 JK |
511 | echo "foo:initial" >expect && |
512 | >actual && | |
99094a7a | 513 | test_config core.pager "exit 1" && |
8d68a6d5 | 514 | test_config pager.log "sed s/^/foo:/ >actual" && |
9bad7233 JK |
515 | test_terminal git log --format=%s -1 && |
516 | test_cmp expect actual | |
517 | ' | |
518 | ||
519 | test_expect_success TTY 'command-specific pager overridden by environment' ' | |
520 | GIT_PAGER="sed s/^/foo:/ >actual" && export GIT_PAGER && | |
521 | >actual && | |
522 | echo "foo:initial" >expect && | |
8d68a6d5 | 523 | test_config pager.log "exit 1" && |
9bad7233 JK |
524 | test_terminal git log --format=%s -1 && |
525 | test_cmp expect actual | |
526 | ' | |
527 | ||
92058e4d JK |
528 | test_expect_success 'setup external command' ' |
529 | cat >git-external <<-\EOF && | |
530 | #!/bin/sh | |
531 | git "$@" | |
532 | EOF | |
533 | chmod +x git-external | |
534 | ' | |
535 | ||
536 | test_expect_success TTY 'command-specific pager works for external commands' ' | |
537 | sane_unset PAGER GIT_PAGER && | |
538 | echo "foo:initial" >expect && | |
539 | >actual && | |
540 | test_config pager.external "sed s/^/foo:/ >actual" && | |
90ae5d27 | 541 | test_terminal git --exec-path="$(pwd)" external log --format=%s -1 && |
92058e4d JK |
542 | test_cmp expect actual |
543 | ' | |
544 | ||
545 | test_expect_success TTY 'sub-commands of externals use their own pager' ' | |
546 | sane_unset PAGER GIT_PAGER && | |
547 | echo "foo:initial" >expect && | |
548 | >actual && | |
549 | test_config pager.log "sed s/^/foo:/ >actual" && | |
550 | test_terminal git --exec-path=. external log --format=%s -1 && | |
551 | test_cmp expect actual | |
552 | ' | |
553 | ||
554 | test_expect_success TTY 'external command pagers override sub-commands' ' | |
555 | sane_unset PAGER GIT_PAGER && | |
556 | >expect && | |
557 | >actual && | |
558 | test_config pager.external false && | |
559 | test_config pager.log "sed s/^/log:/ >actual" && | |
560 | test_terminal git --exec-path=. external log --format=%s -1 && | |
561 | test_cmp expect actual | |
562 | ' | |
563 | ||
9e9de18f JK |
564 | test_expect_success 'command with underscores does not complain' ' |
565 | write_script git-under_score <<-\EOF && | |
566 | echo ok | |
567 | EOF | |
568 | git --exec-path=. under_score >actual 2>&1 && | |
569 | echo ok >expect && | |
570 | test_cmp expect actual | |
571 | ' | |
572 | ||
60b6e220 | 573 | test_done |