Git fork

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 by
requiring each backend to define a SHA1_BACKEND or SHA256_BACKEND symbol
as appropriate and use the value in the printed build options.

Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Justin Tobler and committed by
Junio C Hamano
16fd6c85 683c54c9

+17
+6
Documentation/git-version.adoc
··· 22 22 --build-options:: 23 23 Include additional information about how git was built for diagnostic 24 24 purposes. 25 + + 26 + The libraries used to implement the SHA-1 and SHA-256 algorithms are displayed 27 + in the form `SHA-1: <option>` and `SHA-256: <option>`. Note that the SHA-1 28 + options `SHA1_APPLE`, `SHA1_OPENSSL`, and `SHA1_BLK` do not use a collision 29 + detection algorithm and thus may be vulnerable to known SHA-1 collision 30 + attacks. 25 31 26 32 GIT 27 33 ---
+8
hash.h
··· 2 2 #define HASH_H 3 3 4 4 #if defined(SHA1_APPLE) 5 + #define SHA1_BACKEND "SHA1_APPLE (No collision detection)" 5 6 #include <CommonCrypto/CommonDigest.h> 6 7 #elif defined(SHA1_OPENSSL) 8 + # define SHA1_BACKEND "SHA1_OPENSSL (No collision detection)" 7 9 # include <openssl/sha.h> 8 10 # if defined(OPENSSL_API_LEVEL) && OPENSSL_API_LEVEL >= 3 9 11 # define SHA1_NEEDS_CLONE_HELPER 10 12 # include "sha1/openssl.h" 11 13 # endif 12 14 #elif defined(SHA1_DC) 15 + #define SHA1_BACKEND "SHA1_DC" 13 16 #include "sha1dc_git.h" 14 17 #else /* SHA1_BLK */ 18 + #define SHA1_BACKEND "SHA1_BLK (No collision detection)" 15 19 #include "block-sha1/sha1.h" 16 20 #endif 17 21 ··· 46 50 #endif 47 51 48 52 #if defined(SHA256_NETTLE) 53 + #define SHA256_BACKEND "SHA256_NETTLE" 49 54 #include "sha256/nettle.h" 50 55 #elif defined(SHA256_GCRYPT) 56 + #define SHA256_BACKEND "SHA256_GCRYPT" 51 57 #define SHA256_NEEDS_CLONE_HELPER 52 58 #include "sha256/gcrypt.h" 53 59 #elif defined(SHA256_OPENSSL) 60 + # define SHA256_BACKEND "SHA256_OPENSSL" 54 61 # include <openssl/sha.h> 55 62 # if defined(OPENSSL_API_LEVEL) && OPENSSL_API_LEVEL >= 3 56 63 # define SHA256_NEEDS_CLONE_HELPER 57 64 # include "sha256/openssl.h" 58 65 # endif 59 66 #else 67 + #define SHA256_BACKEND "SHA256_BLK" 60 68 #include "sha256/block/sha256.h" 61 69 #endif 62 70
+3
help.c
··· 9 9 #include "run-command.h" 10 10 #include "levenshtein.h" 11 11 #include "gettext.h" 12 + #include "hash.h" 12 13 #include "help.h" 13 14 #include "command-list.h" 14 15 #include "string-list.h" ··· 803 804 #elif defined ZLIB_VERSION 804 805 strbuf_addf(buf, "zlib: %s\n", ZLIB_VERSION); 805 806 #endif 807 + strbuf_addf(buf, "SHA-1: %s\n", SHA1_BACKEND); 808 + strbuf_addf(buf, "SHA-256: %s\n", SHA256_BACKEND); 806 809 } 807 810 } 808 811