Skip to content

Commit 463a849

Browse files
moygitster
authored andcommitted
Add and document a global --no-pager option for git.
To keep the change small, this is done by setting GIT_PAGER to "cat". Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Acked-by: Brian Gernhardt <benji@silverinsanity.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2f82f76 commit 463a849

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Documentation/git.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ git - the stupid content tracker
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
12+
'git' [--version] [--exec-path[=GIT_EXEC_PATH]]
13+
[-p|--paginate|--no-pager]
1314
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
1415
[--help] COMMAND [ARGS]
1516

@@ -103,6 +104,9 @@ OPTIONS
103104
-p|--paginate::
104105
Pipe all output into 'less' (or if set, $PAGER).
105106

107+
--no-pager::
108+
Do not pipe git output into a pager.
109+
106110
--git-dir=<path>::
107111
Set the path to the repository. This can also be controlled by
108112
setting the GIT_DIR environment variable.

git.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "quote.h"
55

66
const char git_usage_string[] =
7-
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
7+
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
88

99
static void prepend_to_path(const char *dir, int len)
1010
{
@@ -58,6 +58,10 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
5858
}
5959
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
6060
setup_pager();
61+
} else if (!strcmp(cmd, "--no-pager")) {
62+
setenv("GIT_PAGER", "cat", 1);
63+
if (envchanged)
64+
*envchanged = 1;
6165
} else if (!strcmp(cmd, "--git-dir")) {
6266
if (*argc < 2) {
6367
fprintf(stderr, "No directory given for --git-dir.\n" );

0 commit comments

Comments
 (0)