summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-17 13:50:27 -0700
committerJunio C Hamano <gitster@pobox.com>2017-03-17 13:50:27 -0700
commit81944e9b54039f8475d1df5c40e5a1055eae14f6 (patch)
tree7380115d867612f500f48bc89e6ccc9046e809a3
parent58e97730d9868364ea63afbf3ee94fc9b3f3a075 (diff)
parentf18f816cb1586e9aab3e30a7144768e0d282d305 (diff)
downloadgit-81944e9b54039f8475d1df5c40e5a1055eae14f6.tar.gz
Merge branch 'bc/sha1-header-selection-with-cpp-macros'
Our source code has used the SHA1_HEADER cpp macro after "#include" in the C code to switch among the SHA-1 implementations. Instead, list the exact header file names and switch among implementations using "#ifdef BLK_SHA1/#include "block-sha1/sha1.h"/.../#endif"; this helps some IDE tools. * bc/sha1-header-selection-with-cpp-macros: hash.h: move SHA-1 implementation selection into a header file
-rw-r--r--Makefile12
-rw-r--r--cache.h2
-rw-r--r--hash.h14
3 files changed, 20 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index ba524f3a78..a5a11e721a 100644
--- a/Makefile
+++ b/Makefile
@@ -1384,19 +1384,19 @@ ifdef APPLE_COMMON_CRYPTO
endif
ifdef BLK_SHA1
- SHA1_HEADER = "block-sha1/sha1.h"
LIB_OBJS += block-sha1/sha1.o
+ BASIC_CFLAGS += -DSHA1_BLK
else
ifdef PPC_SHA1
- SHA1_HEADER = "ppc/sha1.h"
LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
+ BASIC_CFLAGS += -DSHA1_PPC
else
ifdef APPLE_COMMON_CRYPTO
COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
- SHA1_HEADER = <CommonCrypto/CommonDigest.h>
+ BASIC_CFLAGS += -DSHA1_APPLE
else
- SHA1_HEADER = <openssl/sha.h>
EXTLIBS += $(LIB_4_CRYPTO)
+ BASIC_CFLAGS += -DSHA1_OPENSSL
endif
endif
endif
@@ -1588,7 +1588,6 @@ endif
# Shell quote (do not use $(call) to accommodate ancient setups);
-SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
@@ -1621,8 +1620,7 @@ PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA))
# from the dependency list, that would make each entry appear twice.
LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
-BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
- $(COMPAT_CFLAGS)
+BASIC_CFLAGS += $(COMPAT_CFLAGS)
LIB_OBJS += $(COMPAT_OBJS)
# Quote for C
diff --git a/cache.h b/cache.h
index dc261f40dd..26f336b00f 100644
--- a/cache.h
+++ b/cache.h
@@ -10,8 +10,8 @@
#include "trace.h"
#include "string-list.h"
#include "pack-revindex.h"
+#include "hash.h"
-#include SHA1_HEADER
#ifndef platform_SHA_CTX
/*
* platform's underlying implementation of SHA-1; could be OpenSSL,
diff --git a/hash.h b/hash.h
new file mode 100644
index 0000000000..f0d9ddd0c2
--- /dev/null
+++ b/hash.h
@@ -0,0 +1,14 @@
+#ifndef HASH_H
+#define HASH_H
+
+#if defined(SHA1_PPC)
+#include "ppc/sha1.h"
+#elif defined(SHA1_APPLE)
+#include <CommonCrypto/CommonDigest.h>
+#elif defined(SHA1_OPENSSL)
+#include <openssl/sha.h>
+#else /* SHA1_BLK */
+#include "block-sha1/sha1.h"
+#endif
+
+#endif