@@ -204,62 +204,94 @@ parse_args() {
204
204
full_command=" $full_command $1 "
205
205
}
206
206
207
- parse_args expect_success ' git log'
208
- $test_expectation SIMPLEPAGER " $cmd - default pager is used by default" "
209
- unset PAGER GIT_PAGER;
210
- test_might_fail git config --unset core.pager &&
211
- rm -f default_pager_used ||
212
- cleanup_fail &&
207
+ test_default_pager () {
208
+ parse_args " $@ "
209
+
210
+ $test_expectation SIMPLEPAGER " $cmd - default pager is used by default" "
211
+ unset PAGER GIT_PAGER;
212
+ test_might_fail git config --unset core.pager &&
213
+ rm -f default_pager_used ||
214
+ cleanup_fail &&
215
+
216
+ cat >\$ less <<-\EOF &&
217
+ #!/bin/sh
218
+ wc >default_pager_used
219
+ EOF
220
+ chmod +x \$ less &&
221
+ (
222
+ PATH=.:\$ PATH &&
223
+ export PATH &&
224
+ $full_command
225
+ ) &&
226
+ test -e default_pager_used
227
+ "
228
+ }
213
229
214
- cat >\$ less <<-\EOF &&
215
- #!/bin/sh
216
- wc >default_pager_used
217
- EOF
218
- chmod +x \$ less &&
219
- (
220
- PATH=.:\$ PATH &&
221
- export PATH &&
222
- $full_command
223
- ) &&
224
- test -e default_pager_used
225
- "
230
+ test_PAGER_overrides () {
231
+ parse_args " $@ "
226
232
227
- parse_args expect_success ' git log'
228
- $test_expectation TTY " $cmd - PAGER overrides default pager" "
229
- unset GIT_PAGER;
230
- test_might_fail git config --unset core.pager &&
231
- rm -f PAGER_used ||
232
- cleanup_fail &&
233
+ $test_expectation TTY " $cmd - PAGER overrides default pager" "
234
+ unset GIT_PAGER;
235
+ test_might_fail git config --unset core.pager &&
236
+ rm -f PAGER_used ||
237
+ cleanup_fail &&
233
238
234
- PAGER='wc >PAGER_used' &&
235
- export PAGER &&
236
- $full_command &&
237
- test -e PAGER_used
238
- "
239
-
240
- parse_args expect_success ' git log'
241
- $test_expectation TTY " $cmd - core.pager overrides PAGER" "
242
- unset GIT_PAGER;
243
- rm -f core.pager_used ||
244
- cleanup_fail &&
239
+ PAGER='wc >PAGER_used' &&
240
+ export PAGER &&
241
+ $full_command &&
242
+ test -e PAGER_used
243
+ "
244
+ }
245
245
246
- PAGER=wc &&
247
- export PAGER &&
248
- git config core.pager 'wc >core.pager_used' &&
249
- $full_command &&
250
- test -e core.pager_used
251
- "
252
-
253
- parse_args expect_success ' git log'
254
- $test_expectation TTY " $cmd - GIT_PAGER overrides core.pager" "
255
- rm -f GIT_PAGER_used ||
256
- cleanup_fail &&
246
+ test_core_pager_overrides () {
247
+ parse_args " $@ "
248
+
249
+ $test_expectation TTY " $cmd - core.pager overrides PAGER" "
250
+ unset GIT_PAGER;
251
+ rm -f core.pager_used ||
252
+ cleanup_fail &&
253
+
254
+ PAGER=wc &&
255
+ export PAGER &&
256
+ git config core.pager 'wc >core.pager_used' &&
257
+ $full_command &&
258
+ test -e core.pager_used
259
+ "
260
+ }
261
+
262
+ test_GIT_PAGER_overrides () {
263
+ parse_args " $@ "
264
+
265
+ $test_expectation TTY " $cmd - GIT_PAGER overrides core.pager" "
266
+ rm -f GIT_PAGER_used ||
267
+ cleanup_fail &&
268
+
269
+ git config core.pager wc &&
270
+ GIT_PAGER='wc >GIT_PAGER_used' &&
271
+ export GIT_PAGER &&
272
+ $full_command &&
273
+ test -e GIT_PAGER_used
274
+ "
275
+ }
257
276
258
- git config core.pager wc &&
259
- GIT_PAGER='wc >GIT_PAGER_used' &&
260
- export GIT_PAGER &&
261
- $full_command &&
262
- test -e GIT_PAGER_used
263
- "
277
+ test_default_pager expect_success ' git log'
278
+ test_PAGER_overrides expect_success ' git log'
279
+ test_core_pager_overrides expect_success ' git log'
280
+ test_GIT_PAGER_overrides expect_success ' git log'
281
+
282
+ test_default_pager expect_success ' git -p log'
283
+ test_PAGER_overrides expect_success ' git -p log'
284
+ test_core_pager_overrides expect_success ' git -p log'
285
+ test_GIT_PAGER_overrides expect_success ' git -p log'
286
+
287
+ test_default_pager expect_success test_must_fail ' git -p'
288
+ test_PAGER_overrides expect_success test_must_fail ' git -p'
289
+ test_core_pager_overrides expect_success test_must_fail ' git -p'
290
+ test_GIT_PAGER_overrides expect_success test_must_fail ' git -p'
291
+
292
+ test_default_pager expect_success test_must_fail ' git -p nonsense'
293
+ test_PAGER_overrides expect_success test_must_fail ' git -p nonsense'
294
+ test_core_pager_overrides expect_success test_must_fail ' git -p nonsense'
295
+ test_GIT_PAGER_overrides expect_success test_must_fail ' git -p nonsense'
264
296
265
297
test_done
0 commit comments