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

[PATCH 06/16] hash.h: move some oid-related declarations from cache.h

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 23, 2023, 08:05 UTC
Message-ID
<9f78f0f215595d55ead4d82d20e1d0c9892171ec.1677139522.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1485.git.1677139521.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

These defines and enum are all oid-related and as such seem to make more sense being included in hash.h. Further, moving them there allows us to remove some includes of cache.h in other files.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                                      | 34 --------------------
 diffcore.h                                   |  4 ++-
 hash.h                                       | 34 ++++++++++++++++++++
 line-log.h                                   |  1 +
 submodule-config.h                           |  1 -
 t/helper/test-submodule-nested-repo-config.c |  1 +
 tree-walk.h                                  |  4 ++-
 7 files changed, 42 insertions(+), 37 deletions(-)
diff --git a/cache.h b/cache.h
index 0f1f9dde56b..daf6150bb3c 100644
--- a/cache.h
+++ b/cache.h
@@ -1363,40 +1363,6 @@ struct object_context {
 	char *path;
 };
 
-#define GET_OID_QUIETLY           01
-#define GET_OID_COMMIT            02
-#define GET_OID_COMMITTISH        04
-#define GET_OID_TREE             010
-#define GET_OID_TREEISH          020
-#define GET_OID_BLOB             040
-#define GET_OID_FOLLOW_SYMLINKS 0100
-#define GET_OID_RECORD_PATH     0200
-#define GET_OID_ONLY_TO_DIE    04000
-#define GET_OID_REQUIRE_PATH  010000
-
-#define GET_OID_DISAMBIGUATORS \
-	(GET_OID_COMMIT | GET_OID_COMMITTISH | \
-	GET_OID_TREE | GET_OID_TREEISH | \
-	GET_OID_BLOB)
-
-enum get_oid_result {
-	FOUND = 0,
-	MISSING_OBJECT = -1, /* The requested object is missing */
-	SHORT_NAME_AMBIGUOUS = -2,
-	/* The following only apply when symlinks are followed */
-	DANGLING_SYMLINK = -4, /*
-				* The initial symlink is there, but
-				* (transitively) points to a missing
-				* in-tree file
-				*/
-	SYMLINK_LOOP = -5,
-	NOT_DIR = -6, /*
-		       * Somewhere along the symlink chain, a path is
-		       * requested which contains a file as a
-		       * non-final element.
-		       */
-};
-
 int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
 __attribute__((format (printf, 2, 3)))
 int get_oidf(struct object_id *oid, const char *fmt, ...);
diff --git a/diffcore.h b/diffcore.h
index 9b588a1ee15..1701ed50b9c 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -4,9 +4,11 @@
 #ifndef DIFFCORE_H
 #define DIFFCORE_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct diff_options;
+struct mem_pool;
+struct oid_array;
 struct repository;
 struct strintmap;
 struct strmap;
diff --git a/hash.h b/hash.h
index 351afc2ce3b..d39f73618cb 100644
--- a/hash.h
+++ b/hash.h
@@ -123,6 +123,40 @@ struct object_id {
 	int algo;	/* XXX requires 4-byte alignment */
 };
 
+#define GET_OID_QUIETLY           01
+#define GET_OID_COMMIT            02
+#define GET_OID_COMMITTISH        04
+#define GET_OID_TREE             010
+#define GET_OID_TREEISH          020
+#define GET_OID_BLOB             040
+#define GET_OID_FOLLOW_SYMLINKS 0100
+#define GET_OID_RECORD_PATH     0200
+#define GET_OID_ONLY_TO_DIE    04000
+#define GET_OID_REQUIRE_PATH  010000
+
+#define GET_OID_DISAMBIGUATORS \
+	(GET_OID_COMMIT | GET_OID_COMMITTISH | \
+	GET_OID_TREE | GET_OID_TREEISH | \
+	GET_OID_BLOB)
+
+enum get_oid_result {
+	FOUND = 0,
+	MISSING_OBJECT = -1, /* The requested object is missing */
+	SHORT_NAME_AMBIGUOUS = -2,
+	/* The following only apply when symlinks are followed */
+	DANGLING_SYMLINK = -4, /*
+				* The initial symlink is there, but
+				* (transitively) points to a missing
+				* in-tree file
+				*/
+	SYMLINK_LOOP = -5,
+	NOT_DIR = -6, /*
+		       * Somewhere along the symlink chain, a path is
+		       * requested which contains a file as a
+		       * non-final element.
+		       */
+};
+
 /* A suitably aligned type for stack allocations of hash contexts. */
 union git_hash_ctx {
 	git_SHA_CTX sha1;
diff --git a/line-log.h b/line-log.h
index 82ae8d98a40..adff361b1bc 100644
--- a/line-log.h
+++ b/line-log.h
@@ -5,6 +5,7 @@
 
 struct rev_info;
 struct commit;
+struct string_list;
 
 /* A range [start,end].  Lines are numbered starting at 0, and the
  * ranges include start but exclude end. */
diff --git a/submodule-config.h b/submodule-config.h
index 28a8ca6bf46..c2045875bbb 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -1,7 +1,6 @@
 #ifndef SUBMODULE_CONFIG_CACHE_H
 #define SUBMODULE_CONFIG_CACHE_H
 
-#include "cache.h"
 #include "config.h"
 #include "hashmap.h"
 #include "submodule.h"
diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c
index dc1c14bde37..a3848a8b668 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -1,4 +1,5 @@
 #include "test-tool.h"
+#include "cache.h"
 #include "submodule-config.h"
 
 static void die_usage(const char **argv, const char *msg)
diff --git a/tree-walk.h b/tree-walk.h
index 6305d531503..25fe27e3529 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -1,7 +1,9 @@
 #ifndef TREE_WALK_H
 #define TREE_WALK_H
 
-#include "cache.h"
+#include "hash.h"
+
+struct index_state;
 
 #define MAX_TRAVERSE_TREES 8
 
-- 
gitgitgadget
Previous: Derrick StoleeNext: Derrick Stolee
Message 13 of 60 in “Header cleanups”
  1. 00/16 Header cleanupsElijah Newren via GitGitGadget, Feb 23, 2023
  2. 01/16 treewide: ensure one of the appropriate headers is sourced firstElijah Newren via GitGitGadget, Feb 23, 2023
  3. 02/16 treewide: remove unnecessary git-compat-util.h includes in headersElijah Newren via GitGitGadget, Feb 23, 2023
  4. Derrick StoleeFeb 23, 2023
  5. Elijah NewrenFeb 23, 2023
  6. Junio C HamanoFeb 23, 2023
  7. Elijah NewrenFeb 23, 2023
  8. Junio C HamanoFeb 23, 2023
  9. Elijah NewrenFeb 23, 2023
  10. 03/16 treewide: remove unnecessary cache.h includesElijah Newren via GitGitGadget, Feb 23, 2023
  11. 04/16 treewide: remove unnecessary cache.h includes in source filesElijah Newren via GitGitGadget, Feb 23, 2023
  12. Derrick StoleeFeb 23, 2023
  13. 06/16 hash.h: move some oid-related declarations from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  14. Derrick StoleeFeb 23, 2023
  15. Elijah NewrenFeb 23, 2023
  16. Jonathan TanFeb 24, 2023
  17. 05/16 alloc.h: move ALLOC_GROW() functions from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  18. Derrick StoleeFeb 23, 2023
  19. Elijah NewrenFeb 23, 2023
  20. Junio C HamanoFeb 23, 2023
  21. Junio C HamanoFeb 23, 2023
  22. 07/16 hex.h: move some hex-related declarations from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  23. Derrick StoleeFeb 23, 2023
  24. Elijah NewrenFeb 23, 2023
  25. 09/16 ident.h: move ident-related declarations out of cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  26. 08/16 pretty.h: move has_non_ascii() declaration from commit.hElijah Newren via GitGitGadget, Feb 23, 2023
  27. 10/16 object.h: stop depending on cache.h; make cache.h depend on object.hElijah Newren via GitGitGadget, Feb 23, 2023
  28. Derrick StoleeFeb 23, 2023
  29. Elijah NewrenFeb 23, 2023
  30. 11/16 dir.h: refactor to no longer need to include cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  31. 12/16 object-store.h: move struct object_info from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  32. Derrick StoleeFeb 23, 2023
  33. Elijah NewrenFeb 23, 2023
  34. 13/16 replace-object.h: move read_replace_refs declaration from cache.h to hereElijah Newren via GitGitGadget, Feb 23, 2023
  35. 15/16 Remove unnecessary includes of builtin.hElijah Newren via GitGitGadget, Feb 23, 2023
  36. 14/16 treewide: replace cache.h with more direct headers, where possibleElijah Newren via GitGitGadget, Feb 23, 2023
  37. 16/16 diff.h: remove unnecessary include of object.hElijah Newren via GitGitGadget, Feb 23, 2023
  38. Derrick StoleeFeb 23, 2023
  39. 00/17 Header cleanupsElijah Newren via GitGitGadget, Feb 24, 2023
  40. 01/17 treewide: ensure one of the appropriate headers is sourced firstElijah Newren via GitGitGadget, Feb 24, 2023
  41. 02/17 treewide: remove unnecessary git-compat-util.h includes in headersElijah Newren via GitGitGadget, Feb 24, 2023
  42. 03/17 treewide: remove unnecessary cache.h includesElijah Newren via GitGitGadget, Feb 24, 2023
  43. 04/17 treewide: remove unnecessary cache.h includes in source filesElijah Newren via GitGitGadget, Feb 24, 2023
  44. 06/17 hash.h: move some oid-related declarations from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  45. 07/17 hex.h: move some hex-related declarations from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  46. 09/17 pretty.h: move has_non_ascii() declaration from commit.hElijah Newren via GitGitGadget, Feb 24, 2023
  47. 05/17 alloc.h: move ALLOC_GROW() functions from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  48. 10/17 ident.h: move ident-related declarations out of cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  49. 11/17 object.h: stop depending on cache.h; make cache.h depend on object.hElijah Newren via GitGitGadget, Feb 24, 2023
  50. 12/17 dir.h: refactor to no longer need to include cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  51. 13/17 object-store.h: move struct object_info from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  52. 15/17 treewide: replace cache.h with more direct headers, where possibleElijah Newren via GitGitGadget, Feb 24, 2023
  53. 14/17 replace-object.h: move read_replace_refs declaration from cache.h to hereElijah Newren via GitGitGadget, Feb 24, 2023
  54. 16/17 Remove unnecessary includes of builtin.hElijah Newren via GitGitGadget, Feb 24, 2023
  55. 08/17 cache.h: remove dependence on hex.h; make other files include it explicitlyElijah Newren via GitGitGadget, Feb 24, 2023
  56. 17/17 diff.h: remove unnecessary include of object.hElijah Newren via GitGitGadget, Feb 24, 2023
  57. Johannes SchindelinFeb 24, 2023
  58. Jonathan TanFeb 25, 2023
  59. Elijah NewrenFeb 25, 2023
  60. Derrick StoleeFeb 27, 2023

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.