From 38a94bb6bae683ba5a92969e63f1d3f2cbf41ac0 Mon Sep 17 00:00:00 2001
From: Tay Ray Chuan <rctay89@gmail.com>
Date: Tue, 23 Nov 2010 11:16:30 +0800
Subject: format-patch: page output with --stdout

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>
---
 builtin/log.c | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'builtin/log.c')

diff --git a/builtin/log.c b/builtin/log.c
index 22d12903a..f039fe1fd 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)
-- 
cgit v1.2.1