Skip to content

cargo fmt now messes things up on windows #1936

Open
@pm100

Description

@pm100

rustfmt.toml now has

newline_style ="Unix"

this really messes things up on windows since running cargo fmt now converts all line endings to unix.

git (and gitui) report this as a massive number of files being changed, which is hard to work thru.

Leaving it as Auto works fine on other projects and used to work for gitui when I first worked on it.

git (and gitui and github) convert the line endings correctly when copying down to windows (lf-> crlf) and when uploading back to github (crlf -> lf), this is done by leaving the gitconfig crlf setting as auto. (which is the default). So there is no need for this rustfmt setting, the line endings will be lf in github anyway regardless .

here is newly cloned repo running fmt check

PS C:\work\newgit2\gitui> cargo fmt -- --check
Incorrect newline style in \\?\C:\work\newgit2\gitui\asyncgit\src\asyncjob\mod.rs
Incorrect newline style in \\?\C:\work\newgit2\gitui\asyncgit\src\blame.rs
Incorrect newline style in \\?\C:\work\newgit2\gitui\asyncgit\src\branches.rs
Incorrect newline style in \\?\C:\work\newgit2\gitui\asyncgit\src\cached\branchname.rs
Incorrect newline style in \\?\C:\work\newgit2\gitui\asyncgit\src\cached\mod.rs
Incorrect newline style in \\?\C:\work\newgit2\gitui\asyncgit\src\commit_files.rs
...

it complains about every file because the clone down to windows converted all line endings to crlf

What I have to do at the moment is edit the rustfmt file to Auto.

Took me a while to work out why gitui / git suddenly starting saying all files had been changed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdxhelp wantedExtra attention is neededwindows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions