From: Jeff King <peff@peff.net>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Michal Vyskocil <mvyskocil@suse.cz>, git@vger.kernel.org
Subject: Re: [PATCH] show git tag output in pager
Date: Fri, 7 Oct 2011 10:44:38 -0400 [thread overview]
Message-ID: <20111007144438.GA30318@sigill.intra.peff.net> (raw)
In-Reply-To: <vpqwrcmw7ve.fsf@bauges.imag.fr>
On Mon, Oct 03, 2011 at 02:57:09PM +0200, Matthieu Moy wrote:
> I like the try_subcommand_pager idea. Ideally, there would also be a
> nice mechanism to set defaults for subcommands, so that "git tag
> <whatever>" does the right thing without configuration.
That's easy enough. Something like the patch below?
Still thoroughly untested, but it looks Obviously Correct to me. :)
---
builtin.h | 1 +
builtin/tag.c | 1 +
git.c | 13 +++++++++++++
3 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/builtin.h b/builtin.h
index 0e9da90..b2badf8 100644
--- a/builtin.h
+++ b/builtin.h
@@ -35,6 +35,7 @@ int copy_note_for_rewrite(struct notes_rewrite_cfg *c,
void finish_copy_notes_for_rewrite(struct notes_rewrite_cfg *c);
extern int check_pager_config(const char *cmd);
+extern void try_subcommand_pager(const char *subcommand, int fallback);
extern int textconv_object(const char *path, unsigned mode, const unsigned char *sha1, char **buf, unsigned long *buf_size);
diff --git a/builtin/tag.c b/builtin/tag.c
index 9d89616..c77adc4 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -152,6 +152,7 @@ static int list_tags(const char **patterns, int lines,
filter.lines = lines;
filter.with_commit = with_commit;
+ try_subcommand_pager("tag.list", 1);
for_each_tag_ref(show_reference, (void *) &filter);
return 0;
diff --git a/git.c b/git.c
index 8e34903..11ee1a8 100644
--- a/git.c
+++ b/git.c
@@ -64,6 +64,19 @@ static void commit_pager_choice(void) {
}
}
+void try_subcommand_pager(const char *subcommand, int fallback)
+{
+ /* it's too late to turn off a running pager */
+ if (pager_in_use())
+ return;
+
+ if (use_pager == -1)
+ use_pager = check_pager_config(subcommand);
+ if (use_pager == -1)
+ use_pager = fallback;
+ commit_pager_choice();
+}
+
static int handle_options(const char ***argv, int *argc, int *envchanged)
{
const char **orig_argv = *argv;
--
1.7.7.rc2.7.gdfc92
next prev parent reply other threads:[~2011-10-07 14:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 13:42 [PATCH] show git tag output in pager Michal Vyskocil
2011-09-27 14:19 ` Matthieu Moy
2011-09-29 9:37 ` Michal Vyskocil
2011-09-30 10:42 ` Jeff King
2011-10-03 12:57 ` Matthieu Moy
2011-10-07 14:44 ` Jeff King [this message]
2011-10-07 14:48 ` Matthieu Moy
2011-10-07 16:16 ` Jeff King
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111007144438.GA30318@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=mvyskocil@suse.cz \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).