Skip to content

fix: respect platform line endings in rustfmt - #3016

Open
CAOShurong wants to merge 1 commit into
gitui-org:masterfrom
CAOShurong:codex/1936-rustfmt-newline-auto
Open

fix: respect platform line endings in rustfmt#3016
CAOShurong wants to merge 1 commit into
gitui-org:masterfrom
CAOShurong:codex/1936-rustfmt-newline-auto

Conversation

@CAOShurong

@CAOShurongCAOShurong commented Aug 15, 2026

Copy link
Copy Markdown

This Pull Request fixes/closes#1936.

It changes the following:

  • lets rustfmt preserve the checkout's native line endings instead of forcing Unix newlines on every platform;
  • keeps LF behavior on Unix-like checkouts while allowing a normal Windows core.autocrlf=true checkout to pass the repository's format check.

I followed the checklist:

  • I added unittests (not applicable to this rustfmt configuration change)
  • I ran make check without errors (the full default-feature build needs a complete Perl/OpenSSL toolchain that is not present in this Windows environment)
  • I tested the overall application (no runtime code changes)
  • I added an appropriate item to the changelog (no user-facing behavior changes)

Verification on Windows with core.autocrlf=true:

  • the original newline_style=Unix behavior exits 1 with 162 Incorrect newline style findings;
  • cargo fmt -- --check exits 0 with this change;
  • a separate clean core.autocrlf=false clone reports index/worktree LF and also passes cargo fmt -- --check without changes;
  • cargo nextest run --workspace --no-default-features --features ghemoji,regex-fancy,trace-libgit passes all 313 tests;
  • git diff --check passes and the worktree remains clean after formatting.

The change and this description were prepared with OpenAI Codex assistance. I independently reproduced the issue and checked the commands and results above.

Use rustfmt's Auto newline style so formatting checks preserve the checkout's native line endings on Windows while retaining LF on Unix-like systems.
Assisted-by: OpenAI Codex
Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo fmt now messes things up on windows

1 participant

@CAOShurong