Re: [PATCH] diff: add support for reading files literally with --no-index
- From
Jeff King <peff@peff.net>
- Date
- Dec 20, 2018, 17:17 UTC
- Message-ID
- <20181220171725.GB6684@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8CScTBbYJt_LLp-rBdmJubEQOZqkPQeszzax9YpbCPUkg@mail.gmail.com>
On Thu, Dec 20, 2018 at 06:06:11PM +0100, Duy Nguyen wrote:
Show 13 quoted lines
> On Thu, Dec 20, 2018 at 1:26 AM brian m. carlson > <sandals@crustytoothpaste.net> wrote: > > @@ -5159,6 +5159,8 @@ int diff_opt_parse(struct diff_options *options, > > options->flags.funccontext = 1; > > else if (!strcmp(arg, "--no-function-context")) > > options->flags.funccontext = 0; > > + else if (!strcmp(arg, "--literally")) > > + options->flags.read_literally = 1; > > You probably want to check in diff_setup_done() that if > flags.read_literally is set but flags.no_index is not, then abandon > ship and die() because --literally is not used with --no-index. Even > when --no-index is implicit, flags.no_index should be set.
Yeah, good catch. "git diff --literally HEAD" should report an error.
Show 5 quoted lines
> I wonder if --follow-symlinks would be a good alternative for this > (then if the final destination is unmmapable then we just read the > file whole in memory without the user asking, so it will work with > pipes). --follow-symlinks then could be made work with non-"no-index" > case too. But --literally is also ok.
It's more than symlinks, though. Reading from a named pipe, we'd want to see the actual contents with --literally (and not "oops, I don't know how to represent a named pipe").
-Peff