@matheusbsbs / matheus-bagliano / commits / bce2c9ae9f
Fork 0

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 <pclouds@gmail.com> Improved-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Jun 26, 2010 at 14:25 UTC bce2c9ae9ff458b6090953ab9f639255f757a104
1 file changed +26
t/t7006-pager.sh
+26
@@ -259,6 +259,28 @@ test_core_pager_overrides() {
259 "
260 }
261
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 +
284 test_GIT_PAGER_overrides() {
285 parse_args "$@"
286
@@ -277,21 +299,25 @@ test_GIT_PAGER_overrides() {
299 test_default_pager expect_success 'git log'
300 test_PAGER_overrides expect_success 'git log'
301 test_core_pager_overrides expect_success 'git log'
302 +test_core_pager_subdir expect_success 'git log'
303 test_GIT_PAGER_overrides expect_success 'git log'
304
305 test_default_pager expect_success 'git -p log'
306 test_PAGER_overrides expect_success 'git -p log'
307 test_core_pager_overrides expect_success 'git -p log'
308 +test_core_pager_subdir expect_failure 'git -p log'
309 test_GIT_PAGER_overrides expect_success 'git -p log'
310
311 test_default_pager expect_success test_must_fail 'git -p'
312 test_PAGER_overrides expect_success test_must_fail 'git -p'
313 test_core_pager_overrides expect_success test_must_fail 'git -p'
314 +test_core_pager_subdir expect_failure test_must_fail 'git -p'
315 test_GIT_PAGER_overrides expect_success test_must_fail 'git -p'
316
317 test_default_pager expect_success test_must_fail 'git -p nonsense'
318 test_PAGER_overrides expect_success test_must_fail 'git -p nonsense'
319 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'
321 test_GIT_PAGER_overrides expect_success test_must_fail 'git -p nonsense'
322
323 test_done