@matheusbsbs / matheus-bagliano / commits / 463a849d00
Fork 0

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>

Matthieu Moy committed Aug 19, 2007 at 19:24 UTC 463a849d004b2a3f3c8254b1e7985d4e986b9f1a
2 files changed +10 -2
Documentation/git.txt
+5 -1
@@ -9,7 +9,8 @@ git - the stupid content tracker
9 SYNOPSIS
10 --------
11 [verse]
12 -'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
12 +'git' [--version] [--exec-path[=GIT_EXEC_PATH]]
13 + [-p|--paginate|--no-pager]
14 [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
15 [--help] COMMAND [ARGS]
16
@@ -103,6 +104,9 @@ OPTIONS
104 -p|--paginate::
105 Pipe all output into 'less' (or if set, $PAGER).
106
107 +--no-pager::
108 + Do not pipe git output into a pager.
109 +
110 --git-dir=<path>::
111 Set the path to the repository. This can also be controlled by
112 setting the GIT_DIR environment variable.
git.c
+5 -1
@@ -4,7 +4,7 @@
4 #include "quote.h"
5
6 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]";
8
9 static void prepend_to_path(const char *dir, int len)
10 {
@@ -58,6 +58,10 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
58 }
59 } else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
60 setup_pager();
61 + } else if (!strcmp(cmd, "--no-pager")) {
62 + setenv("GIT_PAGER", "cat", 1);
63 + if (envchanged)
64 + *envchanged = 1;
65 } else if (!strcmp(cmd, "--git-dir")) {
66 if (*argc < 2) {
67 fprintf(stderr, "No directory given for --git-dir.\n" );