git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Quick description of possible gitattributes system

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 2, 2007, 21:45 UTC
Message-ID
<Pine.LNX.4.63.0703022237000.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<Pine.LNX.4.64.0703021249010.3953@woody.linux-foundation.org>
Hi,
On Fri, 2 Mar 2007, Linus Torvalds wrote:
> Doing the pager internally would obviously solve that issue,

Ooooooh! A builtin! (Seriously, I thought about that already, but dismissed it for the reasons you said, and more...)

Show 17 quoted lines
> So we're in the situation where:
> 
>  - the pager process *will* wait until actual data is starting to appear,
>    so we *can* have some side-band channel to tell it "oh, btw, if there 
>    is a pager, this is going to be image data, so start up an external 
>    image viewer instead". 
> 
>  - but I don't have a good clue what side-band to use. We could use 
>    a special "FILE *pagerdata", of course (which would just be fd#3 in 
>    the pager). Then, "git show" could just do something like
> 
> 	if (pager_in_use)
> 		fprintf(pagerdata, "'%s'\n", type);
> 
>    and we could change pager.c to do something like the appended patch.
> 
> but I have to say, it looks a bit strange.

The obvious thing, of course, is a git-show specific solution (this is no patch, it only illustrates my idea):

 builtin-log.c |   11 +++++++++++
 git.c         |    2 +-
 2 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 1c9f7d0..83e6cea 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -123,6 +123,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	struct rev_info rev;
 	struct object_array_entry *objects;
 	int i, count, ret = 0;
+	enum { NO_PAGER, TEXT_PAGER, OTHER_PAGER } pager_mode = NO_PAGER;
 
 	git_config(git_log_config);
 	init_revisions(&rev, prefix);
@@ -140,6 +141,16 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	for (i = 0; i < count && !ret; i++) {
 		struct object *o = objects[i].item;
 		const char *name = objects[i].name;
+		if (o->type == OBJ_BLOB) {
+			/* determine if name falls into some special class */
+			if (pager_mode == NO_PAGER &&
+					setup_special_pager(name))
+				pager_mode = OTHER_PAGER;
+		}
+		if (pager_mode == NO_PAGER) {
+			setup_pager();
+			pager_mode = TEXT_PAGER;
+		}
 		switch (o->type) {
 		case OBJ_BLOB:
 			ret = show_object(o->sha1, 0);
diff --git a/git.c b/git.c
index 909adf2..a3811e6 100644
--- a/git.c
+++ b/git.c
@@ -291,7 +291,7 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
 		{ "runstatus", cmd_runstatus, RUN_SETUP | DISALLOW_IN_GIT_DIR },
 		{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
 		{ "show-branch", cmd_show_branch, RUN_SETUP },
-		{ "show", cmd_show, RUN_SETUP | USE_PAGER },
+		{ "show", cmd_show, RUN_SETUP },
 		{ "stripspace", cmd_stripspace },
 		{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
 		{ "tar-tree", cmd_tar_tree },
Previous: Linus TorvaldsNext: Andy Parkins
Message 16 of 20 in “Quick description of possible gitattributes system”
  1. Quick description of possible gitattributes systemAndy Parkins, Mar 1, 2007
  2. Brian GernhardtMar 1, 2007
  3. Andy ParkinsMar 2, 2007
  4. Brian GernhardtMar 2, 2007
  5. Andy ParkinsMar 2, 2007
  6. Brian GernhardtMar 2, 2007
  7. Robin RosenbergMar 1, 2007
  8. Junio C HamanoMar 2, 2007
  9. Junio C HamanoMar 2, 2007
  10. Andy ParkinsMar 2, 2007
  11. Andy ParkinsMar 2, 2007
  12. Jakub NarebskiMar 2, 2007
  13. Linus TorvaldsMar 2, 2007
  14. Andy ParkinsMar 2, 2007
  15. Linus TorvaldsMar 2, 2007
  16. Johannes SchindelinMar 2, 2007
  17. Andy ParkinsMar 2, 2007
  18. Andy ParkinsMar 2, 2007
  19. Junio C HamanoMar 3, 2007
  20. Jakub NarebskiMar 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.