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

Re: About git reporting missing newline for symlinks

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 12, 2022, 21:34 UTC
Message-ID
<xmqq35bsk9og.fsf@gitster.g>
In-Reply-To
<Y0cyX8Ggp+dkgAjX@tapette.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 19 quoted lines
> On 2022-10-12 at 21:17:04, Ignacio Taranto wrote:
>> So, both git diff and git show display "\ No newline at end of file"
>> for symlinks.
>> 
>> I think this is related to how Git renders diffs, IMO it shouldn't
>> display a warning about
>> newlines for symlinks.
>> 
>> Am I making any sense here?
>
> What Git shows for a symlink is the destination of the symlink.  On
> Unix systems other than macOS, path names may contain any byte other
> than NUL, including a newline.
>
> While it obviously is not a good practice to include newlines in your
> paths, it is possible, and Git would not be able to round-trip symlinks
> where the final character of the destination is a newline if we didn't
> handle trailing newlines properly.  As a result, we're not likely to
> change things here because it's required for correctness.

Just a fun thought experiment, but I wonder what would happen if a user chooses to add .clean and .smudge filter that adds and strips a LF at the end ;-)

Previous: brian m. carlsonNext: brian m. carlson
Message 13 of 15 in “About git reporting missing newline for symlinks”
  1. Ignacio TarantoOct 12, 2022
  2. Junio C HamanoOct 12, 2022
  3. Ignacio TarantoOct 12, 2022
  4. Ævar Arnfjörð BjarmasonOct 13, 2022
  5. Junio C HamanoOct 13, 2022
  6. Ævar Arnfjörð BjarmasonOct 13, 2022
  7. Junio C HamanoOct 13, 2022
  8. Ævar Arnfjörð BjarmasonOct 13, 2022
  9. Junio C HamanoOct 13, 2022
  10. Philip OakleyOct 13, 2022
  11. Erik Cervin EdinOct 13, 2022
  12. brian m. carlsonOct 12, 2022
  13. Junio C HamanoOct 12, 2022
  14. brian m. carlsonOct 12, 2022
  15. Taylor BlauOct 13, 2022

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.