bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Subject: gnulib-tool: In sh+py mode, don't fail because of dangling symlinks
Date: Sun, 21 Apr 2024 00:31:48 +0200	[thread overview]
Message-ID: <6372494.GgVqTqa4M0@nimes> (raw)
In-Reply-To: <34ecc803-8d4c-4ebd-8121-49dd08229cdb@cs.ucla.edu>

Paul Eggert reported:
> I tried this on my well-worn copy of GNU diffutils, and got the 
> following diagnostics. These were all diagnostics about backup files, or 
> files I manually deleted by moving them into a '.del' subdirectory (an 
> old habit of mine), or symlink loops that I had created to test.
> 
> Perhaps the advice should start with, "Start with a fresh checkout from 
> Git."
> 
> -----
> diff: ./.del/gnulib-tests/test-fnmatch-1.sh: No such file or directory
> diff: /home/eggert/src/gnu/glpyXeRWfy/.del/gnulib-tests/test-fnmatch-1.sh: No such file or directory
> ...

These old files most likely were not backup files, but dangling symlinks.
With dangling symlinks, I can reproduce the error, and this patch fixes it:


2024-04-20  Bruno Haible  <bruno@clisp.org>

	gnulib-tool: In sh+py mode, don't fail because of dangling symlinks.
	Reported by Paul Eggert in
	<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00318.html>
	and Pádraig Brady in
	<https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00321.html>.
	* gnulib-tool: In sh+py mode, use diff option '--no-dereference' if
	available.

diff --git a/gnulib-tool b/gnulib-tool
index d7b6d33912..6d430e56e6 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -192,7 +192,14 @@ case "$GNULIB_TOOL_IMPL" in
           func_fatal_error "gnulib-tool.sh succeeded but gnulib-tool.py failed! Inspect $tmp/ and $tmp-py-err."
         fi
         # Compare the two results on the file system.
-        diff -r -q . "$tmp" >/dev/null ||
+        # GNU diffutils 3.3 or newer support option --no-dereference. This
+        # option avoids errors on dangling links.
+        if LC_ALL=C diff --help 2>/dev/null | grep no-dereference >/dev/null; then
+          diff_options='--no-dereference'
+        else
+          diff_options=
+        fi
+        diff -r $diff_options -q . "$tmp" >/dev/null ||
           func_fatal_error "gnulib-tool.py produced different files than gnulib-tool.sh! Compare `pwd` and $tmp."
         # Compare the two outputs.
         diff -q "$tmp-sh-out" "$tmp-py-out" >/dev/null ||
@@ -235,7 +242,14 @@ case "$GNULIB_TOOL_IMPL" in
           func_fatal_error "gnulib-tool.sh succeeded but gnulib-tool.py failed! Inspect $tmp/ and $tmp-py-err."
         fi
         # Compare the two results on the file system.
-        diff -r -q "$dir" "$tmp" >/dev/null ||
+        # GNU diffutils 3.3 or newer support option --no-dereference. This
+        # option avoids errors on dangling links.
+        if LC_ALL=C diff --help 2>/dev/null | grep no-dereference >/dev/null; then
+          diff_options='--no-dereference'
+        else
+          diff_options=
+        fi
+        diff -r $diff_options -q "$dir" "$tmp" >/dev/null ||
           func_fatal_error "gnulib-tool.py produced different files than gnulib-tool.sh! Compare $dir and $tmp."
         # Compare the two outputs.
         diff -q "$tmp-sh-out" "$tmp-py-out" >/dev/null ||





  reply	other threads:[~2024-04-20 22:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20  0:22 beta-tester call draft Bruno Haible
2024-04-20  0:39 ` Bruno Haible
2024-04-20  0:56 ` Collin Funk
2024-04-20  1:49   ` Bruno Haible
2024-04-20  4:27 ` Paul Eggert
2024-04-20 22:31   ` Bruno Haible [this message]
2024-04-20 22:46   ` Bruno Haible
2024-04-20  9:38 ` Simon Josefsson via Gnulib discussion list
2024-04-20 22:50   ` gnulib-tool.py speedup Bruno Haible
2024-04-20 23:01     ` Collin Funk
2024-04-20 23:50       ` Bruno Haible
2024-04-21  0:53         ` Collin Funk
2024-04-20 10:21 ` beta-tester call draft Pádraig Brady
2024-04-20 13:05 ` Bernhard Voelker
2024-04-20 22:54   ` Bruno Haible
2024-04-20 22:57     ` Paul Eggert
2024-04-20 23:14       ` Bruno Haible
2024-04-21 10:53         ` Bernhard Voelker
2024-04-21 14:50           ` future Python evolution Bruno Haible
2024-04-21 15:14             ` Paul Eggert
2024-04-21 22:38               ` Bruno Haible
2024-04-22  7:05                 ` Paul Eggert
2024-04-21 15:26             ` Bernhard Voelker
2024-04-28 14:14             ` Bernhard Voelker
2024-04-21 15:15           ` beta-tester call draft Janneke Nieuwenhuizen
2024-04-21 16:07             ` full-source bootstrap and Python Bruno Haible
2024-04-22  7:29               ` Simon Josefsson via Gnulib discussion list
2024-04-22 10:07                 ` Bruno Haible
2024-04-22 10:06               ` Janneke Nieuwenhuizen
2024-04-22 11:24                 ` Simon Josefsson via Gnulib discussion list
2024-04-22 15:48                 ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6372494.GgVqTqa4M0@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).