All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH] Replace git --paginate by git --pager[=PAGER_CMD].
Date: Tue, 21 Aug 2007 10:37:08 +0200	[thread overview]
Message-ID: <11876854283229-git-send-email-Matthieu.Moy@imag.fr> (raw)
In-Reply-To: <fadhkv$amj$2@sea.gmane.org>

The previous one was -p|--paginate, but doesn't accept a natural
negation. This patch changes it to -p|--pager|--pager=PAGER_CMD, which
makes the negation --no-pager more natural, and provides a simple way to
override the pager command (git --pager=CMD is equivalent to
GIT_PAGER=CMD git with most shells).

--paginate is kept as a backward-compatibility, deprecated option.

Suggested-by: David Kastrup <dak@gnu.org>
Idea-acked-by: Jakub Narebski <jnareb@gmail.com>

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 Documentation/git.txt |    8 +++++---
 git.c                 |   16 ++++++++++++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 3b0d530..444823d 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git' [--version] [--exec-path[=GIT_EXEC_PATH]]
-    [-p|--paginate|--no-pager]
+    [-p|--pager[=PAGER_CMD]|--no-pager]
     [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
     [--help] COMMAND [ARGS]
 
@@ -101,8 +101,10 @@ OPTIONS
 	environment variable. If no path is given 'git' will print
 	the current setting and then exit.
 
--p|--paginate::
-	Pipe all output into 'less' (or if set, $PAGER).
+-p|--pager[=PAGER_CMD]::
+	Pipe all output into 'less' (or if set, PAGER_CMD,
+	`$GIT_PAGER`, or `$PAGER`, in this order of preference).
+	--paginate is provided as a deprecated alias for -p.
 
 --no-pager::
 	Do not pipe git output into a pager.
diff --git a/git.c b/git.c
index c46691e..4c626b5 100644
--- a/git.c
+++ b/git.c
@@ -4,7 +4,9 @@
 #include "quote.h"
 
 const char git_usage_string[] =
-	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate|--no-pager] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]]\n"
+        "	[-p|--pager[=PAGER_CMD]|--no-pager] [--bare]\n"
+        "	[--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS]";
 
 static void prepend_to_path(const char *dir, int len)
 {
@@ -56,8 +58,18 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
 				puts(git_exec_path());
 				exit(0);
 			}
-		} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
+		} else if (!strcmp(cmd, "-p") || 
+                           /* 
+                            * Deprecated, but kept for backward
+                            * compatibility
+                            */
+                           !strcmp(cmd, "--paginate")) {
 			setup_pager();
+                } else if (!prefixcmp(cmd, "--pager")) {
+			cmd += 7;
+			if (*cmd == '=')
+				setenv("GIT_PAGER", cmd+1, 1);
+                        setup_pager();
 		} else if (!strcmp(cmd, "--no-pager")) {
 			setenv("GIT_PAGER", "cat", 1);
 			if (envchanged)
-- 
1.5.3.rc5.17.g1cd0d-dirty

  reply	other threads:[~2007-08-21  8:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-19 17:26 [RFC] Clean way to disable pager Matthieu Moy
2007-08-19 17:41 ` Matthieu Moy
2007-08-19 17:52 ` Linus Torvalds
2007-08-19 18:24 ` Brian Gernhardt
2007-08-19 18:52 ` Junio C Hamano
2007-08-19 19:44   ` Matthieu Moy
2007-08-19 21:59     ` Adam Roben
2007-08-19 22:37       ` David Kastrup
2007-08-20  8:15         ` Matthieu Moy
2007-08-21  2:11           ` Jakub Narebski
2007-08-21  8:37             ` Matthieu Moy [this message]
2007-08-21  8:42               ` [PATCH] Replace git --paginate by git --pager[=PAGER_CMD] Johannes Schindelin
2007-08-21  8:51                 ` Matthieu Moy
2007-08-21  9:19                   ` David Kastrup
2007-08-19 21:28 ` [RFC] Clean way to disable pager Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11876854283229-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.