From: Jeff King <peff@peff.net>
To: Kevin Ballard <kevin@sb.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: To page or not to page
Date: Fri, 2 May 2008 11:36:28 -0400 [thread overview]
Message-ID: <20080502153628.GA6294@sigill.intra.peff.net> (raw)
In-Reply-To: <20080502060930.GA1079@sigill.intra.peff.net>
On Fri, May 02, 2008 at 02:09:30AM -0400, Jeff King wrote:
> > I agree with you; I don't like it at all. Probably whether or not to use
> > a pager for a given command should be controlled by a "pager.<cmd>"
> > config variable.
>
> Here is a quick and dirty patch to do that. It should probably be split
> into two (there is a big code movement of the commands array), and it
> needs documentation and tests. But I'm going to sleep for now.
Here is a cleaner patch. Rather than looking at all of pager.*, it waits
until we see which command to execute, and just looks up pager.cmd (we
end up having to parse the config the same number of times). And we
don't have to munge the static global commands array, which just feels a
little cleaner.
Still no documentation, and still not a "real" patch; I am curious to
see the list reaction on the issues I raised elsewhere in the thread
(like the user-facing inconsistencies).
---
git.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/git.c b/git.c
index 89b431f..68d8b37 100644
--- a/git.c
+++ b/git.c
@@ -230,6 +230,25 @@ struct cmd_struct {
int option;
};
+static const char *pager_command_key;
+static int pager_command_value;
+
+int pager_command_config(const char *var, const char *value)
+{
+ if (!prefixcmp(var, "pager.") && !strcmp(var + 6, pager_command_key))
+ pager_command_value = git_config_bool(var, value);
+ return 0;
+}
+
+/* returns 0 for "no pager", 1 for "use pager", and -1 for "not specified" */
+int check_pager_config(const char *cmd)
+{
+ pager_command_key = cmd;
+ pager_command_value = -1;
+ git_config(pager_command_config);
+ return pager_command_value;
+}
+
static int run_command(struct cmd_struct *p, int argc, const char **argv)
{
int status;
@@ -239,8 +258,17 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
prefix = NULL;
if (p->option & RUN_SETUP)
prefix = setup_git_directory();
- if (p->option & USE_PAGER)
+ switch (check_pager_config(p->cmd)) {
+ case 0:
+ break;
+ case 1:
setup_pager();
+ break;
+ default:
+ if (p->option & USE_PAGER)
+ setup_pager();
+ break;
+ }
if (p->option & NEED_WORK_TREE)
setup_work_tree();
--
1.5.5.1.221.ga481.dirty
prev parent reply other threads:[~2008-05-02 15:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-02 5:41 To page or not to page Kevin Ballard
2008-05-02 5:45 ` Jeff King
2008-05-02 5:56 ` Junio C Hamano
2008-05-02 6:04 ` Kevin Ballard
2008-05-02 6:08 ` Junio C Hamano
2008-05-02 13:47 ` Bart Trojanowski
2008-05-02 9:41 ` Pedro Melo
2008-05-02 16:58 ` Kevin Ballard
2008-05-02 10:34 ` Wincent Colaiuta
2008-05-02 12:36 ` Jeff King
2008-05-02 13:49 ` Pedro Melo
2008-05-02 14:00 ` Aidan Van Dyk
2008-05-02 16:13 ` Wincent Colaiuta
2008-05-02 16:56 ` Kevin Ballard
2008-05-02 18:40 ` Wincent Colaiuta
2008-05-02 6:11 ` Jeff King
2008-05-02 7:53 ` Johannes Schindelin
2008-05-02 6:09 ` Jeff King
2008-05-02 6:19 ` Junio C Hamano
2008-05-02 12:55 ` Jeff King
2008-05-02 18:18 ` Junio C Hamano
2008-05-05 21:59 ` Jeff King
2008-05-06 5:51 ` Jeff King
2008-05-06 5:53 ` Jeff King
2008-05-11 17:15 ` Junio C Hamano
2008-05-16 4:42 ` Jeff King
2008-05-16 4:51 ` Jeff King
2008-05-16 10:29 ` Johannes Schindelin
2008-05-02 6:56 ` Jakub Narebski
2008-05-02 12:57 ` Jeff King
2008-05-02 15:36 ` Jeff King [this message]
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=20080502153628.GA6294@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kevin@sb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).