git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stefan Karpinski" <stefan.karpinski@gmail.com>
To: "Jeff King" <peff@peff.net>
Cc: jidanni@jidanni.org, git@vger.kernel.org
Subject: Re: git-diff should not fire up $PAGER if there is no diff
Date: Tue, 16 Dec 2008 17:43:28 -0500	[thread overview]
Message-ID: <d4bc1a2a0812161443k62e4b53s841ac32f653037fe@mail.gmail.com> (raw)
In-Reply-To: <20081216074414.GB2468@coredump.intra.peff.net>

On Tue, Dec 16, 2008 at 2:44 AM, Jeff King <peff@peff.net> wrote:
> On Tue, Dec 16, 2008 at 01:35:53AM -0500, Stefan Karpinski wrote:
>
>> > On Mon, Dec 15, 2008 at 7:56 PM, Jeff King <peff@peff.net> wrote:
>> >  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).
>>
>> Wouldn't ungetc work? Or is that not portable enough? (It would only
>> work here because the EOF has to be the first character.)
>
> No, it won't work. ungetc works on the buffered stdio object, so it is
> useful for pushing back characters onto the buffer to be read later in
> the program from the same buffer. But in this case, we are going to
> execv() (or on Windows, spawn) the pager, meaning it will throw away
> anything that has been read() from the pipe and put in the buffer.
>
> So we would need a system call to push a character back to the OS, so
> that it was available for read() by the pager process.

Yeah, I realized that after I sent the message. Late night sending bad!

  reply	other threads:[~2008-12-16 22:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16  0:21 git-diff should not fire up $PAGER if there is no diff jidanni
2008-12-16  0:56 ` Jeff King
2008-12-16  6:35   ` Stefan Karpinski
2008-12-16  7:44     ` Jeff King
2008-12-16 22:43       ` Stefan Karpinski [this message]
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
     [not found] <alpine.DEB.1.00.0812160153340.14632@racer>
2008-12-16  1:16 ` git-diff should not fire up $PAGER if there is no diff jidanni
2008-12-16  4:07   ` Jeff King
2008-12-16 17:38     ` jidanni

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4bc1a2a0812161443k62e4b53s841ac32f653037fe@mail.gmail.com \
    --to=stefan.karpinski@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jidanni@jidanni.org \
    --cc=peff@peff.net \
    /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.
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).