git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jan 28, 2018, 15:57 UTC
Message-ID
<20180128155722.880805-2-sandals@crustytoothpaste.net>
In-Reply-To
<20180128155722.880805-1-sandals@crustytoothpaste.net>

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 <sandals@crustytoothpaste.net>
---
 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_Final    	SHA1_Final
-#endif
-
-#define git_SHA_CTX		platform_SHA_CTX
-#define git_SHA1_Init		platform_SHA1_Init
-#define git_SHA1_Update		platform_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_Update		git_SHA1_Update_Chunked
-#endif
-
 #include <zlib.h>
 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_Final    	SHA1_Final
+#endif
+
+#define git_SHA_CTX		platform_SHA_CTX
+#define git_SHA1_Init		platform_SHA1_Init
+#define git_SHA1_Update		platform_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_Update		git_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
Previous: brian m. carlsonNext: brian m. carlson
Message 2 of 22 in “object_id part 11 (the_hash_algo)”
  1. 00/12 object_id part 11 (the_hash_algo)brian m. carlson, Jan 28, 2018
  2. 01/12 hash: move SHA-1 macros to hash.hbrian m. carlson, Jan 28, 2018
  3. 04/12 builtin/unpack-objects: switch uses of SHA-1 to the_hash_algobrian m. carlson, Jan 28, 2018
  4. 05/12 sha1_file: switch uses of SHA-1 to the_hash_algobrian m. carlson, Jan 28, 2018
  5. 06/12 fast-import: switch various uses of SHA-1 to the_hash_algobrian m. carlson, Jan 28, 2018
  6. Patryk ObaraJan 28, 2018
  7. 09/12 read-cache: abstract away uses of SHA-1brian m. carlson, Jan 28, 2018
  8. Eric SunshineJan 28, 2018
  9. brian m. carlsonJan 28, 2018
  10. 12/12 bulk-checkin: abstract SHA-1 usagebrian m. carlson, Jan 28, 2018
  11. 03/12 builtin/index-pack: improve hash function abstractionbrian m. carlson, Jan 28, 2018
  12. 11/12 csum-file: abstract uses of SHA-1brian m. carlson, Jan 28, 2018
  13. 10/12 csum-file: rename sha1file to hashfilebrian m. carlson, Jan 28, 2018
  14. 02/12 hash: create union for hash context allocationbrian m. carlson, Jan 28, 2018
  15. Patryk ObaraJan 28, 2018
  16. brian m. carlsonJan 28, 2018
  17. 07/12 pack-check: convert various uses of SHA-1 to abstract formsbrian m. carlson, Jan 28, 2018
  18. 08/12 pack-write: switch various SHA-1 values to abstract formsbrian m. carlson, Jan 28, 2018
  19. Patryk ObaraJan 28, 2018
  20. brian m. carlsonJan 28, 2018
  21. Patryk ObaraJan 28, 2018
  22. brian m. carlsonJan 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.