# 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.
#
|| 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
# The subdirectory 'gnulib' already exists.
if test -n "$GNULIB_REVISION"; then
if test -d "$gnulib_path/.git"; then
- (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"