Re: [PATCH] show git tag output in pager

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] show git tag output in pager

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:52:09

Jeff King [off-list ref] writes:
On Thu, Sep 29, 2011 at 11:37:49AM +0200, Michal Vyskocil wrote:
quoted
On Tue, Sep 27, 2011 at 04:19:39PM +0200, Matthieu Moy wrote:
quoted
The commit message should explain why this is needed, and in particular
why you prefer this to setting pager.tag in your ~/.gitconfig.
Opps! I read a documentation, but I did not realize this works for all
commands and not only for them calling setup_pager(). Then sorry, no
change is needed.
I don't think you want to set pager.tag. It will invoke the pager for
all tag subcommands, including tag creation and deletion.
That's the kind of argument/discussion I was expecting in the commit
message.
I think instead, you want some way for commands to say "OK, I'm in a
subcommand that might or might not want a pager now".
Right.

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.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

Re: [PATCH] show git tag output in pager

From: Jeff King <hidden>
Date: 2016-06-15 22:52:12

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help