Subject: [PATCH 2/2] help: include unsafe SHA-1 build info in version

From: Justin Tobler <[email-masked]>
Date: Fri, 28 Mar 2025 12:01:21 -0500

In 06c92dafb8 (Makefile: allow specifying a SHA-1 for non-cryptographic
uses, 2024-09-26), support for unsafe SHA-1 is added. Add the unsafe
SHA-1 build info to `git version --build-info` and update corresponding
documentation.

Signed-off-by: Justin Tobler <[email-masked]>
---
 Documentation/git-version.adoc | 3 +++
 help.c                         | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/Documentation/git-version.adoc b/Documentation/git-version.adoc
index 80fa7754a6..53c8ba74c1 100644
--- a/Documentation/git-version.adoc
+++ b/Documentation/git-version.adoc
@@ -22,6 +22,9 @@ OPTIONS
 --build-options::
 	Include additional information about how git was built for diagnostic
 	purposes.
++
+If built to use a faster SHA-1 implementation for non-cryptographic purposes,
+the implmentation used is denoted as "unsafe-SHA-1".
 
 GIT
 ---
diff --git a/help.c b/help.c
index 32b5d4e6f5..7670e0a64a 100644
--- a/help.c
+++ b/help.c
@@ -784,6 +784,14 @@ static void get_sha_impl(struct strbuf *buf)
 	strbuf_addstr(buf, "SHA-1: Collision Detection\n");
 #endif
 
+#if defined(SHA1_OPENSSL_UNSAFE)
+	strbuf_addstr(buf, "unsafe-SHA-1: OpenSSL\n");
+#elif defined(SHA1_BLK_UNSAFE)
+	strbuf_addstr(buf, "unsafe-SHA-1: blk\n");
+#elif defined(SHA1_APPLE_UNSAFE)
+	strbuf_addstr(buf, "unsafe-SHA-1: Apple CommonCrypto\n");
+#endif
+
 #if defined(SHA256_OPENSSL)
 	strbuf_addstr(buf, "SHA-256: OpenSSL\n");
 #elif defined(SHA256_NETTLE)
-- 
2.49.0