]> Cypherpunks repositories - gostls13.git/commit
cmd/go: support sha1 repos when git default is sha256
authorDavid Finkel <david.finkel@gmail.com>
Fri, 14 Nov 2025 02:16:43 +0000 (21:16 -0500)
committerSean Liao <sean@liao.dev>
Fri, 21 Nov 2025 21:29:38 +0000 (13:29 -0800)
commit6aeacdff3889bc743f2baf8e8239b8cb83afd807
tree6991d651ac1a73d4acf5e0690c194ce5b5bd8849
parent9570036ca5a95bff4c6768288a7c1db68277b9c0
cmd/go: support sha1 repos when git default is sha256

When git is recent enough (beyond 2.29), always set the --object-format
flag.

This fixes repo cloning when users have set the git configuration
init.defaultObjectFormat to sha256.

Git is planning[1] to switch the default hash function to sha256 with
the 3.0 release sometime in late 2026. (that may slip, but it's still
worth being ahead of the curve)

This change moves the version-check function from cl/698835 into
codehost/git.go so we can use it to condition setting
--object-format=sha1.

Adjust the regexp parsing git version output to handle more cases.

[1]: https://lore.kernel.org/lkml/xmqqikikk1hr.fsf@gitster.g/T/#u

Updates #68359
Change-Id: I7d59eb4e116b8afb47d3d1ca068d75eb5047d5c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/720500
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/modfetch/codehost/git.go
src/cmd/go/internal/modfetch/codehost/git_test.go
src/cmd/go/internal/vcweb/script.go
src/cmd/go/scriptconds_test.go