Skip to content

file upload doesn't respect .gitattributes to normalize CRLF line endings #17496

Open
@plgruener

Description

@plgruener

Gitea Version

1.16.0+dev-444-g40c8451b7

Git Version

No response

Operating System

No response

How are you running Gitea?

Tested via https://try.gitea.io/plgruener/testCRLF

Database

No response

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

In a Git repo with a .gitattributes file with contents * text=auto, all newly added/staged files have their line terminators automatically converted from CRLF -> LF.
However, when you upload and commit a file with CRLF line terminators via the Gitea webinterface, the line endings are not normalized.

You can see this when you clone the example repo: crlf.txt was given CRLF (with the unix2dos utility) and uploaded via "upload file".
(Be careful to not enable core.autocrlf in your local Git config; and set core.eol=lf, else Git will convert every file to CRLF line endings.)
Also when you edit the example file again with the web editor (which forces LF line endings), you'll see that it reports seemingly identical changes on every line, indicating a line ending conversion.

(When copy-pasting the text in the "new file" web-editor, this is not immediately an issue, because the web editor forces LF line endings. But ideally, the editor should also respect .gitattributes, see #9108.)

Expected behaviour: be able to force the line ending style on all files by respecting the .gitattributes, whether they are submitted by push, by web-editor or by uploading a file.
If there's a workaround to just force LF on upload, that would be fine, but keep in mind that some files on Windows, eg .bat scripts, may require CRLF.

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions