git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: git-diff should not fire up $PAGER, period!
@ 2008-12-18  2:18 Mike Coleman
  2008-12-18  2:26 ` Junio C Hamano
  2008-12-18  3:22 ` Johannes Schindelin
  0 siblings, 2 replies; 11+ messages in thread
From: Mike Coleman @ 2008-12-18  2:18 UTC (permalink / raw)
  To: git

It's so cold here my car wouldn't start this morning, so I feel
fortunate to have these flames to keep me warm!  :-)


I still find git-diff's unsolicited invocation of $PAGER a bit
jarring, but I also find that I like it.  It has a sort of Windows-ish
feel to it (am I straying from the true path?).  It's convenient,
though honestly "git-diff|l" would only be two extra characters.  From
a UI perspective, the oddest thing about it is that all (not, in
fact?) of the other git programs which might also produce lengthy
output *don't* invoke $PAGER--git-status particularly comes to mind.
There are a large number of Unix programs that would be more
convenient if their output was automatically paged, but I'm not sure
it'd be better if they were all changed to do this.  (The best analog
I can think of where this seems desirable is man(1).)

To me, the most important nugget from the original complaint was that
git-diff sends its error messages to stdout.  I understand why it
might be done, but I'd worry about losing the stderr diagnostic for a
command that matters.  [I've been playing around with this for a few
minutes trying to see errors going to stdout and I can't reproduce
it--I wonder if they really do.]


Regarding the emacs complaint, as an emacs user I'd say I'm not
surprised this didn't quite work right.  In the particular case of the
compilation buffer, I wonder if the solution isn't to just unset TERM,
the existence of which (together with the fact that there's a pty)
could be taken as an invitation for the subordinate process to start
doing awful raw-terminal things.  (Similar logic applies to the
DISPLAY variable.)  Like Junio, I also eschew doing terminal emulation
inside of emacs.

Good evening from the icy midwest,
Mike

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: git-diff should not fire up $PAGER if there is no diff
@ 2008-12-16  0:56 Jeff King
  2008-12-17 21:45 ` git-diff should not fire up $PAGER, period! jidanni
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff King @ 2008-12-16  0:56 UTC (permalink / raw)
  To: jidanni; +Cc: git

On Tue, Dec 16, 2008 at 08:21:33AM +0800, jidanni@jidanni.org wrote:

> git-diff should not fire up $PAGER if there is no diff output.
> Just exit. The man page doesn't even mention $PAGER too.

I agree that would be nice, but it is a little difficult to implement.
The current behavior forks early and then pipes the output to the pager.
So we would have to:

  1. change that behavior to instead delay starting the pager until the
     first output. Which means intercepting every
     write/fwrite/printf/fputs/etc call.

  2. detect EOF before starting the pager. We in fact already delay
     running the pager in the forked process until we have some activity
     on the pipe, but I don't know if there is a portable way of
     detecting that that activity is EOF without performing an actual
     read() call (which is undesirable, since it eats the first byte of
     output that should go to the pager).

  3. a hacky solution to (2) above would be to make _2_ pipes, one of
     which signals to the pager sub-process either "exit now" or "proceed
     with running the pager".

The usual workaround is to ask the pager to exit immediately if the
output is small. I.e., putting "F" in your LESS variable (which git does
automatically if you don't already have LESS set).

-Peff

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-12-22  8:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-18  2:18 git-diff should not fire up $PAGER, period! Mike Coleman
2008-12-18  2:26 ` Junio C Hamano
2008-12-18  3:22 ` Johannes Schindelin
  -- strict thread matches above, loose matches on Subject: below --
2008-12-16  0:56 git-diff should not fire up $PAGER if there is no diff Jeff King
2008-12-17 21:45 ` git-diff should not fire up $PAGER, period! jidanni
2008-12-17 22:02   ` Junio C Hamano
2008-12-17 22:04   ` Linus Torvalds
2008-12-22  3:28     ` Miles Bader
2008-12-18  3:31   ` Jeff King
2008-12-22  3:27   ` Miles Bader
2008-12-22  7:55     ` Johannes Sixt
2008-12-22  8:30       ` Junio C Hamano

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).