]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
gnulib-tool.sh: Handle .gitignore files that do not end in a newline.
authorBruno Haible <bruno@clisp.org>
Thu, 11 Apr 2024 00:44:03 +0000 (02:44 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 11 Apr 2024 00:44:03 +0000 (02:44 +0200)
* gnulib-tool.sh (func_import): If the .gitignore file ends with a
character other than a newline, add a newline before adding more lines.

ChangeLog
gnulib-tool.sh

index ac263c611fd3733f0c07f053fdeef57fbf8b5a43..4504a32681591afc901e37c02eb05582a497fc94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-04-10  Bruno Haible  <bruno@clisp.org>
+
+       gnulib-tool.sh: Handle .gitignore files that do not end in a newline.
+       * gnulib-tool.sh (func_import): If the .gitignore file ends with a
+       character other than a newline, add a newline before adding more lines.
+
 2024-04-10  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool.py: Skip nonexistent modules instead of failing.
index a8075d991f58d12c870a7085f985210d8899c3dd..e99b8fff7976ac05f21c5d27da135971effa75df 100755 (executable)
@@ -6263,6 +6263,9 @@ s,//*$,/,'
                   if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
                 } > "$tmp"/sed-ignore-removed
                 { cat "$destdir/$dir$ignore"~
+                  # Add a newline if the original $dir$ignore file ended
+                  # with a character other than a newline.
+                  if test `tail -c 1 < "$destdir/$dir$ignore"~ | tr -d '\n' | wc -c` = 1; then echo; fi
                   sed -e "s|^|$anchor|" < "$tmp"/ignore-added
                 } | sed -f "$tmp"/sed-ignore-removed \
                   > "$destdir/$dir$ignore"