Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:56

Possibly related (same subject, not in this thread)

Johannes Schindelin [off-list ref] writes:
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help