diff bootstrap-funclib.sh @ 33477:3362e398d702

Update to gnulib revision 92d80242ad1344b5364ca9bd1d995d68c3a73ef7. * bootstrap-funclib.sh: Update from gnulib. * bootstrap.conf: Update GNULIB_REVISION and remove comments about local changes to bootstrap-funclib.sh. * build-aux/gnulib-bootstrap-git-fetch.diff: Delete patch that is no longer needed.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 28 Apr 2024 12:03:16 +0200
parents 321f49a98a85
children
line wrap: on
line diff
--- a/bootstrap-funclib.sh	Sat Apr 27 17:33:00 2024 +0200
+++ b/bootstrap-funclib.sh	Sun Apr 28 12:03:16 2024 +0200
@@ -1,6 +1,6 @@
 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
 
-scriptlibversion=2024-04-13.15; # UTC
+scriptlibversion=2024-04-28.09; # UTC
 
 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
 #
@@ -462,7 +462,17 @@
       || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
              "but does not contain gnulib-tool"
     if test -n "$GNULIB_REVISION" && $use_git; then
-      (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || exit $?
+      # The 'git checkout "$GNULIB_REVISION"' command succeeds if the
+      # GNULIB_REVISION is a commit hash that exists locally, or if it is
+      # branch name that can be fetched from origin. It fails, however,
+      # if the GNULIB_REVISION is a commit hash that only exists in
+      # origin. In this case, we need a 'git fetch' and then retry
+      # 'git checkout "$GNULIB_REVISION"'.
+      (cd "$GNULIB_SRCDIR" \
+       && { git checkout "$GNULIB_REVISION" 2>/dev/null \
+            || { git fetch origin && git checkout "$GNULIB_REVISION"; }
+          }
+      ) || exit $?
     fi
   else
     if ! $use_git; then
@@ -532,11 +542,17 @@
         # The subdirectory 'gnulib' already exists.
         if test -n "$GNULIB_REVISION"; then
           if test -d "$gnulib_path/.git"; then
-            if ! git --git-dir="$gnulib_path"/.git cat-file \
-                 commit "$GNULIB_REVISION"; then
-              git --git-dir="$gnulib_path"/.git fetch
-            fi
-            (cd "$gnulib_path" && git checkout "$GNULIB_REVISION") || exit 1
+            # The 'git checkout "$GNULIB_REVISION"' command succeeds if the
+            # GNULIB_REVISION is a commit hash that exists locally, or if it is
+            # branch name that can be fetched from origin. It fails, however,
+            # if the GNULIB_REVISION is a commit hash that only exists in
+            # origin. In this case, we need a 'git fetch' and then retry
+            # 'git checkout "$GNULIB_REVISION"'.
+            (cd "$gnulib_path" \
+             && { git checkout "$GNULIB_REVISION" 2>/dev/null \
+                  || { git fetch origin && git checkout "$GNULIB_REVISION"; }
+                }
+            ) || exit $?
           else
             die "Error: GNULIB_REVISION is specified in bootstrap.conf," \
                 "but '$gnulib_path' contains no git history"