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

[PATCH 14/24] object.h: move an inline function and some defines from cache.h

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 1, 2023, 15:10 UTC
Message-ID
<fa58cf82c66c7bb8e6e441b7e5fa5b5ac45f301b.1680361840.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1509.git.1680361837.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

The object_type() inline function is very tied to the enum object_type declaration within object.h, and just seemed to make more sense to live there. Move it, and as a side-effect, remove a bunch of dependencies on cache.h that are no longer needed.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 bundle.c            |  2 +-
 cache.h             | 21 ---------------------
 delta-islands.c     |  2 +-
 fsck.c              |  2 +-
 http-push.c         |  2 +-
 list-objects.c      |  2 +-
 object.h            | 21 +++++++++++++++++++++
 pack-bitmap-write.c |  2 +-
 submodule-config.c  |  2 +-
 walker.c            |  2 +-
 10 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/bundle.c b/bundle.c
index 6471489975a..a5505368de5 100644
--- a/bundle.c
+++ b/bundle.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
 #include "environment.h"
diff --git a/cache.h b/cache.h
index f02c7c9609d..f5eaea341c2 100644
--- a/cache.h
+++ b/cache.h
@@ -29,18 +29,6 @@
 #define DTYPE(de)	DT_UNKNOWN
 #endif
 
-/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
-#define S_IFINVALID     0030000
-
-/*
- * A "directory link" is a link to another git directory.
- *
- * The value 0160000 is not normally a valid mode, and
- * also just happens to be S_IFDIR + S_IFLNK
- */
-#define S_IFGITLINK	0160000
-#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
-
 /*
  * Some mode bits are also used internally for computations.
  *
@@ -156,8 +144,6 @@ struct cache_entry {
 #error "CE_EXTENDED_FLAGS out of range"
 #endif
 
-#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
-
 /* Forward structure decls */
 struct pathspec;
 struct child_process;
@@ -415,13 +401,6 @@ void prefetch_cache_entries(const struct index_state *istate,
 extern struct index_state the_index;
 #endif
 
-static inline enum object_type object_type(unsigned int mode)
-{
-	return S_ISDIR(mode) ? OBJ_TREE :
-		S_ISGITLINK(mode) ? OBJ_COMMIT :
-		OBJ_BLOB;
-}
-
 #define INIT_DB_QUIET 0x0001
 #define INIT_DB_EXIST_OK 0x0002
 
diff --git a/delta-islands.c b/delta-islands.c
index 40f2ccfb550..c824a5f6a42 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "attr.h"
 #include "object.h"
diff --git a/fsck.c b/fsck.c
index 8ef1b022346..adbe8bf59e7 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/http-push.c b/http-push.c
index a8af6c0f690..637a4e91f7a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/list-objects.c b/list-objects.c
index df18d103063..eecca721ac0 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/object.h b/object.h
index fc45b158da0..568cddfc2b4 100644
--- a/object.h
+++ b/object.h
@@ -101,6 +101,27 @@ enum object_type {
 	OBJ_MAX
 };
 
+/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
+#define S_IFINVALID     0030000
+
+/*
+ * A "directory link" is a link to another git directory.
+ *
+ * The value 0160000 is not normally a valid mode, and
+ * also just happens to be S_IFDIR + S_IFLNK
+ */
+#define S_IFGITLINK	0160000
+#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
+
+#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
+
+static inline enum object_type object_type(unsigned int mode)
+{
+	return S_ISDIR(mode) ? OBJ_TREE :
+		S_ISGITLINK(mode) ? OBJ_COMMIT :
+		OBJ_BLOB;
+}
+
 /*
  * The object type is stored in 3 bits.
  */
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 7f5f489beb0..faf67c94d37 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/submodule-config.c b/submodule-config.c
index 252b90aa439..7fc0812b644 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/walker.c b/walker.c
index cfbd257fdba..24ff7dfdc28 100644
--- a/walker.c
+++ b/walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "walker.h"
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 14 of 101 in “Header cleanups (splitting up cache.h)”
  1. 00/24 Header cleanups (splitting up cache.h)Elijah Newren via GitGitGadget, Apr 1, 2023
  2. 03/24 treewide: be explicit about dependence on convert.hElijah Newren via GitGitGadget, Apr 1, 2023
  3. 01/24 treewide: be explicit about dependence on trace.h & trace2.hElijah Newren via GitGitGadget, Apr 1, 2023
  4. 02/24 treewide: be explicit about dependence on advice.hElijah Newren via GitGitGadget, Apr 1, 2023
  5. 04/24 treewide: be explicit about dependence on pack-revindex.hElijah Newren via GitGitGadget, Apr 1, 2023
  6. 05/24 treewide: be explicit about dependence on oid-array.hElijah Newren via GitGitGadget, Apr 1, 2023
  7. 06/24 treewide: be explicit about dependence on mem-pool.hElijah Newren via GitGitGadget, Apr 1, 2023
  8. 10/24 git-zlib: move declarations for git-zlib functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  9. 07/24 treewide: remove unnecessary cache.h inclusionElijah Newren via GitGitGadget, Apr 1, 2023
  10. 09/24 treewide: remove cache.h inclusion due to object-name.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  11. 11/24 treewide: remove cache.h inclusion due to git-zlib changesElijah Newren via GitGitGadget, Apr 1, 2023
  12. 13/24 treewide: remove cache.h inclusion due to object-file.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  13. 08/24 object-name.h: move declarations for object-name.c functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  14. 14/24 object.h: move an inline function and some defines from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  15. 17/24 pager.h: move declarations for pager.c functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  16. 12/24 object-file.h: move declarations for object-file.c functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  17. 16/24 treewide: remove cache.h inclusion due to editor.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  18. 20/24 strbuf: move forward declarations to beginning of fileElijah Newren via GitGitGadget, Apr 1, 2023
  19. 19/24 cache.h: remove unnecessary includesElijah Newren via GitGitGadget, Apr 1, 2023
  20. 15/24 editor: move editor-related functions and declarations into common fileElijah Newren via GitGitGadget, Apr 1, 2023
  21. 23/24 chdir-notify, quote: replace cache.h include with path.hElijah Newren via GitGitGadget, Apr 1, 2023
  22. 22/24 treewide: reduce includes of cache.h in other headersElijah Newren via GitGitGadget, Apr 1, 2023
  23. 21/24 treewide: remove double forward declaration of read_in_fullElijah Newren via GitGitGadget, Apr 1, 2023
  24. 18/24 treewide: remove cache.h inclusion due to pager.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  25. 24/24 mailmap, quote: move declarations of global vars to correct unitElijah Newren via GitGitGadget, Apr 1, 2023
  26. Elijah NewrenApr 3, 2023
  27. 00/24 Header cleanups (splitting up cache.h)Elijah Newren via GitGitGadget, Apr 4, 2023
  28. 01/24 treewide: be explicit about dependence on trace.h & trace2.hElijah Newren via GitGitGadget, Apr 4, 2023
  29. 04/24 treewide: be explicit about dependence on pack-revindex.hElijah Newren via GitGitGadget, Apr 4, 2023
  30. 05/24 treewide: be explicit about dependence on oid-array.hElijah Newren via GitGitGadget, Apr 4, 2023
  31. 03/24 treewide: be explicit about dependence on convert.hElijah Newren via GitGitGadget, Apr 4, 2023
  32. 06/24 treewide: be explicit about dependence on mem-pool.hElijah Newren via GitGitGadget, Apr 4, 2023
  33. 02/24 treewide: be explicit about dependence on advice.hElijah Newren via GitGitGadget, Apr 4, 2023
  34. 07/24 treewide: remove unnecessary cache.h inclusionElijah Newren via GitGitGadget, Apr 4, 2023
  35. 11/24 treewide: remove cache.h inclusion due to git-zlib changesElijah Newren via GitGitGadget, Apr 4, 2023
  36. 10/24 git-zlib: move declarations for git-zlib functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  37. 09/24 treewide: remove cache.h inclusion due to object-name.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  38. 08/24 object-name.h: move declarations for object-name.c functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  39. 13/24 treewide: remove cache.h inclusion due to object-file.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  40. 17/24 treewide: remove cache.h inclusion due to editor.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  41. 14/24 object.h: move some inline functions and defines from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  42. 12/24 object-file.h: move declarations for object-file.c functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  43. 15/24 treewide: remove cache.h inclusion due to object.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  44. 16/24 editor: move editor-related functions and declarations into common fileElijah Newren via GitGitGadget, Apr 4, 2023
  45. 20/24 cache.h: remove unnecessary includesElijah Newren via GitGitGadget, Apr 4, 2023
  46. 18/24 pager.h: move declarations for pager.c functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  47. 19/24 treewide: remove cache.h inclusion due to pager.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  48. 22/24 treewide: remove double forward declaration of read_in_fullElijah Newren via GitGitGadget, Apr 4, 2023
  49. 21/24 strbuf: move forward declarations to beginning of fileElijah Newren via GitGitGadget, Apr 4, 2023
  50. Calvin WanApr 5, 2023
  51. Elijah NewrenApr 7, 2023
  52. Calvin WanApr 10, 2023
  53. Elijah NewrenApr 10, 2023
  54. 24/24 mailmap, quote: move declarations of global vars to correct unitElijah Newren via GitGitGadget, Apr 4, 2023
  55. 23/24 treewide: reduce includes of cache.h in other headersElijah Newren via GitGitGadget, Apr 4, 2023
  56. Calvin WanApr 5, 2023
  57. Elijah NewrenApr 7, 2023
  58. Calvin WanApr 10, 2023
  59. 00/23 Header cleanups (splitting up cache.h)Elijah Newren via GitGitGadget, Apr 11, 2023
  60. 02/23 treewide: be explicit about dependence on advice.hElijah Newren via GitGitGadget, Apr 11, 2023
  61. 03/23 treewide: be explicit about dependence on convert.hElijah Newren via GitGitGadget, Apr 11, 2023
  62. 01/23 treewide: be explicit about dependence on trace.h & trace2.hElijah Newren via GitGitGadget, Apr 11, 2023
  63. 04/23 treewide: be explicit about dependence on pack-revindex.hElijah Newren via GitGitGadget, Apr 11, 2023
  64. 05/23 treewide: be explicit about dependence on oid-array.hElijah Newren via GitGitGadget, Apr 11, 2023
  65. 06/23 treewide: be explicit about dependence on mem-pool.hElijah Newren, Apr 11, 2023
  66. 07/23 treewide: remove unnecessary cache.h inclusionElijah Newren, Apr 11, 2023
  67. fix connection via git protocolMichael J Gruber, Apr 15, 2023
  68. Elijah NewrenApr 16, 2023
  69. Elijah NewrenApr 16, 2023
  70. Michael J GruberApr 16, 2023
  71. Jeff KingApr 17, 2023
  72. Junio C HamanoApr 17, 2023
  73. Junio C HamanoApr 17, 2023
  74. Jeff KingApr 18, 2023
  75. Junio C HamanoApr 18, 2023
  76. Elijah NewrenApr 18, 2023
  77. Jeff KingApr 18, 2023
  78. Junio C HamanoApr 17, 2023
  79. Elijah NewrenApr 18, 2023
  80. Junio C HamanoApr 18, 2023
  81. Eric SunshineApr 18, 2023
  82. Elijah NewrenApr 19, 2023
  83. Junio C HamanoApr 24, 2023
  84. Elijah NewrenApr 19, 2023
  85. 09/23 treewide: remove cache.h inclusion due to object-name.h changesElijah Newren, Apr 11, 2023
  86. 10/23 git-zlib: move declarations for git-zlib functions from cache.hElijah Newren, Apr 11, 2023
  87. 08/23 object-name.h: move declarations for object-name.c functions from cache.hElijah Newren, Apr 11, 2023
  88. 11/23 treewide: remove cache.h inclusion due to git-zlib changesElijah Newren, Apr 11, 2023
  89. 13/23 treewide: remove cache.h inclusion due to object-file.h changesElijah Newren, Apr 11, 2023
  90. 12/23 object-file.h: move declarations for object-file.c functions from cache.hElijah Newren, Apr 11, 2023
  91. 14/23 object.h: move some inline functions and defines from cache.hElijah Newren, Apr 11, 2023
  92. 15/23 treewide: remove cache.h inclusion due to object.h changesElijah Newren, Apr 11, 2023
  93. 16/23 editor: move editor-related functions and declarations into common fileElijah Newren, Apr 11, 2023
  94. 17/23 treewide: remove cache.h inclusion due to editor.h changesElijah Newren, Apr 11, 2023
  95. 18/23 pager.h: move declarations for pager.c functions from cache.hElijah Newren, Apr 11, 2023
  96. 19/23 treewide: remove cache.h inclusion due to pager.h changesElijah Newren, Apr 11, 2023
  97. 20/23 cache.h: remove unnecessary includesElijah Newren, Apr 11, 2023
  98. 21/23 treewide: remove double forward declaration of read_in_fullElijah Newren, Apr 11, 2023
  99. 22/23 treewide: reduce includes of cache.h in other headersElijah Newren, Apr 11, 2023
  100. 23/23 mailmap, quote: move declarations of global vars to correct unitElijah Newren, Apr 11, 2023
  101. Elijah NewrenApr 11, 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.