[Bug 297041] Pre-commit hook incorrectly rejects commits that add missing newline at EOF

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 25 Jul 2026 08:34:30 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=297041

            Bug ID: 297041
           Summary: Pre-commit hook incorrectly rejects commits that add
                    missing newline at EOF
           Product: Documentation
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Website
          Assignee: doc@FreeBSD.org
          Reporter: vladlen@FreeBSD.org

I am trying to commit a fix to the doc tree that adds a missing newline at the
end of a file. However, the pre-receive hook rejects the commit with the
following error:

Total 12 (delta 7), reused 0 (delta 0), pack-reused 0 (from 0)
remote: 
remote: ================================================================
remote: Some files in your commit does not have newline at end
remote: of file. Please fix this and try committing again.
remote: ================================================================
remote: 
To gitrepo.freebsd.org:doc.git
 ! [remote rejected]       main -> main (pre-receive hook declined)
error: failed to push some refs to 'gitrepo.freebsd.org:doc.git'

It appears that a new server-side hook has been introduced to prevent files
without a trailing newline from being committed. However, the hook does not
distinguish between:

1. Adding a new file without a trailing newline (bad)
2. Fixing an existing file by adding the missing newline (good)

The hook rejects both cases because the diff output for adding a missing
newline looks identical to modifying a line (the hook likely detects that a
line was changed, but the newline character itself is not visible in the diff
context).

Example diff when fixing a missing newline - what I am trying to push:

-Кайл Эванс (от имени core@)
\ No newline at end of file
+Кайл Эванс (от имени core@)
+

The hook appears to check for the `\ No newline at end of file` marker in the
diff but does not account for commits that remove this marker by adding the
newline.

Expected behavior:
The hook should allow commits that only add a newline at the end of the file
(i.e., commits that remove the `\ No newline at end of file` marker from the
diff).

Suggested fix:
Could this hook be disabled until all newlines at EOF checked and fixed? 

Additional information
The file in question: website/content/ru/news/2026-ports-freeze/_index.adoc

Please let me know if additional information or testing is needed.

Thanks,
Vladlen Popolitov

-- 
You are receiving this mail because:
You are the assignee for the bug.