Re: [PATCH] diff: add support for reading files literally with --no-index
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Dec 20, 2018, 17:06 UTC
- Message-ID
- <CACsJy8CScTBbYJt_LLp-rBdmJubEQOZqkPQeszzax9YpbCPUkg@mail.gmail.com>
- In-Reply-To
- <20181220002610.43832-1-sandals@crustytoothpaste.net>
On Thu, Dec 20, 2018 at 1:26 AM brian m. carlson <sandals@crustytoothpaste.net> wrote:
Show 6 quoted lines
> @@ -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.
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.
-- Duy