{"thread":{"id":"25794","subject":"[PATCH] format-patch: page output with --stdout","startedAt":"2010-11-20T05:05:42Z","lastAt":"2010-11-23T03:16:30Z","messageCount":3,"participants":["Tay Ray Chuan","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"156249","messageId":"1290229542-3116-1-git-send-email-rctay89@gmail.com","threadId":"25794","inReplyTo":null,"subject":"[PATCH] format-patch: page output with --stdout","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-11-20T05:05:42Z","receivedAt":"2010-11-20T05:05:42Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Pass output through the pager if format-patch is run with --stdout. This\nsaves the user the trouble of running git with '-p' or piping through a\npager.\n\nsetup_pager() already checks if stdout is a tty, so we don't have to\nworry about behaviour if the user redirects/pipes stdout.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n builtin/log.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d0297a1..c631950 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1159,6 +1159,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n+\telse\n+\t\tsetup_pager();\n \n \tif (output_directory) {\n \t\tif (use_stdout)\n-- \n1.7.3.2.492.gfc3d1.dirty\n"},{"id":"156330","messageId":"20101122181501.GF2084@burratino","threadId":"25794","inReplyTo":"1290229542-3116-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH] format-patch: page output with --stdout","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-22T18:15:01Z","receivedAt":"2010-11-22T18:15:01Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Tay Ray Chuan wrote:\n\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -1159,6 +1159,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n>  \n>  \tif (!use_stdout)\n>  \t\toutput_directory = set_outdir(prefix, output_directory);\n> +\telse\n> +\t\tsetup_pager();\n\nSince it can be disabled with\n\n\t[pager]\n\t\tformat-patch = false\n\nthis looks reasonable to me.  Maybe a test to that effect would\nhelp, something like this?\n\n test_expect_success TTY 'format-patch --stdout paginates' '\n\trm -f pager_used &&\n\t(\n\t\tGIT_PAGER=\"wc >pager_used\" &&\n\t\texport GIT_PAGER &&\n\t\ttest_terminal git format-patch --stdout --all\n\t) &&\n\ttest_path_is_file pager_used\n '\n\n test_expect_success TTY 'format-patch --stdout pagination can be disabled' '\n\trm -f pager_used &&\n\t(\n\t\tGIT_PAGER=\"wc >pager_used\" &&\n\t\texport GIT_PAGER &&\n\t\ttest_terminal git --no-pager format-patch --stdout --all &&\n\t\ttest_terminal git -c \"pager.format-patch=false\" format-patch --stdout --all\n\t) &&\n\ttest_path_is_missing pager_used &&\n\ttest_path_is_missing .git/pager_used\n '\n"},{"id":"156350","messageId":"1290482190-5932-1-git-send-email-rctay89@gmail.com","threadId":"25794","inReplyTo":"20101122181501.GF2084@burratino","subject":"[PATCH v2] format-patch: page output with --stdout","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-11-23T03:16:30Z","receivedAt":"2010-11-23T03:16:30Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Pass output through the pager if format-patch is run with --stdout. This\nsaves the user the trouble of running git with '-p' or piping through a\npager.\n\nsetup_pager() already checks if stdout is a tty, so we don't have to\nworry about behaviour if the user redirects/pipes stdout. Paging can\nalso be disabled with the config\n\n  [pager]\n      format-patch = false\n\nAdd tests to check for these behaviour.\n\nHelped-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nThanks for the tests, Johnathan.\n\n builtin/log.c           |    2 ++\n t/t4014-format-patch.sh |   23 +++++++++++++++++++++++\n 2 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d0297a1..c631950 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1159,6 +1159,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n+\telse\n+\t\tsetup_pager();\n \n \tif (output_directory) {\n \t\tif (use_stdout)\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 07bf6eb..027c13d 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -6,6 +6,7 @@\n test_description='various format-patch tests'\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-terminal.sh\n \n test_expect_success setup '\n \n@@ -686,4 +687,26 @@ test_expect_success 'format-patch --signature=\"\" supresses signatures' '\n \t! grep \"^-- \\$\" output\n '\n \n+test_expect_success TTY 'format-patch --stdout paginates' '\n+\trm -f pager_used &&\n+\t(\n+\t\tGIT_PAGER=\"wc >pager_used\" &&\n+\t\texport GIT_PAGER &&\n+\t\ttest_terminal git format-patch --stdout --all\n+\t) &&\n+\ttest_path_is_file pager_used\n+'\n+\n+ test_expect_success TTY 'format-patch --stdout pagination can be disabled' '\n+\trm -f pager_used &&\n+\t(\n+\t\tGIT_PAGER=\"wc >pager_used\" &&\n+\t\texport GIT_PAGER &&\n+\t\ttest_terminal git --no-pager format-patch --stdout --all &&\n+\t\ttest_terminal git -c \"pager.format-patch=false\" format-patch --stdout --all\n+\t) &&\n+\ttest_path_is_missing pager_used &&\n+\ttest_path_is_missing .git/pager_used\n+'\n+\n test_done\n-- \n1.7.3.2.487.gd5344.dirty\n"}]}