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

Re: [PATCH 4/8] diff: support reading a file from stdin via "-"

From
Junio C Hamano <junkio@cox.net>
Date
Feb 25, 2007, 23:41 UTC
Message-ID
<7virdprejh.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0702260009530.22628@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
> I see this purely for purposes of --no-index diff. And in that case, we 
> only compare one file pair. Either one of them is from stdin, or it is 
> not. Therefore, if memory gets tight, we cannot compare that file pair 
> anyway, and have to error out.
>
> Maybe I missed something obvious?

I think the responsibility to mark if a path whose name is "-" is a filesystem object or stdin lies within the option parser. If the user says "diff - a" or diff a -" then the user clearly means the stdin, while if the user says "diff ./- a" it is a path (and the later stages like populate_filespec() would see canonicalized "-" as the filename). The point is that the disambiguation must be done by somebody, and I think the option parser, who calls get_pathspec(), should be the one that does it.

So we at least need a bit in diff_options that lets the option parser to tell the later stages "if you see - in pathspec, the user means stdin". And my suggestion was that if you are going to do that in the option parser anyway, you could read stdin in the option parser and hang that data in diff_options, and the presence of that stdin data (pointer being non NULL) can be used as that signal.

I think the callers of populate_filespec() may need to pass around diff_options as a parameter for the above to work, but hopefully that should not be a rocket surgery.

Previous: Johannes SchindelinNext: Junio C Hamano
Message 4 of 6 in “diff: support reading a file from stdin via "-"”
  1. 4/8 diff: support reading a file from stdin via "-"Johannes Schindelin, Feb 25, 2007
  2. Junio C HamanoFeb 25, 2007
  3. Johannes SchindelinFeb 25, 2007
  4. Junio C HamanoFeb 25, 2007
  5. Junio C HamanoFeb 26, 2007
  6. Johannes SchindelinFeb 26, 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.