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

Re: [BUG?] iconv used as textconv, and spurious ^M on added lines on Windows

From
Jeff King <peff@peff.net>
Date
Apr 1, 2017, 06:08 UTC
Message-ID
<20170401060800.hrpqqgdx6t262c7f@sigill.intra.peff.net>
In-Reply-To
<e1a6d44c-b01b-993c-6a22-e6ac0abca03c@gmail.com>
On Fri, Mar 31, 2017 at 03:24:48PM +0200, Jakub Narębski wrote:
Show 5 quoted lines
> > I suspect in the normal case that git is doing line-ending conversion,
> > but it's suppressed when textconv is in use.
> 
> I would not consider this a bug if not for the fact that there is no ^M
> without using iconv as textconv.

I don't think it's a bug, though. You have told Git that you will convert the contents (whatever their format) into the canonical format, but your program to do so includes a CR.

We _could_ further process with other canonicalizations, but I'm not sure that is a good idea (line-endings sound reasonably harmless, but almost certainly we should not be doing clean/smudge filtering). And I'm not sure if there would be any compatibility fallouts.

So I think the behavior is perhaps not what you want, but it's not an unreasonable one. And the solution is to define your textconv such that it produces clean LF-only output. Perhaps:

  [diff.whatever]
  textconv = "iconv ... | tr -d '\r'"
?
-Peff
Previous: Jakub NarębskiNext: Jakub Narębski
Message 4 of 10 in “[BUG?] iconv used as textconv, and spurious ^M on added lines on Windows”
  1. Jakub NarębskiMar 30, 2017
  2. Jeff KingMar 30, 2017
  3. Jakub NarębskiMar 31, 2017
  4. Jeff KingApr 1, 2017
  5. Jakub NarębskiApr 1, 2017
  6. Jeff KingApr 2, 2017
  7. Jakub NarębskiApr 2, 2017
  8. Torsten BögershausenMar 31, 2017
  9. Jakub NarębskiMar 31, 2017
  10. Torsten BögershausenApr 2, 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.