* [PATCH] format-patch: page output with --stdout
@ 2010-11-20 5:05 Tay Ray Chuan
2010-11-22 18:15 ` Jonathan Nieder
0 siblings, 1 reply; 3+ messages in thread
From: Tay Ray Chuan @ 2010-11-20 5:05 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Jonathan Nieder
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.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
builtin/log.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index d0297a1..c631950 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1159,6 +1159,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!use_stdout)
output_directory = set_outdir(prefix, output_directory);
+ else
+ setup_pager();
if (output_directory) {
if (use_stdout)
--
1.7.3.2.492.gfc3d1.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] format-patch: page output with --stdout
2010-11-20 5:05 [PATCH] format-patch: page output with --stdout Tay Ray Chuan
@ 2010-11-22 18:15 ` Jonathan Nieder
2010-11-23 3:16 ` [PATCH v2] " Tay Ray Chuan
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Nieder @ 2010-11-22 18:15 UTC (permalink / raw)
To: Tay Ray Chuan; +Cc: Git Mailing List, Junio C Hamano
Tay Ray Chuan wrote:
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1159,6 +1159,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>
> if (!use_stdout)
> output_directory = set_outdir(prefix, output_directory);
> + else
> + setup_pager();
Since it can be disabled with
[pager]
format-patch = false
this looks reasonable to me. Maybe a test to that effect would
help, something like this?
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
'
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] format-patch: page output with --stdout
2010-11-22 18:15 ` Jonathan Nieder
@ 2010-11-23 3:16 ` Tay Ray Chuan
0 siblings, 0 replies; 3+ messages in thread
From: Tay Ray Chuan @ 2010-11-23 3:16 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Jonathan Nieder
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>
---
Thanks for the tests, Johnathan.
builtin/log.c | 2 ++
t/t4014-format-patch.sh | 23 +++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index d0297a1..c631950 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1159,6 +1159,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!use_stdout)
output_directory = set_outdir(prefix, output_directory);
+ else
+ setup_pager();
if (output_directory) {
if (use_stdout)
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 07bf6eb..027c13d 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -6,6 +6,7 @@
test_description='various format-patch tests'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
test_expect_success setup '
@@ -686,4 +687,26 @@ test_expect_success 'format-patch --signature="" supresses signatures' '
! 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
--
1.7.3.2.487.gd5344.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-23 3:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-20 5:05 [PATCH] format-patch: page output with --stdout Tay Ray Chuan
2010-11-22 18:15 ` Jonathan Nieder
2010-11-23 3:16 ` [PATCH v2] " Tay Ray Chuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).