#5677 made addToGitignore preserve a CRLF .gitignore by consuming
gitignore.AppendLineEnding, but it re-implemented the rest of the #6343
append policy inline: the final-line completion, including the rule that a
trailing CR is completed with a bare LF. That policy already lives in
gitignore.AppendLines, which the three other project-ignore writers call.
The two copies are byte-equivalent today, and only one of them is
discoverable when the policy changes.
Derive the appended bytes from AppendLines instead. Its contract leaves the
existing bytes unchanged, so everything past len(content) is exactly the
append, and writing only that suffix keeps the O_APPEND handle: the user's
.gitignore is still appended to, never truncated and rewritten. The write
also becomes a single Write call instead of a separator write followed by an
Fprintf.
No behavior change. The call-site tests pass unmodified, byte for byte. The
doc comment on TestAddToGitignoreCompletesUnterminatedCRLFLine is reworded
because it described the removed separator variable; the arm it pins, and
why only that test reaches it, are unchanged.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Gas City Adopt-PR
Co-authored-by: Eddie the Engineer <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>