git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Consider escaping special characters like 'less' does

From
Jeff King <peff@peff.net>
Date
Oct 15, 2017, 20:06 UTC
Message-ID
<20171015200635.e2u4qkxlz2xwpfov@sigill.intra.peff.net>
In-Reply-To
<CA+o7MD8fcD5-SFeQsX84Etu68ov7yy48OO4dV=gXMp5xY8s9Rg@mail.gmail.com>
On Sun, Oct 15, 2017 at 06:39:45PM +0200, Joris Valette wrote:
Show 7 quoted lines
> > It's your MUA's fault that you get a ?, the mail didn't contain any.
> 
> Actually, the original mail contained the special BOM sequence but
> it's generally invisible. His MUA shows it with a '?', mine doesn't
> show anything, neither does Firefox on the mailing list page.
> 
> The question remains: could escaping be done?

Git's diff generation will never do such escaping by default, because it means creating a patch that cannot be applied to get back the original content.

There _are_ already options to create diffs that cannot be applied, like --textconv. So it would be possible to add a similar option for escaping. But I don't think we really need or want a separate option, when you can already do one of:

  1. If your files have special binary characters that are hard to see,
     you can use the existing textconv system to do whatever escaping
     you like. And then the Git will diff the result of the escaping,
     which means you get readable diffs when they change.
  2. Put the raw output of git's diff through a filter that escapes. We
     already do this most of the time by piping through less. The most
     noticeable exception is "add --patch". There you can set up a
     program to filter as well. There's more information in a recent
     thread here:
       https://public-inbox.org/git/20171012184736.rglkbyryauwuvn2a@sigill.intra.peff.net/

It doesn't seem out of the question to me to have an out-of-the-box default for interactive.diffFilter which does some basic escaping (we could even implement it inside the perl script for efficiency).

-Peff
Previous: Joris ValetteNext: Joris Valette
Message 5 of 13 in “Consider escaping special characters like 'less' does”
  1. Joris ValetteOct 15, 2017
  2. Jason PyeronOct 15, 2017
  3. Andreas SchwabOct 15, 2017
  4. Joris ValetteOct 15, 2017
  5. Jeff KingOct 15, 2017
  6. Joris ValetteOct 15, 2017
  7. Jeff KingOct 16, 2017
  8. Andreas SchwabOct 16, 2017
  9. Jeff KingOct 16, 2017
  10. Junio C HamanoOct 17, 2017
  11. Jeff KingOct 17, 2017
  12. Jason PyeronOct 22, 2017
  13. Jeff KingOct 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.