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:31 UTC
Message-ID
<xmqq7d14k9uh.fsf@gitster.g>
In-Reply-To
<CAAHd=zcrU3VJro1R3xDj3hmqGXZHUA6rHuDFxwhF5aewNvA8xQ@mail.gmail.com>
Ignacio Taranto <ignacio.taranto@eclypsium.com> writes:
Show 7 quoted lines
> 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?
Yes, but not really.

It is not "warning" at all. The users want to know when compared contents do or do not end with an incomplete line at the end, and the "\ No newline" is the diff's way to give that single bit of information to us.

And the contents of a symbolic link typically is a single incomplete line, so it is expected to see "\ No newline" when comparing them.

This is important as "git diff | git -C ../some/where/else apply" should be able to recreate the change in the current repository (which may have change to or addition of a symbolic link) in the other repository, and "git apply" on the receiving end must be able to tell that the symbolic link it needs to create in the other repository must not have an extra LF at the end.

Previous: Ignacio TarantoNext: Ignacio Taranto
Message 2 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.