>From d65a0b870b0092e9e13c278e664073841f594e26 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Fri, 11 Jan 2013 16:33:43 +0100 Subject: [PATCH 1/2] build: avoid unnecessary sorting of .gitignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During bootstrap, files may be created which are already included in .gitignore, but the test to add such a file relied on the sort order. Now, it just adds such a new entry and thus only changes the file if the line count would change. * bootstrap (insert_sorted_if_absent): Instead of comparing the sorted new file with the original, the function compares the line count, and only in case of a difference, the given file is changed. Before that, ensure that the given ignore file does not already include duplicate entries. Otherwise, the above comparison would fail. Improved-by: Pádraig Brady --- bootstrap | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bootstrap b/bootstrap index 61a9cbd..87c001f 100755 --- a/bootstrap +++ b/bootstrap @@ -306,10 +306,18 @@ insert_sorted_if_absent() { file=$1 str=$2 test -f $file || touch $file - echo "$str" | sort_patterns - $file | cmp -s - $file > /dev/null \ - || { echo "$str" | sort_patterns - $file > $file.bak \ - && mv $file.bak $file; } \ + duplicate_entries=$(sort $file | uniq -d) + if [ "$duplicate_entries" ] ; then + echo "Error: Duplicate entries in $file: " $duplicate_entries >&2 + exit 1 + fi + linesold=$(wc -l < $file) + linesnew=$(echo "$str" | sort_patterns - $file | wc -l) + if [ $linesold != $linesnew ] ; then + { echo "$str" | sort_patterns - $file > $file.bak \ + && mv $file.bak $file; } \ || exit 1 + fi } # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with -- 1.7.7 >From 2cb00b980137c093560abdec34bdd9c25daf9364 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Fri, 11 Jan 2013 09:14:22 +0100 Subject: [PATCH 2/2] maint: fix alphabetical order in .gitignore Since commit v8.20-67-g0f525b6, .gitignore sometimes showed up as changed because the entries "*.gcda" and "*.gcno" had not been in alphabetical order. * .gitignore: Exchange the entries "*.gcda" and "*.gcno". --- .gitignore | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/.gitignore b/.gitignore index 67f428c..f0d6d87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ *.I[12] *.[EIOX] *.bak -*.gcno *.gcda +*.gcno *.o */.deps/ *~ -- 1.7.7