SVN NPTL branch doesn't check for trailing whitespaces

Denys Vlasenko vda.linux at googlemail.com
Sat Jul 12 23:13:38 UTC 2008


On Thursday 10 July 2008 12:40, Carmelo AMOROSO wrote:
> Hi All,
> I'm not svn expert, but I've noted that the nptl branch doesn't take 
> care of trailing whitespaces on files and accept them silently, the same 
> doesn't happen on trunk.
> Indeed I've committed some files on branch without problems and then, 
> moving on trunk I've discovered the problems (sorry for that).
> 
> Is someone knows how to fix the nptl branch to reject commit when files 
> have trailing whitespaces, please do.

Apart from having such hooks installed - how about adding this?
For the moment, running it just removes trailing whitespace
(which produces patch of about ~400k).

I am proposing just adding it for reference. Whether we want to
one day sync up and run it over every active devel branch
is another matter.
--
vda


diff -d -urpN -U5 uClibc.2/extra/scripts/fix_ws.sh uClibc.3/extra/scripts/fix_ws.sh
--- uClibc.2/extra/scripts/fix_ws.sh	1970-01-01 01:00:00.000000000 +0100
+++ uClibc.3/extra/scripts/fix_ws.sh	2008-07-13 01:06:43.000000000 +0200
@@ -0,0 +1,72 @@
+#!/bin/bash
+# Whitespace fixer
+# Usage: fix_ws [dir]...
+
+temp="/tmp/fix_ws.$$.$RANDOM"
+
+# Using $'xxx' bashism
+begin8sp_tab=$'s/^        /\t/'
+beginchar7sp_chartab=$'s/^\\([^ \t]\\)       /\\1\t/'
+tab8sp_tabtab=$'s/\t        /\t\t/g'
+tab8sptab_tabtabtab=$'s/\t        \t/\t\t\t/g'
+begin17sptab_tab=$'s/^ \\{1,7\\}\t/\t/'
+tab17sptab_tabtab=$'s/\t \\{1,7\\}\t/\t\t/g'
+trailingws_=$'s/[ \t]*$//'
+
+#>fix_ws.diff
+
+find "$@" -type f \
+| while read name; do
+    test "YES" = "${name/*.bz2/YES}" && continue
+    test "YES" = "${name/*.gz/YES}" && continue
+    test "YES" = "${name/*.png/YES}" && continue
+    test "YES" = "${name/*.gif/YES}" && continue
+    test "YES" = "${name/*.jpg/YES}" && continue
+    test "YES" = "${name/*.diff/YES}" && continue
+    test "YES" = "${name/*.patch/YES}" && continue
+
+# uclibc has no agreed-upot tab size. can't use these
+# more thorough replaces because of that:
+#    if test "YES" = "${name/*.[chsS]/YES}" \
+#	-o "YES" = "${name/*.sh/YES}" \
+#	-o "YES" = "${name/*.txt/YES}" \
+#	-o "YES" = "${name/*.html/YES}" \
+#	-o "YES" = "${name/*.htm/YES}" \
+#	-o "YES" = "${name/*Config.in*/YES}" \
+#    ; then
+#    # More aggressive whitespace fixes for known file types
+#	echo "Formatting: $name" >&2
+#	cat "$name" \
+#	| sed -e "$tab8sptab_tabtabtab" -e "$tab8sptab_tabtabtab" \
+#	      -e "$tab8sptab_tabtabtab" -e "$tab8sptab_tabtabtab" \
+#	| sed "$begin17sptab_tab" \
+#	| sed -e "$tab17sptab_tabtab" -e "$tab17sptab_tabtab" \
+#	      -e "$tab17sptab_tabtab" -e "$tab17sptab_tabtab" \
+#	      -e "$tab17sptab_tabtab" -e "$tab17sptab_tabtab" \
+#	| sed "$trailingws_"
+#    elif test "YES" = "${name/*Makefile*/YES}" \
+#	-o "YES" = "${name/*Kbuild*/YES}" \
+#    ; then
+#    # For Makefiles, never convert "1-7spaces+tab" into "tabtab"
+#	echo "Makefile: $name" >&2
+#	cat "$name" \
+#	| sed -e "$tab8sptab_tabtabtab" -e "$tab8sptab_tabtabtab" \
+#	      -e "$tab8sptab_tabtabtab" -e "$tab8sptab_tabtabtab" \
+#	| sed -e "$tab17sptab_tabtab" -e "$tab17sptab_tabtab" \
+#	      -e "$tab17sptab_tabtab" -e "$tab17sptab_tabtab" \
+#	      -e "$tab17sptab_tabtab" -e "$tab17sptab_tabtab" \
+#	| sed "$trailingws_"
+#    else
+    if true; then
+    # Only remove trailing WS for the rest
+	echo "Removing trailing whitespace: $name" >&2
+	cat "$name" \
+	| sed "$trailingws_"
+    fi >"$temp"
+
+#    diff -u "$temp" "$name" >>fix_ws.diff
+
+    # Conserve mode/symlink:
+    cat "$temp" >"$name"
+done
+rm "$temp" 2>/dev/null



More information about the uClibc mailing list