diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit
index 2d29d7e79f762c6be7d0309e092b1b29cb8986d2..054652603f868f4b8fb282691872e26f87a8490a 100755
--- a/git-hooks/sanitize-commit
+++ b/git-hooks/sanitize-commit
@@ -503,7 +503,8 @@ while (<DIFF>) {
             $no_copyright = 0;
         }
         if ($check_gen && /All changes made in this file will be lost|This file is automatically generated|DO NOT EDIT|DO NOT delete this file|[Gg]enerated by|uicgenerated|produced by gperf|made by GNU Bison/) {
-            complain("Adding generated file", "generated") if ($new_file && !defined($cfg{generated}));
+            complain("Adding generated file (inferred from line ".($lineno + 1).")", "generated")
+                if ($new_file && !defined($cfg{generated}));
             $ws_check = 0;
             $check_gen = 0;
         }
@@ -537,10 +538,16 @@ while (<DIFF>) {
         $in_plus = 1;
         if (!$crlf_fail && /\r\n$/) {
             $crlf_fail = 1;
-            complain("CRLF line endings", "crlf");
+            if ($lineno != 1) {
+                # A stray CRLF somewhere in the middle.
+                complain_ln("CRLF line endings", "crlf");
+            } else {
+                # Assume that the whole file is affected.
+                complain("CRLF line endings", "crlf");
+            }
         }
         if (!$conflict_fail && /^(?:[<>=]){7}( |$)/) {
-            complain("Unresolved merge conflict", "conflict");
+            complain_ln("Unresolved merge conflict", "conflict");
             $conflict_fail = 1;
         }
         if ($ws_check) {