]> Savannah Git Hosting - gnulib.git/commitdiff
bootstrap: Support a tag name as GNULIB_REVISION.
authorBruno Haible <bruno@clisp.org>
Thu, 9 Jan 2025 08:37:41 +0000 (09:37 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 9 Jan 2025 08:37:41 +0000 (09:37 +0100)
* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): If $GNULIB_REVISION
is a tag name, make sure to add that tag.
* build-aux/bootstrap: Regenerated.

ChangeLog
build-aux/bootstrap
top/bootstrap-funclib.sh

index a1179e22b1efdbafb51a3fcaa832f5a76bec3688..c8556a54f3565580f355b55f00504f056ab7f71f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-09  Bruno Haible  <bruno@clisp.org>
+
+       bootstrap: Support a tag name as GNULIB_REVISION.
+       * top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): If $GNULIB_REVISION
+       is a tag name, make sure to add that tag.
+       * build-aux/bootstrap: Regenerated.
+
 2025-01-08  Bruno Haible  <bruno@clisp.org>
 
        sys_select-h: Define suseconds_t on native Windows.
index cacb3d5fef29ad2a6bd19975f0758cb0fe95fa25..f6a62143156a90c113636255b37923f72ce9175e 100755 (executable)
@@ -37,7 +37,7 @@ medir=`dirname "$me"`
 
 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
 
-scriptlibversion=2024-11-25.15; # UTC
+scriptlibversion=2025-01-09.08; # UTC
 
 # Copyright (C) 2003-2025 Free Software Foundation, Inc.
 #
@@ -587,7 +587,6 @@ prepare_GNULIB_SRCDIR ()
             if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
               shallow='--depth 2'
             fi
-            mkdir -p "$gnulib_path"
             # Only want a shallow checkout of $GNULIB_REVISION, but git does not
             # support cloning by commit hash. So attempt a shallow fetch by
             # commit hash to minimize the amount of data downloaded and changes
@@ -596,13 +595,31 @@ prepare_GNULIB_SRCDIR ()
             # shallow fetch cannot be performed because we do not know what the
             # depth of the commit is without fetching all commits. So fall back
             # to fetching all commits.
+            # $GNULIB_REVISION can be a commit id, a tag name, or a branch name.
+            mkdir -p "$gnulib_path"
             git -C "$gnulib_path" init
             git -C "$gnulib_path" remote add origin "$gnulib_url"
-            git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
-              || git -C "$gnulib_path" fetch origin \
-              || cleanup_gnulib
-            git -C "$gnulib_path" reset --hard FETCH_HEAD
-            git -C "$gnulib_path" checkout "$GNULIB_REVISION" || cleanup_gnulib
+            if git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION"
+            then
+              # "git fetch" of the specific commit succeeded.
+              git -C "$gnulib_path" reset --hard FETCH_HEAD \
+                || cleanup_gnulib
+              # "git fetch" does not fetch tags (at least in git version 2.43).
+              # If $GNULIB_REVISION is a tag (not a commit id or branch name),
+              # add the tag explicitly.
+              revision=`git -C "$gnulib_path" log -1 --pretty=format:%H`
+              branch=`LC_ALL=C git -C "$gnulib_path" remote show origin \
+                      | sed -n -e 's/^    \([^ ]*\) * tracked$/\1/p'`
+              test "$revision" = "$GNULIB_REVISION" \
+                || test "$branch" = "$GNULIB_REVISION" \
+                || git -C "$gnulib_path" tag "$GNULIB_REVISION"
+            else
+              # Fetch the entire repository.
+              git -C "$gnulib_path" fetch origin \
+                || cleanup_gnulib
+              git -C "$gnulib_path" checkout "$GNULIB_REVISION" \
+                || cleanup_gnulib
+            fi
           fi
         fi
         trap - HUP INT PIPE TERM
index 793c7e60e5f9bf3674cdd60d17f3ffdb2177482b..a48bd63bb218576fef86d11f9787da898038dec4 100644 (file)
@@ -1,6 +1,6 @@
 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
 
-scriptlibversion=2024-11-25.15; # UTC
+scriptlibversion=2025-01-09.08; # UTC
 
 # Copyright (C) 2003-2025 Free Software Foundation, Inc.
 #
@@ -550,7 +550,6 @@ prepare_GNULIB_SRCDIR ()
             if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
               shallow='--depth 2'
             fi
-            mkdir -p "$gnulib_path"
             # Only want a shallow checkout of $GNULIB_REVISION, but git does not
             # support cloning by commit hash. So attempt a shallow fetch by
             # commit hash to minimize the amount of data downloaded and changes
@@ -559,13 +558,31 @@ prepare_GNULIB_SRCDIR ()
             # shallow fetch cannot be performed because we do not know what the
             # depth of the commit is without fetching all commits. So fall back
             # to fetching all commits.
+            # $GNULIB_REVISION can be a commit id, a tag name, or a branch name.
+            mkdir -p "$gnulib_path"
             git -C "$gnulib_path" init
             git -C "$gnulib_path" remote add origin "$gnulib_url"
-            git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
-              || git -C "$gnulib_path" fetch origin \
-              || cleanup_gnulib
-            git -C "$gnulib_path" reset --hard FETCH_HEAD
-            git -C "$gnulib_path" checkout "$GNULIB_REVISION" || cleanup_gnulib
+            if git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION"
+            then
+              # "git fetch" of the specific commit succeeded.
+              git -C "$gnulib_path" reset --hard FETCH_HEAD \
+                || cleanup_gnulib
+              # "git fetch" does not fetch tags (at least in git version 2.43).
+              # If $GNULIB_REVISION is a tag (not a commit id or branch name),
+              # add the tag explicitly.
+              revision=`git -C "$gnulib_path" log -1 --pretty=format:%H`
+              branch=`LC_ALL=C git -C "$gnulib_path" remote show origin \
+                      | sed -n -e 's/^    \([^ ]*\) * tracked$/\1/p'`
+              test "$revision" = "$GNULIB_REVISION" \
+                || test "$branch" = "$GNULIB_REVISION" \
+                || git -C "$gnulib_path" tag "$GNULIB_REVISION"
+            else
+              # Fetch the entire repository.
+              git -C "$gnulib_path" fetch origin \
+                || cleanup_gnulib
+              git -C "$gnulib_path" checkout "$GNULIB_REVISION" \
+                || cleanup_gnulib
+            fi
           fi
         fi
         trap - HUP INT PIPE TERM