Skip to content

Commit bce2c9a

Browse files
jrngitster
authored andcommitted
tests: local config file should be honored from subdirs of toplevel
When git is passed the --paginate option, starting up a pager requires deciding what pager to start, which requires access to the core.pager configuration. If --paginate is handled before searching for the git dir, this configuration will be missed. In other words, with --paginate and only with --paginate, any repository-local core.pager setting is being ignored [*]. [*] unless the git directory is ./.git or GIT_DIR or GIT_CONFIG was set explicitly. Add a test to demonstrate this counterintuitive behavior. Noticed while reading over a patch by Duy that fixes it. Cc: Nguyễn Thái Ngọc Duy <[email protected]> Improved-by: Johannes Sixt <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8f81449 commit bce2c9a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

t/t7006-pager.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,28 @@ test_core_pager_overrides() {
259259
"
260260
}
261261

262+
test_core_pager_subdir() {
263+
parse_args "$@"
264+
265+
$test_expectation TTY "$cmd - core.pager from subdirectory" "
266+
unset GIT_PAGER;
267+
rm -f core.pager_used &&
268+
rm -fr sub ||
269+
cleanup_fail &&
270+
271+
PAGER=wc &&
272+
stampname=\$(pwd)/core.pager_used &&
273+
export PAGER stampname &&
274+
git config core.pager 'wc >\"\$stampname\"' &&
275+
mkdir sub &&
276+
(
277+
cd sub &&
278+
$full_command
279+
) &&
280+
test -e core.pager_used
281+
"
282+
}
283+
262284
test_GIT_PAGER_overrides() {
263285
parse_args "$@"
264286

@@ -277,21 +299,25 @@ test_GIT_PAGER_overrides() {
277299
test_default_pager expect_success 'git log'
278300
test_PAGER_overrides expect_success 'git log'
279301
test_core_pager_overrides expect_success 'git log'
302+
test_core_pager_subdir expect_success 'git log'
280303
test_GIT_PAGER_overrides expect_success 'git log'
281304

282305
test_default_pager expect_success 'git -p log'
283306
test_PAGER_overrides expect_success 'git -p log'
284307
test_core_pager_overrides expect_success 'git -p log'
308+
test_core_pager_subdir expect_failure 'git -p log'
285309
test_GIT_PAGER_overrides expect_success 'git -p log'
286310

287311
test_default_pager expect_success test_must_fail 'git -p'
288312
test_PAGER_overrides expect_success test_must_fail 'git -p'
289313
test_core_pager_overrides expect_success test_must_fail 'git -p'
314+
test_core_pager_subdir expect_failure test_must_fail 'git -p'
290315
test_GIT_PAGER_overrides expect_success test_must_fail 'git -p'
291316

292317
test_default_pager expect_success test_must_fail 'git -p nonsense'
293318
test_PAGER_overrides expect_success test_must_fail 'git -p nonsense'
294319
test_core_pager_overrides expect_success test_must_fail 'git -p nonsense'
320+
test_core_pager_subdir expect_failure test_must_fail 'git -p nonsense'
295321
test_GIT_PAGER_overrides expect_success test_must_fail 'git -p nonsense'
296322

297323
test_done

0 commit comments

Comments
 (0)