Skip to content

Commit cb6f9e4

Browse files
jltoblergitster
authored andcommitted
help: include SHA implementation in version info
When the `--build-options` flag is used with git-version(1), additional information about the built version of Git is printed. During build time, different SHA implementations may be configured, but this information is not included in the version info. Add the SHA implementations Git is built with to the version info. Signed-off-by: Justin Tobler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 683c54c commit cb6f9e4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

help.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,33 @@ 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(SHA256_OPENSSL)
788+
strbuf_addstr(buf, "SHA-256: OpenSSL\n");
789+
#elif defined(SHA256_NETTLE)
790+
strbuf_addstr(buf, "SHA-256: Nettle\n");
791+
#elif defined(SHA256_GCRYPT)
792+
strbuf_addstr(buf, "SHA-256: gcrypt\n");
793+
#elif defined(SHA256_BLK)
794+
strbuf_addstr(buf, "SHA-256: blk\n");
795+
#endif
796+
}
797+
771798
void get_version_info(struct strbuf *buf, int show_build_options)
772799
{
773800
/*
@@ -803,6 +830,7 @@ void get_version_info(struct strbuf *buf, int show_build_options)
803830
#elif defined ZLIB_VERSION
804831
strbuf_addf(buf, "zlib: %s\n", ZLIB_VERSION);
805832
#endif
833+
get_sha_impl(buf);
806834
}
807835
}
808836

0 commit comments

Comments
 (0)