+2011-04-05 Eric Blake <eblake@redhat.com>
+
+ bootstrap: preserve git whitelist item sorting
+ * build-aux/bootstrap (sort_patterns): New function.
+ (insert_sorted_if_absent): Use it to sink ! lines to the bottom.
+
2011-04-05 Simon Josefsson <simon@josefsson.org>
* top/maint.mk (sc_prohibit_empty_lines_at_EOF): Don't trigger
#! /bin/sh
# Print a version string.
-scriptversion=2011-03-03.12; # UTC
+scriptversion=2011-04-05.18; # UTC
# Bootstrap this package from checked-out sources.
exit 1
fi
+# Ensure that lines starting with ! sort last, per gitignore conventions
+# for whitelisting exceptions after a more generic blacklist pattern.
+sort_patterns() {
+ sort -u "$@" | sed '/^!/ {
+ H
+ d
+ }
+ $ {
+ P
+ x
+ s/^\n//
+ }'
+}
+
# If $STR is not already on a line by itself in $FILE, insert it,
# sorting the new contents of the file and replacing $FILE with the result.
insert_sorted_if_absent() {
file=$1
str=$2
test -f $file || touch $file
- echo "$str" | sort -u - $file | cmp - $file > /dev/null \
- || echo "$str" | sort -u - $file -o $file \
+ echo "$str" | sort_patterns - $file | cmp - $file > /dev/null \
+ || { echo "$str" | sort_patterns - $file > $file.bak \
+ && mv $file.bak $file; } \
|| exit 1
}