bootstrap: Simplify git submodule initialization.
authorBruno Haible <bruno@clisp.org>
Sat, 13 Apr 2024 22:08:50 +0000 (00:08 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 13 Apr 2024 22:08:50 +0000 (00:08 +0200)
* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): Err out if git is
older than version 1.6.4. Remove fallback code for older versions.
* build-aux/bootstrap: Regenerated.

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

index c9349f22aca7779e36375082e3e50b343db497f3..a6878807bab8bba26fe0bba2106902035cc27e75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-13  Bruno Haible  <bruno@clisp.org>
+
+       bootstrap: Simplify git submodule initialization.
+       * top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): Err out if git is
+       older than version 1.6.4. Remove fallback code for older versions.
+       * build-aux/bootstrap: Regenerated.
+
 2024-04-13  Collin Funk  <collin.funk1@gmail.com>
 
        Improve 'git diff' of Python files.
index ef9161d75ed2e5cd77244c9a0789c6b6f5f6db44..70e567b2ad33867d1424b32861f4397d0cd8871f 100755 (executable)
@@ -500,6 +500,12 @@ prepare_GNULIB_SRCDIR ()
       || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
              "but does not contain gnulib-tool"
   elif $use_git; then
+    if git submodule -h | grep -- --reference > /dev/null; then
+      :
+    else
+      die "git version is too old, git >= 1.6.4 is required"
+    fi
+
     gnulib_path=$(git_modules_config submodule.gnulib.path)
     test -z "$gnulib_path" && gnulib_path=gnulib
 
@@ -510,25 +516,8 @@ prepare_GNULIB_SRCDIR ()
        && git_modules_config submodule.gnulib.url >/dev/null; then
       # Use GNULIB_REFDIR as a reference.
       echo "$0: getting gnulib files..."
-      if git submodule -h|grep -- --reference > /dev/null; then
-        # Prefer the one-liner available in git 1.6.4 or newer.
-        git submodule update --init --reference "$GNULIB_REFDIR" \
-          "$gnulib_path" || exit $?
-      else
-        # This fallback allows at least git 1.5.5.
-        if test -f "$gnulib_path"/gnulib-tool; then
-          # Since file already exists, assume submodule init already complete.
-          git submodule update -- "$gnulib_path" || exit $?
-        else
-          # Older git can't clone into an empty directory.
-          rmdir "$gnulib_path" 2>/dev/null
-          git clone --reference "$GNULIB_REFDIR" \
-            "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
-            && git submodule init -- "$gnulib_path" \
-            && git submodule update -- "$gnulib_path" \
-            || exit $?
-        fi
-      fi
+      git submodule update --init --reference "$GNULIB_REFDIR" \
+        "$gnulib_path" || exit $?
     else
       # GNULIB_REFDIR is not set or not usable. Ignore it.
       if git_modules_config submodule.gnulib.url >/dev/null; then
index 64896ff4e538a9bfcc1f9138052a65a851fb8bae..e0d3ab900df468e35de0fcc195eacf660ffd4d22 100644 (file)
@@ -463,6 +463,12 @@ prepare_GNULIB_SRCDIR ()
       || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \
              "but does not contain gnulib-tool"
   elif $use_git; then
+    if git submodule -h | grep -- --reference > /dev/null; then
+      :
+    else
+      die "git version is too old, git >= 1.6.4 is required"
+    fi
+
     gnulib_path=$(git_modules_config submodule.gnulib.path)
     test -z "$gnulib_path" && gnulib_path=gnulib
 
@@ -473,25 +479,8 @@ prepare_GNULIB_SRCDIR ()
        && git_modules_config submodule.gnulib.url >/dev/null; then
       # Use GNULIB_REFDIR as a reference.
       echo "$0: getting gnulib files..."
-      if git submodule -h|grep -- --reference > /dev/null; then
-        # Prefer the one-liner available in git 1.6.4 or newer.
-        git submodule update --init --reference "$GNULIB_REFDIR" \
-          "$gnulib_path" || exit $?
-      else
-        # This fallback allows at least git 1.5.5.
-        if test -f "$gnulib_path"/gnulib-tool; then
-          # Since file already exists, assume submodule init already complete.
-          git submodule update -- "$gnulib_path" || exit $?
-        else
-          # Older git can't clone into an empty directory.
-          rmdir "$gnulib_path" 2>/dev/null
-          git clone --reference "$GNULIB_REFDIR" \
-            "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
-            && git submodule init -- "$gnulib_path" \
-            && git submodule update -- "$gnulib_path" \
-            || exit $?
-        fi
-      fi
+      git submodule update --init --reference "$GNULIB_REFDIR" \
+        "$gnulib_path" || exit $?
     else
       # GNULIB_REFDIR is not set or not usable. Ignore it.
       if git_modules_config submodule.gnulib.url >/dev/null; then