summaryrefslogtreecommitdiff
path: root/t/t7006-pager.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2010-11-17 12:04:12 -0500
committerJunio C Hamano <gitster@pobox.com>2010-11-17 11:37:06 -0800
commit9bad7233699e1fcf58e75f1e163499ec24680826 (patch)
treed6e85cf6685d7a3d88c45702a9aead6c6f99f66e /t/t7006-pager.sh
parentb2be2f6aeaa8f4af602679e5571d2e916a259d91 (diff)
downloadgit-9bad7233699e1fcf58e75f1e163499ec24680826.tar.gz
allow command-specific pagers in pager.<cmd>
A user may want different pager settings or even a different pager for various subcommands (e.g., because they use different less settings for "log" vs "diff", or because they have a pager that interprets only log output but not other commands). This patch extends the pager.<cmd> syntax to support not only boolean to-page-or-not-to-page, but also to specify a pager just for a specific command. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7006-pager.sh')
-rwxr-xr-xt/t7006-pager.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index fb744e3c4a..49a6261693 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -435,4 +435,33 @@ test_core_pager_subdir expect_success 'git -p shortlog'
test_core_pager_subdir expect_success test_must_fail \
'git -p apply </dev/null'
+test_expect_success TTY 'command-specific pager' '
+ unset PAGER GIT_PAGER;
+ echo "foo:initial" >expect &&
+ >actual &&
+ git config --unset core.pager &&
+ git config pager.log "sed s/^/foo:/ >actual" &&
+ test_terminal git log --format=%s -1 &&
+ test_cmp expect actual
+'
+
+test_expect_success TTY 'command-specific pager overrides core.pager' '
+ unset PAGER GIT_PAGER;
+ echo "foo:initial" >expect &&
+ >actual &&
+ git config core.pager "exit 1"
+ git config pager.log "sed s/^/foo:/ >actual" &&
+ test_terminal git log --format=%s -1 &&
+ test_cmp expect actual
+'
+
+test_expect_success TTY 'command-specific pager overridden by environment' '
+ GIT_PAGER="sed s/^/foo:/ >actual" && export GIT_PAGER &&
+ >actual &&
+ echo "foo:initial" >expect &&
+ git config pager.log "exit 1" &&
+ test_terminal git log --format=%s -1 &&
+ test_cmp expect actual
+'
+
test_done