[PATCH 3/4] tests: local config file should be honored from subdirs of toplevel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Improved-by: Johannes Sixt <j6t@xxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 t/t7006-pager.sh |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 4420f91..2b106be 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -259,6 +259,28 @@ test_core_pager_overrides() {
 	"
 }
 
+test_core_pager_subdir() {
+	parse_args "$@"
+
+	$test_expectation TTY "$cmd - core.pager from subdirectory" "
+		unset GIT_PAGER;
+		rm -f core.pager_used &&
+		rm -fr sub ||
+		cleanup_fail &&
+
+		PAGER=wc &&
+		stampname=\$(pwd)/core.pager_used &&
+		export PAGER stampname &&
+		git config core.pager 'wc >\"\$stampname\"' &&
+		mkdir sub &&
+		(
+			cd sub &&
+			$full_command
+		) &&
+		test -e core.pager_used
+	"
+}
+
 test_GIT_PAGER_overrides() {
 	parse_args "$@"
 
@@ -277,21 +299,25 @@ test_GIT_PAGER_overrides() {
 test_default_pager        expect_success 'git log'
 test_PAGER_overrides      expect_success 'git log'
 test_core_pager_overrides expect_success 'git log'
+test_core_pager_subdir    expect_success 'git log'
 test_GIT_PAGER_overrides  expect_success 'git log'
 
 test_default_pager        expect_success 'git -p log'
 test_PAGER_overrides      expect_success 'git -p log'
 test_core_pager_overrides expect_success 'git -p log'
+test_core_pager_subdir    expect_failure 'git -p log'
 test_GIT_PAGER_overrides  expect_success 'git -p log'
 
 test_default_pager        expect_success test_must_fail 'git -p'
 test_PAGER_overrides      expect_success test_must_fail 'git -p'
 test_core_pager_overrides expect_success test_must_fail 'git -p'
+test_core_pager_subdir    expect_failure test_must_fail 'git -p'
 test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'
 
 test_default_pager        expect_success test_must_fail 'git -p nonsense'
 test_PAGER_overrides      expect_success test_must_fail 'git -p nonsense'
 test_core_pager_overrides expect_success test_must_fail 'git -p nonsense'
+test_core_pager_subdir    expect_failure test_must_fail 'git -p nonsense'
 test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p nonsense'
 
 test_done
-- 
1.7.1.579.ge2549

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]