Re: bootstrap fails with SHA256 default object format

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <3258741.9fHWaBTJ5E@cagnes>
Him

Seth McDonald wrote:
> I believe I've found a bug in Gnulib's bootstrap functionality.  When
> attempting to ./bootstrap Libntlm 1.8 (from [0]), I ran into this error:
> 
> 	$ ./bootstrap
> 	./bootstrap: Bootstrapping from checked-out libntlm sources...
> 	./bootstrap: getting gnulib files...
> 	Initialized empty Git repository in /[...]/gnulib/.git/
> 	warning: redirecting to https://https.git.savannah.gnu.org/git/gnulib.git/
> 	fatal: couldn't find remote ref dfb71172a46ef41f8cf8ab7ca529c1dd3097a41d
> 	warning: redirecting to https://https.git.savannah.gnu.org/git/gnulib.git/
> 	fatal: mismatched algorithms: client sha256; server sha1
> 
> I eventually remembered I have init.defaultObjectFormat set to sha256 in
> my global git config.  And after temporarily changing it to sha1,
> ./bootstrap appeared to work.
> 
> Usually this shouldn't occur, since I believe git-clone sets the object
> format automatically to the same as upstream.  But after grepping
> Libntlm's bootstrap scripts, I found that it instead invokes git-init
> and manually adds the upstream with git-remote.  From
> bootstrap-funclib.sh, lines 527-529 (see [1]):
> 
> 	git -C "$gnulib_path" init
> 	git -C "$gnulib_path" remote add origin \
> 	    ${GNULIB_URL:-$default_gnulib_url}

Yes. We do this in order to save network bandwidth.

> And briefly searching the current Gnulib repo, it appears this is still
> the case.  From top/bootstrap.sh, lines 564-565 (see [2]):
> 
> 	git -C "$gnulib_path" -c init.defaultBranch=master init
> 	git -C "$gnulib_path" remote add origin "$gnulib_url"
> 
> This explains the bug.  git-init initialises the repo with a SHA256
> object format, then git-remote adds an upstream with a SHA1 object
> format.

Thanks for the report.

> As such, the bug can be fixed by appending --object-format=sha1 to the
> git-init command, which forces git to initialise the repo with a SHA1
> object format regardless of the global default.

We can't do this, because the option --object-format=sha1 was only introduced
in git version 2.27 (2020), which is too new. We can't assume all users of
Gnulib have a git version that is this new.

> I've tested this with
> the same Libntlm repository and it appears to work.

Instead I'm applying the patch below. Can you please test whether it works
for you?

Bruno


2026-08-09  Bruno Haible  <[email protected]>

	bootstrap: Fix error "client sha256; server sha1" seen by some users.
	Reported by Seth McDonald <[email protected]> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2026-08/msg00149.html>.
	* top/bootstrap-funclib.sh (prepare_GNULIB_SRCDIR): Force sha1 object
	format in "git init" command.
	* build-aux/bootstrap: Regenerated.

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 19f9424bb6..da6337aa9d 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-12-04.19; # UTC
+scriptlibversion=2026-08-09.13; # UTC
 
 # Copyright (C) 2003-2026 Free Software Foundation, Inc.
 #
@@ -597,8 +597,12 @@ prepare_GNULIB_SRCDIR ()
             mkdir -p "$gnulib_path"
             # Use a -c option to silence an annoying message
             # "hint: Using 'master' as the name for the initial branch."
-            # (cf. <https://stackoverflow.com/questions/65524512/>).
-            git -C "$gnulib_path" -c init.defaultBranch=master init
+            # (cf. <https://stackoverflow.com/questions/65524512/>)
+            # and another -c option to override a configuration
+            # init.defaultObjectFormat=sha256 that some users have installed.
+            git -C "$gnulib_path" -c init.defaultBranch=master \
+                                  -c init.defaultObjectFormat=sha1 \
+                                  init
             git -C "$gnulib_path" remote add origin "$gnulib_url"
             if git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION"
             then
diff --git a/top/bootstrap-funclib.sh b/top/bootstrap-funclib.sh
index 8a0116a76f..679c4916ab 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-12-04.19; # UTC
+scriptlibversion=2026-08-09.13; # UTC
 
 # Copyright (C) 2003-2026 Free Software Foundation, Inc.
 #
@@ -560,8 +560,12 @@ prepare_GNULIB_SRCDIR ()
             mkdir -p "$gnulib_path"
             # Use a -c option to silence an annoying message
             # "hint: Using 'master' as the name for the initial branch."
-            # (cf. <https://stackoverflow.com/questions/65524512/>).
-            git -C "$gnulib_path" -c init.defaultBranch=master init
+            # (cf. <https://stackoverflow.com/questions/65524512/>)
+            # and another -c option to override a configuration
+            # init.defaultObjectFormat=sha256 that some users have installed.
+            git -C "$gnulib_path" -c init.defaultBranch=master \
+                                  -c init.defaultObjectFormat=sha1 \
+                                  init
             git -C "$gnulib_path" remote add origin "$gnulib_url"
             if git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION"
             then
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.