bug-gnulib
[Top][All Lists]
Advanced

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

Re: the release of grep-2.9 is imminent


From: Jim Meyering
Subject: Re: the release of grep-2.9 is imminent
Date: Wed, 22 Jun 2011 08:34:11 +0200

Bruno Haible wrote:
> Jim Meyering wrote about modifications done to .gitignore files:
>> I've Cc'd bug-gnulib, since gnulib-tool appears
>> to be doing it.
>>
>> I notice that some of your differences appear to be due to sorting
>> with a different locale than I use.  That implies there's a second
>> problem: perhaps one of gnulib-tool's uses of sort is not prefixed
>> with LC_ALL=C.
>
> In both cases, the problem lies in the 'bootstrap' script, not in
> 'gnulib-tool'. gnulib-tool does only two things with the .gitignore files:
>   - It adds added files, at the end of the .gitignore file.
>   - It removes removed files from the list.
>
> See gnulib-tool lines 5312..5319:
>
>                 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
>                 ...
>                 { cat "$destdir/$dir$ignore"~
>                   sed -e "s|^|$anchor|" < "$tmp"/ignore-added
>                 } | sed -f "$tmp"/sed-ignore-removed \
>                   > "$destdir/$dir$ignore"
>
> gnulib-tool does *not* add blank lines.
> gnulib-tool does *not* sort the files.
> gnulib-tool preserves comments in the files.

Hi Bruno,
I should have investigated before saying more.  Sorry.
As you note, the problem was in bootstrap, not gnulib-tool.

I would have simply modified the sed script in sort_patterns,
but doing that would have required using GNU-sed-specific ERE support.
Here's the original:

# 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//
  }'
}

Changing the substitution to s/^\n*// would solve it if
we could also get empty lines into the hold space.
However, to get both ! lines and empty ones, you'd have
to use a pattern like this: /^\(!\|$\)/
which is not portable.

Instead, I've just added the readable and portable filter:

   | sed '/^$/d'


>From 90d0c4909f2b77d711ea6332a99a9332ff1bab36 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 22 Jun 2011 08:21:05 +0200
Subject: [PATCH] bootstrap: do not insert a blank line into each .gitignore
 file

* build-aux/bootstrap (sort_patterns): Filter out blank lines.
---
 ChangeLog           |    5 +++++
 build-aux/bootstrap |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 36d72ae..2663e32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-22  Jim Meyering  <address@hidden>
+
+       bootstrap: do not insert a blank line into each .gitignore file
+       * build-aux/bootstrap (sort_patterns): Filter out blank lines.
+
 2011-06-21  Eric Blake  <address@hidden>

        perror: test for output mismatch
diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 522ac70..b286beb 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2011-05-16.16; # UTC
+scriptversion=2011-06-22.06; # UTC

 # Bootstrap this package from checked-out sources.

@@ -290,7 +290,7 @@ sort_patterns() {
     P
     x
     s/^\n//
-  }'
+  }' | sed '/^$/d'
 }

 # If $STR is not already on a line by itself in $FILE, insert it,
--
1.7.6.rc2.295.gb63f3



reply via email to

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