Re: [PATCH] diff: add support for reading files literally with --no-index

2019-01-05 Thread brian m. carlson
On Fri, Jan 04, 2019 at 11:26:56AM -0800, Junio C Hamano wrote: > "brian m. carlson" writes: > > >> - --dereference to control whether to follow symlinks > > > > This is actually surprisingly difficult. The reason I implemented this > > only for no-index mode is because there are actually severa

Re: [PATCH] diff: add support for reading files literally with --no-index

2019-01-04 Thread Junio C Hamano
"brian m. carlson" writes: >> - --dereference to control whether to follow symlinks > > This is actually surprisingly difficult. The reason I implemented this > only for no-index mode is because there are actually several places we > can stat a file in the diff code, and implementing a --derefer

Re: [PATCH] diff: add support for reading files literally with --no-index

2019-01-03 Thread brian m. carlson
On Thu, Jan 03, 2019 at 06:18:55PM -0800, Jonathan Nieder wrote: > I may be a minority in this opinion, but I had trouble understanding > what --literally would do from its name. I suspect we can come up > with a better name. > > Unfortunately, I'm terrible at coming up with names. :-P > > --der

Re: [PATCH] diff: add support for reading files literally with --no-index

2019-01-03 Thread Jonathan Nieder
Hi, brian m. carlson wrote: > In some shells, such as bash and zsh, it's possible to use a command > substitution to provide the output of a command as a file argument to > another process, like so: > > diff -u <(printf "a\nb\n") <(printf "a\nc\n") > > However, this syntax does not produce usef

Re: [PATCH] diff: add support for reading files literally with --no-index

2019-01-03 Thread brian m. carlson
On Wed, Jan 02, 2019 at 10:56:45AM -0800, Junio C Hamano wrote: > This is good as a goal, but the implementation seems to be overly > eager to dereference any symlink or non-regular file found in any > level of recursion. The use case presented as the justification in > the proposed log message, a

Re: [PATCH] diff: add support for reading files literally with --no-index

2019-01-02 Thread Junio C Hamano
"brian m. carlson" writes: > +test_expect_success SYMLINKS 'diff --no-index --literally with symlinks' ' > + test_write_lines a b c >f1 && > + test_write_lines a d c >f2 && > + ln -s f1 s1 && > + ln -s f2 s2 && > + cat >expect <<-\EOF && > + diff --git a/s1 b/s2 > + --

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-21 Thread brian m. carlson
On Fri, Dec 21, 2018 at 12:52:04PM +0100, Johannes Schindelin wrote: > ... and in Git for Windows' Bash, it would result in something like: > > $ git -P diff --no-index <(printf "a\nb\n") <(printf "a\nc\n") > error: Could not access '/proc/24012/fd/63' > > ... because the Bash is "MSY

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-21 Thread Johannes Schindelin
Hi Brian, On Thu, 20 Dec 2018, brian m. carlson wrote: > In some shells, such as bash and zsh, it's possible to use a command > substitution to provide the output of a command as a file argument to > another process, like so: > > diff -u <(printf "a\nb\n") <(printf "a\nc\n") > > However, this

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread brian m. carlson
On Thu, Dec 20, 2018 at 10:48:41AM -0500, Jeff King wrote: > The distinction is a bit subtle, but I think treating only the actual > top-level arguments as symlinks would solve your problem, but still > allow a more detailed diff for the recursive cases. Yeah, I think that would be better. I'll ad

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread brian m. carlson
On Thu, Dec 20, 2018 at 10:43:06PM +0100, Ævar Arnfjörð Bjarmason wrote: > > On Thu, Dec 20 2018, brian m. carlson wrote: > > > We don't include a test for the pipe scenario because I couldn't get > > that case to work in portable shell (although of course it works in > > bash). I have, however,

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Ævar Arnfjörð Bjarmason
On Thu, Dec 20 2018, brian m. carlson wrote: > We don't include a test for the pipe scenario because I couldn't get > that case to work in portable shell (although of course it works in > bash). I have, however, tested it on both macOS and Linux. No clue how > this works on Windows. You can (an

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Duy Nguyen
On Thu, Dec 20, 2018 at 6:32 PM Jeff King wrote: > > On Thu, Dec 20, 2018 at 06:23:42PM +0100, Duy Nguyen wrote: > > > On Thu, Dec 20, 2018 at 6:18 PM Jeff King wrote: > > > > I wonder if --follow-symlinks would be a good alternative for this > > > > (then if the final destination is unmmapable t

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Jeff King
On Thu, Dec 20, 2018 at 06:23:42PM +0100, Duy Nguyen wrote: > On Thu, Dec 20, 2018 at 6:18 PM Jeff King wrote: > > > 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 u

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Duy Nguyen
On Thu, Dec 20, 2018 at 6:18 PM Jeff King wrote: > > 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 c

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Jeff King
On Thu, Dec 20, 2018 at 06:06:11PM +0100, Duy Nguyen wrote: > On Thu, Dec 20, 2018 at 1:26 AM brian m. carlson > wrote: > > @@ -5159,6 +5159,8 @@ int diff_opt_parse(struct diff_options *options, > > options->flags.funccontext = 1; > > else if (!strcmp(arg, "--no-function-c

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Duy Nguyen
On Thu, Dec 20, 2018 at 1:26 AM brian m. carlson 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; > + e

Re: [PATCH] diff: add support for reading files literally with --no-index

2018-12-20 Thread Jeff King
On Thu, Dec 20, 2018 at 12:26:10AM +, brian m. carlson wrote: > In some shells, such as bash and zsh, it's possible to use a command > substitution to provide the output of a command as a file argument to > another process, like so: > > diff -u <(printf "a\nb\n") <(printf "a\nc\n") > > How

[PATCH] diff: add support for reading files literally with --no-index

2018-12-19 Thread brian m. carlson
In some shells, such as bash and zsh, it's possible to use a command substitution to provide the output of a command as a file argument to another process, like so: diff -u <(printf "a\nb\n") <(printf "a\nc\n") However, this syntax does not produce useful results with git diff --no-index. On m