Skip to content

Commit c296666

Browse files
committed
Merge branch 'jt/help-sha-backend-info-in-build-options' into jch
"git help --build-options" reports SHA-1 and SHA-256 backends used in the build. * jt/help-sha-backend-info-in-build-options: help: include unsafe SHA-1 build info in version help: include SHA implementation in version info
2 parents 2788150 + 84fcb4b commit c296666

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

Documentation/git-version.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ OPTIONS
2222
--build-options::
2323
Include additional information about how git was built for diagnostic
2424
purposes.
25+
+
26+
If built to use a faster SHA-1 implementation for non-cryptographic purposes,
27+
the implmentation used is denoted as "unsafe-SHA-1".
2528

2629
GIT
2730
---

help.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,41 @@ char *help_unknown_cmd(const char *cmd)
768768
exit(1);
769769
}
770770

771+
static void get_sha_impl(struct strbuf *buf)
772+
{
773+
#if defined(SHA1_OPENSSL)
774+
strbuf_addstr(buf, "SHA-1: OpenSSL\n");
775+
#elif defined(SHA1_BLK)
776+
strbuf_addstr(buf, "SHA-1: blk\n");
777+
#elif defined(SHA1_APPLE)
778+
strbuf_addstr(buf, "SHA-1: Apple CommonCrypto\n");
779+
#elif defined(DC_SHA1_EXTERNAL)
780+
strbuf_addstr(buf, "SHA-1: Collision Detection (External)\n");
781+
#elif defined(DC_SHA1_SUBMODULE)
782+
strbuf_addstr(buf, "SHA-1: Collision Detection (Submodule)\n");
783+
#elif defined(SHA1_DC)
784+
strbuf_addstr(buf, "SHA-1: Collision Detection\n");
785+
#endif
786+
787+
#if defined(SHA1_OPENSSL_UNSAFE)
788+
strbuf_addstr(buf, "unsafe-SHA-1: OpenSSL\n");
789+
#elif defined(SHA1_BLK_UNSAFE)
790+
strbuf_addstr(buf, "unsafe-SHA-1: blk\n");
791+
#elif defined(SHA1_APPLE_UNSAFE)
792+
strbuf_addstr(buf, "unsafe-SHA-1: Apple CommonCrypto\n");
793+
#endif
794+
795+
#if defined(SHA256_OPENSSL)
796+
strbuf_addstr(buf, "SHA-256: OpenSSL\n");
797+
#elif defined(SHA256_NETTLE)
798+
strbuf_addstr(buf, "SHA-256: Nettle\n");
799+
#elif defined(SHA256_GCRYPT)
800+
strbuf_addstr(buf, "SHA-256: gcrypt\n");
801+
#elif defined(SHA256_BLK)
802+
strbuf_addstr(buf, "SHA-256: blk\n");
803+
#endif
804+
}
805+
771806
void get_version_info(struct strbuf *buf, int show_build_options)
772807
{
773808
/*
@@ -803,6 +838,7 @@ void get_version_info(struct strbuf *buf, int show_build_options)
803838
#elif defined ZLIB_VERSION
804839
strbuf_addf(buf, "zlib: %s\n", ZLIB_VERSION);
805840
#endif
841+
get_sha_impl(buf);
806842
}
807843
}
808844

0 commit comments

Comments
 (0)