Final Newline
GitAuto ensures every file ends with exactly one newline character. Missing final newlines violate the POSIX standard, trigger git diff warnings, and cause linter errors in many projects.
Why This Exists
The POSIX standard defines a text file as a sequence of lines, each ending with a newline. When a file does not end with a newline, git shows the warning "No newline at end of file" in diffs, and many linters (ESLint, Prettier, editorconfig) flag it as an error. The model sometimes omits the final newline, and sometimes adds multiple trailing newlines. Both cases trigger failures that waste agent iterations.
Why Models Get Final Newlines Wrong
Models have no reliable sense of "the file is done now, add exactly one newline." The end of generation is controlled by a stop token, not by the model deliberately choosing to end with a newline. Whether the output ends with zero, one, or two newlines is essentially random. Same as trailing spaces - benchmarks normalize whitespace, so final newline handling is invisible during evaluation.
How It Works
Before writing a file, GitAuto strips all trailing newlines from the content and then appends exactly one newline character. This guarantees the file ends with a single \n regardless of how many (or how few) the model included. The operation is applied to all text files and runs after trailing space removal to avoid interaction issues.
Related Features
- Trailing Space Removal - Strips whitespace from line endings before final newline is applied
- Line Ending Preservation - Preserves LF vs CRLF style after the final newline is ensured
Need Help?
Have questions or suggestions? We're here to help you get the most out of GitAuto.
Contact us with your questions or feedback!