summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 03276d9)
raw | patch | inline | side by side (parent: 03276d9)
author | Tay Ray Chuan <rctay89@gmail.com> | |
Tue, 23 Nov 2010 03:16:30 +0000 (11:16 +0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 23 Nov 2010 20:17:03 +0000 (12:17 -0800) |
Pass output through the pager if format-patch is run with --stdout. This
saves the user the trouble of running git with '-p' or piping through a
pager.
setup_pager() already checks if stdout is a tty, so we don't have to
worry about behaviour if the user redirects/pipes stdout. Paging can
also be disabled with the config
[pager]
format-patch = false
Add tests to check for these behaviour.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
saves the user the trouble of running git with '-p' or piping through a
pager.
setup_pager() already checks if stdout is a tty, so we don't have to
worry about behaviour if the user redirects/pipes stdout. Paging can
also be disabled with the config
[pager]
format-patch = false
Add tests to check for these behaviour.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c | patch | blob | history | |
t/t4014-format-patch.sh | patch | blob | history |
diff --git a/builtin/log.c b/builtin/log.c
index 22d12903ac06597979f30d0fd94267fc543afa29..f039fe1fd14358f161729a1fb2e89d76359fd858 100644 (file)
--- a/builtin/log.c
+++ b/builtin/log.c
if (!use_stdout)
output_directory = set_outdir(prefix, output_directory);
+ else
+ setup_pager();
if (output_directory) {
if (use_stdout)
index 07bf6eb49dd2879758f64a8c09a0ae8d7e54dd45..027c13d52cd701ba28e3c5e29c5431acfccdad73 100755 (executable)
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
test_description='various format-patch tests'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
test_expect_success setup '
! grep "^-- \$" output
'
+test_expect_success TTY 'format-patch --stdout paginates' '
+ rm -f pager_used &&
+ (
+ GIT_PAGER="wc >pager_used" &&
+ export GIT_PAGER &&
+ test_terminal git format-patch --stdout --all
+ ) &&
+ test_path_is_file pager_used
+'
+
+ test_expect_success TTY 'format-patch --stdout pagination can be disabled' '
+ rm -f pager_used &&
+ (
+ GIT_PAGER="wc >pager_used" &&
+ export GIT_PAGER &&
+ test_terminal git --no-pager format-patch --stdout --all &&
+ test_terminal git -c "pager.format-patch=false" format-patch --stdout --all
+ ) &&
+ test_path_is_missing pager_used &&
+ test_path_is_missing .git/pager_used
+'
+
test_done