[PATCH 1/9] t7006: GIT_DIR/config should be honored in 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.

Unfortunately, the --paginate option is handled before git has a
chance to search for a git directory.  The effect is that with
--paginate and only with --paginate, a repository-local core.pager
setting does not take effect [*].

[*] unless the git directory is simply .git in the cwd or GIT_DIR
or GIT_CONFIG was set explicitly.

Add a test to demonstrate this counterintuitive behavior.

Noticed while reading over a patch by Nguyễn Thái Ngọc Duy that
fixes it.

Cc: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
 t/t7006-pager.sh |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index d9202d5..4f804ed 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -164,6 +164,38 @@ test_expect_success TTY 'core.pager overrides PAGER' '
 	test -e core.pager_used
 '
 
+unset GIT_PAGER
+rm -f core.pager_used
+rm -fr sub
+test_expect_success TTY 'core.pager in subdir' '
+	PAGER=wc &&
+	stampname=$(pwd)/core.pager_used &&
+	export PAGER stampname &&
+	git config core.pager "wc > \"\$stampname\"" &&
+	mkdir sub &&
+	(
+		cd sub &&
+		test_terminal git log
+	) &&
+	test -e "$stampname"
+'
+
+unset GIT_PAGER
+rm -f core.pager_used
+rm -fr sub
+test_expect_failure TTY 'core.pager in subdir with --paginate' '
+	PAGER=wc &&
+	stampname=$(pwd)/core.pager_used &&
+	export PAGER stampname &&
+	git config core.pager "wc > \"\$stampname\"" &&
+	mkdir sub &&
+	(
+		cd sub &&
+		test_terminal git --paginate log
+	) &&
+	test -e "$stampname"
+'
+
 rm -f GIT_PAGER_used
 test_expect_success TTY 'GIT_PAGER overrides core.pager' '
 	git config core.pager wc &&
-- 
1.7.0.4

--
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]