Indicate when newline has been added/removed from end of file #8414

Open
opened 2025-11-02 08:05:17 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @ktprograms on GitHub (Jan 27, 2022).

Feature Description

When showing the diffs for a commit, if the commit either adds or deletes the newline at the end of the file, Gitea shows that there has been a change on that line, but there is no indicator what the change is. This feature is currently not available on GitHub either.

I think the best way to add this feature would be how git diff handles newlines at the end of the file being added/removed, by using \ No newline at end of file. For example, if the latest commit added the newline to the end of the file, the diff (generated with git diff HEAD^) would look like this:

diff --git a/Test-NoEOL.txt b/Test-NoEOL.txt
index 5ab2f8a..e965047 100644
--- a/Test-NoEOL.txt
+++ b/Test-NoEOL.txt
@@ -1 +1 @@
-Hello
\ No newline at end of file
+Hello

If the commit removed the newline at the end of the file, the \ No newline at end of file part would be below the +Hello line (indicating that the lack of newline has been added).

Alternatively, it could be rendered the way a shell renders it when the command doesn't output a newline:
Screenshot 2022-01-27 at 2 37 00 PM
(The inverted percent sign after the text). The fish shell uses a non-inverted return symbol (⏎, U+23CE).

Screenshots

Currently displayed (a newline was added at the end of app/build.gradle in this commit):
Screenshot 2022-01-27 at 3 30 08 PM

You can see how git renders it by cloning https://codeberg.org/ktprograms/Ohms_Now and running git diff 6ba65f0f89..020701d58b.

Originally created by @ktprograms on GitHub (Jan 27, 2022). ### Feature Description When showing the diffs for a commit, if the commit either adds or deletes the newline at the end of the file, Gitea shows that there **has** been a change on that line, but there is no indicator what the change is. This feature is currently not available on GitHub either. I think the best way to add this feature would be how `git diff` handles newlines at the end of the file being added/removed, by using `\ No newline at end of file`. For example, if the latest commit **added** the newline to the end of the file, the diff (generated with `git diff HEAD^`) would look like this: ```diff diff --git a/Test-NoEOL.txt b/Test-NoEOL.txt index 5ab2f8a..e965047 100644 --- a/Test-NoEOL.txt +++ b/Test-NoEOL.txt @@ -1 +1 @@ -Hello \ No newline at end of file +Hello ``` If the commit **removed** the newline at the end of the file, the `\ No newline at end of file` part would be **below** the `+Hello` line (indicating that the **lack of newline** has been **added**). Alternatively, it could be rendered the way a shell renders it when the command doesn't output a newline: <img width="133" alt="Screenshot 2022-01-27 at 2 37 00 PM" src="https://user-images.githubusercontent.com/71804605/151311316-524d038f-f148-4b26-8c12-f32658a894a6.png"> (The inverted percent sign after the text). The [fish](https://fishshell.com) shell uses a non-inverted return symbol (⏎, U+23CE). ### Screenshots Currently displayed (a newline was **added** at the end of `app/build.gradle` in this commit): <img width="1125" alt="Screenshot 2022-01-27 at 3 30 08 PM" src="https://user-images.githubusercontent.com/71804605/151311720-fe9b20dd-c5e8-4066-a4ee-8cbbc637dffc.png"> You can see how git renders it by cloning https://codeberg.org/ktprograms/Ohms_Now and running `git diff 6ba65f0f89..020701d58b`.
GiteaMirror added the type/enhancement label 2025-11-02 08:05:17 -06:00
Author
Owner

@stth commented on GitHub (Nov 8, 2022):

I am also missing that feature. It is a pain to check manually if some sloppy dev forgot that mandatory "new line at at end of file" in c/cc++ code

@stth commented on GitHub (Nov 8, 2022): I am also missing that feature. It is a pain to check manually if some sloppy dev forgot that mandatory "new line at at end of file" in c/cc++ code
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8414