coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] maint: fix alphabetical order in .gitignore


From: Bernhard Voelker
Subject: Re: [PATCH] maint: fix alphabetical order in .gitignore
Date: Fri, 11 Jan 2013 09:47:12 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 01/02/2013 04:02 PM, Bernhard Voelker wrote:
> If insert_vc_ignore is the only place where .gitignore
> is sorted, why not fix it there, i.e. use some way to
> add an entry without sorting the file?

I found out that bootstrap tries to add the just-generated
file "ABOUT-NLS" to .gitignore - which is already there.

But today, insert_sorted_if_absent() changes .gitignore
not only when the given entry is missing, but even if just
the ordering would change.

The following patch changes this behavior, and now
insert_sorted_if_absent() only adds the entry - well, sorted
again - only if the line count would change.

The second patch fixes the sorting of current .gitignore
(as in my initial patch).

WDYT?

Have a nice day,
Berny


>From 99c50676d4109e767926e9aa766e6e536dd3a716 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Fri, 11 Jan 2013 09:12:31 +0100
Subject: [PATCH 1/2] build: avoid unnecessary sorting of .gitignore

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.
---
 bootstrap |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/bootstrap b/bootstrap
index 61a9cbd..e00639b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -306,10 +306,13 @@ 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; } \
+  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 f3ae43711cf92772ebbbbd9f541bc60bf32ffccf Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]