Re: [PATCH] Quick description of possible gitattributes system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Fri, 2 Mar 2007, Andy Parkins wrote:

> On Friday 2007, March 02, Linus Torvalds wrote:
> 
> > Yes. How about just having the built-in git pager do the right thing?
> 
> Perfect.  This is absolutely the right thing to do I think.

Well, it would be perfect, except it's rather hard to do. Right now we 
simply don't have any way to tell the pager what to do with the data, and 
we'd need to do some communications passing thing to let it know.

It *could* just look at the data directly, but that's actually hard: if we 
start looking at the data, there's no way to push the data back onto the 
head of a pipe, and there's no really good way to tell an external pager 
to "start off with this data that I already read earlier to figure out the 
type, and then continue with that other file descriptor that I'm passing 
in".

So then we'd have to have a totally useless process in between the git 
process and the external pager to just feed the data from one pipe to the 
other..

Doing the pager internally would obviously solve that issue, but I really 
don't think we want to do that, especially since it's very 
system-dependent. And temporary files suck for all the other reasons 
(incrementally generated data).

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.

		Linus

---
diff --git a/pager.c b/pager.c
index 5f280ab..b71dd44 100644
--- a/pager.c
+++ b/pager.c
@@ -9,6 +9,8 @@
 
 static void run_pager(const char *pager)
 {
+	static char input_type[100] = "text";
+
 	/*
 	 * Work around bug in "less" by not starting it until we
 	 * have real input
@@ -17,7 +19,16 @@ static void run_pager(const char *pager)
 
 	FD_ZERO(&in);
 	FD_SET(0, &in);
-	select(1, &in, NULL, &in, NULL);
+	FD_SET(3, &in);
+	select(4, &in, NULL, &in, NULL);
+	if (FS_ISSET(3, &in)) {
+		int n = read(3, input_type, sizeof(input_type)-1);
+		if (n > 0)
+			input_type[n] = 0;
+	}
+	close(3);
+
+	pager = select_pager(input_type, pager);
 
 	execlp(pager, pager, NULL);
 	execl("/bin/sh", "sh", "-c", pager, NULL);
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]