[PATCH 11/10] support pager.* for aliases

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

 



Until this patch, doing something like:

  git config alias.foo log
  git config pager.foo /some/specific/pager

would not respect pager.foo at all. With this patch, we
will use pager.foo for the "foo" alias.  We will also
fallback to pager.log if "foo" is a non-shell alias that
uses the "log" command (but any pager.foo overrides
pager.log).

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 git.c            |    3 +++
 t/t7006-pager.sh |   31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/git.c b/git.c
index 8828c18..375e9b2 100644
--- a/git.c
+++ b/git.c
@@ -180,6 +180,9 @@ static int handle_alias(int *argcp, const char ***argv)
 	alias_command = (*argv)[0];
 	alias_string = alias_lookup(alias_command);
 	if (alias_string) {
+		if (use_pager == -1)
+			use_pager = check_pager_config(alias_command);
+
 		if (alias_string[0] == '!') {
 			const char **alias_argv;
 			int argc = *argcp, i;
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 4582336..a8c6e85 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -450,4 +450,35 @@ test_expect_success TTY 'command-specific pager overridden by environment' '
 	test_cmp expect actual
 '
 
+test_expect_success TTY 'command-specific pager works for aliases' '
+	sane_unset PAGER GIT_PAGER &&
+	echo "foo:initial" >expect &&
+	>actual &&
+	test_config alias.aliaslog "log --format=%s" &&
+	test_config pager.aliaslog "sed s/^/foo:/ >actual" &&
+	test_terminal git aliaslog -1 &&
+	test_cmp expect actual
+'
+
+test_expect_success TTY 'non-shell alias falls back to command pager config' '
+	sane_unset PAGER GIT_PAGER &&
+	echo "foo:initial" >expect &&
+	>actual &&
+	test_config alias.aliaslog "log --format=%s" &&
+	test_config pager.log "sed s/^/foo:/ >actual" &&
+	test_terminal git aliaslog -1 &&
+	test_cmp expect actual
+'
+
+test_expect_success TTY 'alias-specific pager can override aliased command' '
+	sane_unset PAGER GIT_PAGER &&
+	>expect &&
+	>actual &&
+	test_config alias.aliaslog "log --format=%s" &&
+	test_config pager.log "sed s/^/log:/ >actual" &&
+	test_config pager.aliaslog false &&
+	test_terminal git aliaslog -1 &&
+	test_cmp expect actual
+'
+
 test_done
-- 
1.7.6.10.g62f04

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