Hi Benno, > In build-aux/bootstrap there is this fragment of code: > > if git clone -h 2>&1 | grep -- --depth > /dev/null; then > shallow='--depth 2' > fi > > But the output of `git clone -h` nowadays (version 2.48.1) does > not contain the option --depth. It instead contains this: > > --[no-]depth <depth> create a shallow clone of that depth > > Meaning that the clone will always be full, instead of shallow as > seemingly was intended.
And likewise for 'git fetch -h', a few lines below that. Testing with a few older 'git' binaries that I happen to have lying around: $ git clone -h 2>&1 | grep depth 1.4.4: 1.5.0.rc4: Usage: .../bin/git-clone [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [--depth <n>] [-n] <repo> [<dir>] 2.22.0: --depth <depth> create a shallow clone of that depth 2.43.0: --[no-]depth <depth> create a shallow clone of that depth $ git fetch -h 2>&1 | grep depth 1.6.3.2: 1.7.1: --depth <DEPTH> deepen history of shallow clone 2.22.0: --depth <depth> deepen history of shallow clone 2.43.0: --[no-]depth <depth> deepen history of shallow clone So, the --depth option - in 'git clone' was introduced before git 1.5.0.rc4 (2007-02-08), - in 'git fetch' was introduced before git 1.7.1 (2010-04-24). We can safely assume that no one is using 'git' binaries from 2010 or older for active development. Thus I'm removing these feature checks: 2025-02-16 Bruno Haible <br...@clisp.org> bootstrap: Fix recognition of --depth option with recent git releases. Reported by Benno Schulenberg <bensb...@telfort.nl> in <https://lists.gnu.org/archive/html/bug-gnulib/2025-02/msg00106.html>. * top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): Assume that 'git clone' and 'git fetch' support the --depth option. * build-aux/bootstrap: Regenerated. diff --git a/build-aux/bootstrap b/build-aux/bootstrap index 2d174cedbd..fef3cbcd37 100755 --- a/build-aux/bootstrap +++ b/build-aux/bootstrap @@ -37,7 +37,7 @@ medir=`dirname "$me"` # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. -scriptlibversion=2025-02-04.01; # UTC +scriptlibversion=2025-02-16.12; # UTC # Copyright (C) 2003-2025 Free Software Foundation, Inc. # @@ -580,17 +580,11 @@ prepare_GNULIB_SRCDIR () || cleanup_gnulib else # GNULIB_REFDIR is not set or not usable. Ignore it. - shallow= + shallow='--depth 2' if test -z "$GNULIB_REVISION"; then - if git clone -h 2>&1 | grep -- --depth > /dev/null; then - shallow='--depth 2' - fi git clone $shallow "$gnulib_url" "$gnulib_path" \ || cleanup_gnulib else - if git fetch -h 2>&1 | grep -- --depth > /dev/null; then - shallow='--depth 2' - fi # 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 diff --git a/top/bootstrap-funclib.sh b/top/bootstrap-funclib.sh index 1ad3d85a41..47e015bd24 100644 --- a/top/bootstrap-funclib.sh +++ b/top/bootstrap-funclib.sh @@ -1,6 +1,6 @@ # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. -scriptlibversion=2025-02-04.01; # UTC +scriptlibversion=2025-02-16.12; # UTC # Copyright (C) 2003-2025 Free Software Foundation, Inc. # @@ -543,17 +543,11 @@ prepare_GNULIB_SRCDIR () || cleanup_gnulib else # GNULIB_REFDIR is not set or not usable. Ignore it. - shallow= + shallow='--depth 2' if test -z "$GNULIB_REVISION"; then - if git clone -h 2>&1 | grep -- --depth > /dev/null; then - shallow='--depth 2' - fi git clone $shallow "$gnulib_url" "$gnulib_path" \ || cleanup_gnulib else - if git fetch -h 2>&1 | grep -- --depth > /dev/null; then - shallow='--depth 2' - fi # 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