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