Re: [PATCH v2 01/12] hash: move SHA-1 macros to hash.h

2018-02-02 Thread Junio C Hamano
"brian m. carlson"  writes:

> +#ifndef platform_SHA_CTX
> +/*
> + * platform's underlying implementation of SHA-1; could be OpenSSL,
> + * blk_SHA, Apple CommonCrypto, etc...  Note that including
> + * SHA1_HEADER may have already defined platform_SHA_CTX for our
> + * own implementations like block-sha1 and ppc-sha1, so we list
> + * the default for OpenSSL compatible SHA-1 implementations here.
> + */

This nit has been with us for a long time, but "Note that including
SHA1_HEADER may have..." has been way too stale a comment for quite
some time.  It was made different from "including SHA1_HEADER" by
f18f816c ("hash.h: move SHA-1 implementation selection into a header
file", 2017-03-11).

Perhaps

Note that we may have already defined platform_SHA_CTX for our
own implementations like block-sha1 and ppc-sha1, so we list
...

or something.


[PATCH v2 01/12] hash: move SHA-1 macros to hash.h

2018-01-31 Thread brian m. carlson
Most of the other code dealing with SHA-1 and other hashes is located in
hash.h, which is in turn loaded by cache.h.  Move the SHA-1 macros to
hash.h as well, so we can use them in additional hash-related items in
the future.

Signed-off-by: brian m. carlson 
---
 cache.h | 25 -
 hash.h  | 25 +
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/cache.h b/cache.h
index d8b975a571..bfde6f757a 100644
--- a/cache.h
+++ b/cache.h
@@ -16,31 +16,6 @@
 #include "sha1-array.h"
 #include "repository.h"
 
-#ifndef platform_SHA_CTX
-/*
- * platform's underlying implementation of SHA-1; could be OpenSSL,
- * blk_SHA, Apple CommonCrypto, etc...  Note that including
- * SHA1_HEADER may have already defined platform_SHA_CTX for our
- * own implementations like block-sha1 and ppc-sha1, so we list
- * the default for OpenSSL compatible SHA-1 implementations here.
- */
-#define platform_SHA_CTX   SHA_CTX
-#define platform_SHA1_Init SHA1_Init
-#define platform_SHA1_Update   SHA1_Update
-#define platform_SHA1_FinalSHA1_Final
-#endif
-
-#define git_SHA_CTXplatform_SHA_CTX
-#define git_SHA1_Init  platform_SHA1_Init
-#define git_SHA1_Updateplatform_SHA1_Update
-#define git_SHA1_Final platform_SHA1_Final
-
-#ifdef SHA1_MAX_BLOCK_SIZE
-#include "compat/sha1-chunked.h"
-#undef git_SHA1_Update
-#define git_SHA1_Updategit_SHA1_Update_Chunked
-#endif
-
 #include 
 typedef struct git_zstream {
z_stream z;
diff --git a/hash.h b/hash.h
index 7d7a864f5d..7122dea7b3 100644
--- a/hash.h
+++ b/hash.h
@@ -15,6 +15,31 @@
 #include "block-sha1/sha1.h"
 #endif
 
+#ifndef platform_SHA_CTX
+/*
+ * platform's underlying implementation of SHA-1; could be OpenSSL,
+ * blk_SHA, Apple CommonCrypto, etc...  Note that including
+ * SHA1_HEADER may have already defined platform_SHA_CTX for our
+ * own implementations like block-sha1 and ppc-sha1, so we list
+ * the default for OpenSSL compatible SHA-1 implementations here.
+ */
+#define platform_SHA_CTX   SHA_CTX
+#define platform_SHA1_Init SHA1_Init
+#define platform_SHA1_Update   SHA1_Update
+#define platform_SHA1_FinalSHA1_Final
+#endif
+
+#define git_SHA_CTXplatform_SHA_CTX
+#define git_SHA1_Init  platform_SHA1_Init
+#define git_SHA1_Updateplatform_SHA1_Update
+#define git_SHA1_Final platform_SHA1_Final
+
+#ifdef SHA1_MAX_BLOCK_SIZE
+#include "compat/sha1-chunked.h"
+#undef git_SHA1_Update
+#define git_SHA1_Updategit_SHA1_Update_Chunked
+#endif
+
 /*
  * Note that these constants are suitable for indexing the hash_algos array and
  * comparing against each other, but are otherwise arbitrary, so they should 
not