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

Re: git-diff should not fire up $PAGER if there is no diff

From
Stefan Karpinski <stefan.karpinski@gmail.com>
Date
Dec 16, 2008, 22:43 UTC
Message-ID
<d4bc1a2a0812161443k62e4b53s841ac32f653037fe@mail.gmail.com>
In-Reply-To
<20081216074414.GB2468@coredump.intra.peff.net>
On Tue, Dec 16, 2008 at 2:44 AM, Jeff King <peff@peff.net> wrote:
Show 21 quoted lines
> 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!
Previous: Jeff KingNext: jidanni@jidanni.org
Message 5 of 13 in “git-diff should not fire up $PAGER if there is no diff”
  1. jidanni@jidanni.orgDec 16, 2008
  2. Jeff KingDec 16, 2008
  3. Stefan KarpinskiDec 16, 2008
  4. Jeff KingDec 16, 2008
  5. Stefan KarpinskiDec 16, 2008
  6. git-diff should not fire up $PAGER, period!jidanni@jidanni.org, Dec 17, 2008
  7. Junio C HamanoDec 17, 2008
  8. Linus TorvaldsDec 17, 2008
  9. Miles BaderDec 22, 2008
  10. Jeff KingDec 18, 2008
  11. Miles BaderDec 22, 2008
  12. Johannes SixtDec 22, 2008
  13. Junio C HamanoDec 22, 2008

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.