Single file editor should not mutate line endings
Git operations performed by the GitLab application, such as commit
, rely on Gitaly to execute the underlying Git commands. Some examples are when a user generates commits through the WebIDE, single file editor, code review suggestion, or uploading files to the repository. All of these actions perform Git operations for the repository on the server side via Gitaly RPCs.
Currently Gitaly's Git is configured with core.autocrlf
set to input
. Consequently, any new or updated file with CRLF
line endings will have them replaced with LF
line endings on commit. This is very problematic when a user intends to use the WebIDE or any of the previously mentioned options to made updates to a file with CRLF
line endings because the line endings will always be rewritten to LF
even if the user does not intend for this change. Gitaly should be agnostic towards a file's line endings and should always respect what the user submits. To accomplish this, Gitaly needs to change the core.autocrlf
configuration from input
to false
. gitaly#3476 (closed) and gitaly!4836 (merged) go further into the changes on the Gitaly side.
The problem with updating the Gitaly configuration is that the single file editor always creates new files with CRLF
and replaces line endings in an existing file with CRLF
. Historically the single file editor has relied on Gitaly to keep LF
line endings which most users expect. Before we can change how Gitaly handles line endings, we should ensure the single file editor does not mutate line endings as well.