git/list[1] front-page[2] threads[3] people[4] search[5] about
 

hooks--pre-commit: chomp() in cygwin perl does not strip "\r"

From
LYLiu Yubao <yubao.liu@gmail.com>
Date
Oct 20, 2006, 06:14 UTC
Message-ID
<4538692E.6030404@gmail.com>

perl v5.8.7 built for cygwin-thread-multi-64int, its chomp() doesn't strip trailing "\r" so that pre-commit reports "trailing whitespace" for every line. ActiveState Perl v5.8.8 can strip "\r" and "\n" properly.

Changing
	if (/\s$/) {
to
	if (/[:blank:]$/) {
is also ok.
diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit
index 723a9ef..6a55612
--- a/templates/hooks--pre-commit
+++ b/templates/hooks--pre-commit
@@ -54,7 +54,7 @@ perl -e '
         }
         if (s/^\+//) {
             $lineno++;
-           chomp;
+           s/[\r\n]+$//;
             if (/\s$/) {
                 bad_line("trailing whitespace", $_);
             }
Message 1 of 1 in “hooks--pre-commit: chomp() in cygwin perl does not strip "\r"”
  1. Liu YubaoOct 20, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.