Re: [PATCH 2/2] diff: add a special SYMLINK user-diff driver
- From
Jeff King <peff@peff.net>
- Date
- Sep 22, 2010, 00:30 UTC
- Message-ID
- <20100922003049.GA23931@sigill.intra.peff.net>
- In-Reply-To
- <AANLkTi=zSPegcPNY8jr4S5qeXWHrxuC+0SY-h5EhyA+6@mail.gmail.com>
On Wed, Sep 22, 2010 at 12:12:30AM +0000, Ævar Arnfjörð Bjarmason wrote:
Show 16 quoted lines
> 2010/9/21 Jeff King <peff@peff.net>: > > +However, it may happen that you do want to change the diff parameters > > +specifically for symlinks. You can do that by configuring the special > > +"SYMLINK" diff driver. For example, to add a newline to the end of > > +the symlink contents (and suppress the usual "no newline at end of file" > > +warning), you could configure: > > + > > +----------------------------- > > +[diff "SYMLINK"] > > + textconv = perl -pe 's/$/\n/' > > +----------------------------- > > That'll turn every \n in the stream into \n\n, not add a newline to > the end of the file. Don't you mean: > > perl -0666 -pe 's/$/\n/'
Yeah, it will add a newline to the end of file, but it will also double existing newlines. I wanted something short and clear so the reader could understand what was going on, and symlink paths don't generally contain an extra newline.
Just "perl -0pe 's/$/\n/'" would work, as symlink targets can't possibly have embedded NULs.
But:
> Or, more efficiently:
>
> perl -ple 'END { print }'That one is even more readable, IMHO. But it isn't right. :) The automatic line-handling actually adds the missing newline, so I think it would have to be:
perl -ple ''
-Peff