Skip to contentSkip to conversation

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

PATCH Liu Yubao 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore

Liu Yubao

author
#0 lore raw

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.

templates/hooks--pre-commit +1 -1
index 723a9ef..6a55612
@@ -54,7 +54,7 @@ perl -e '
        }
        if (s/^\+//) {
            $lineno++;
-           chomp;
+           s/[\r\n]+$//;
            if (/\s$/) {
                bad_line("trailing whitespace", $_);
            }