Difference in last line rendering. Browse file two lines, MR - one line.
Summary
There is an inconsistency in how GitLab renders files with a trailing newline (\n
):
- In the file view, the newline is rendered correctly (shown as an empty line).
- In the diff view, the same newline is not rendered at all — making it appear as if the file ends without one.
Steps to reproduce
- Create a new file with a single line ending in a newline character, e.g.
FOO=BAR\n
. - Commit and push the file to GitLab.
- View the file in the repository browser (file view).
- View the same file in a merge request or commit diff (diff view).
Environment info
-
GitLab version: Self hosted 18.3.2
-
Reproduced with multiple file types (
.env
,.conf
,.bazeliskrc
,.txt
) -
Render the trailing newline in the diff view as an empty line
-
Add visual markers or toggles for end-of-line characters
-
Align the diff view behavior with the file view for consistency
Edited by 🤖 GitLab Bot 🤖