]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.sh: Improve sort order of directories.
authorBruno Haible <bruno@clisp.org>
Thu, 11 Apr 2024 13:08:01 +0000 (15:08 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 11 Apr 2024 13:08:01 +0000 (15:08 +0200)
* gnulib-tool.sh (func_import): In file fileset-changes, store directory
names without a trailing slash.

ChangeLog
gnulib-tool.sh

index 1a8d73612755f280298da0114bd7c04477b24b31..9476206e2c8792fc6f9ca7ab4d6ad7ddd9bff145 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-11  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.sh: Improve sort order of directories.
+       * gnulib-tool.sh (func_import): In file fileset-changes, store directory
+       names without a trailing slash.
+
 2024-04-11  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.sh: Remove './' prefix from file names to update or remove.
index 6335228c46bacfd509ff56c961d69c27f464c4b1..507607376f32aefbabd518122b26a56bae69621a 100755 (executable)
@@ -6270,10 +6270,10 @@ s,//*$,/,'
 
   if test "$vc_files" != false; then
     # Update the .cvsignore and .gitignore files.
-    { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
-      echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
+    { echo "$added_files" | sed -e '/^$/d' -e 's,^\([^/]*\)$,./\1,' -e 's,/\([^/]*\)$,|A|\1,'
+      echo "$removed_files" | sed -e '/^$/d' -e 's,^\([^/]*\)$,./\1,' -e 's,/\([^/]*\)$,|R|\1,'
       # Treat gnulib-comp.m4 like an added file, even if it already existed.
-      echo "$m4base/|A|gnulib-comp.m4"
+      echo "$m4base|A|gnulib-comp.m4"
     } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
     { # Rearrange file descriptors. Needed because "while ... done < ..."
       # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
@@ -6353,8 +6353,13 @@ s,//*$,/,'
       last_dir_added=
       last_dir_removed=
       while read line; do
-        # Why not ''read next_dir op file'' ? Because the dir column can be empty.
+        # Why not ''read next_dir op file'' ? Because I hate working with IFS.
         next_dir=`echo "$line" | sed -e 's,|.*,,'`
+        if test "$next_dir" = '.'; then
+          next_dir=
+        else
+          next_dir="$next_dir/"
+        fi
         op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
         file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
         if test "$next_dir" != "$last_dir"; then