From 6f2711645f131e2dc53611a499d68fe09eb79623 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 11 Apr 2024 15:08:01 +0200 Subject: [PATCH] gnulib-tool.sh: Improve sort order of directories. * gnulib-tool.sh (func_import): In file fileset-changes, store directory names without a trailing slash. --- ChangeLog | 6 ++++++ gnulib-tool.sh | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a8d736127..9476206e2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-04-11 Bruno Haible + + 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 gnulib-tool.sh: Remove './' prefix from file names to update or remove. diff --git a/gnulib-tool.sh b/gnulib-tool.sh index 6335228c46..507607376f 100755 --- a/gnulib-tool.sh +++ b/gnulib-tool.sh @@ -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 -- 2.39.5