From: Elijah Newren <newren@gmail•com>
To: git@vger•kernel.org
Cc: Elijah Newren <newren@gmail•com>, Calvin Wan <calvinwan@google•com>
Subject: [PATCH v3 14/23] object.h: move some inline functions and defines from cache.h
Date: Tue, 11 Apr 2023 00:41:55 -0700 [thread overview]
Message-ID: <20230411074204.3024420-9-newren@gmail.com> (raw)
In-Reply-To: <20230411074204.3024420-1-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. That makes S_ISGITLINK and some other defines make sense to go
with it, as well as the create_ce_mode() and canon_mode() inline
functions. Move all these inline functions and defines from cache.h to
object.h.
Signed-off-by: Elijah Newren <newren@gmail•com>
Acked-by: Calvin Wan <calvinwan@google•com>
---
cache.h | 42 ------------------------------------------
object.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 42 deletions(-)
diff --git a/cache.h b/cache.h
index 89987cca22a..394e8d01254 100644
--- a/cache.h
+++ b/cache.h
@@ -28,18 +28,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.
*
@@ -155,8 +143,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;
@@ -197,17 +183,6 @@ static inline unsigned create_ce_flags(unsigned stage)
#define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
#define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
-static inline unsigned int create_ce_mode(unsigned int mode)
-{
- if (S_ISLNK(mode))
- return S_IFLNK;
- if (S_ISSPARSEDIR(mode))
- return S_IFDIR;
- if (S_ISDIR(mode) || S_ISGITLINK(mode))
- return S_IFGITLINK;
- return S_IFREG | ce_permissions(mode);
-}
static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
unsigned int mode)
{
@@ -234,16 +209,6 @@ static inline int ce_to_dtype(const struct cache_entry *ce)
else
return DT_UNKNOWN;
}
-static inline unsigned int canon_mode(unsigned int mode)
-{
- if (S_ISREG(mode))
- return S_IFREG | ce_permissions(mode);
- if (S_ISLNK(mode))
- return S_IFLNK;
- if (S_ISDIR(mode))
- return S_IFDIR;
- return S_IFGITLINK;
-}
static inline int ce_path_match(struct index_state *istate,
const struct cache_entry *ce,
@@ -414,13 +379,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/object.h b/object.h
index fc45b158da0..96e52e24fb1 100644
--- a/object.h
+++ b/object.h
@@ -101,6 +101,50 @@ 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;
+}
+
+#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
+static inline unsigned int create_ce_mode(unsigned int mode)
+{
+ if (S_ISLNK(mode))
+ return S_IFLNK;
+ if (S_ISSPARSEDIR(mode))
+ return S_IFDIR;
+ if (S_ISDIR(mode) || S_ISGITLINK(mode))
+ return S_IFGITLINK;
+ return S_IFREG | ce_permissions(mode);
+}
+
+static inline unsigned int canon_mode(unsigned int mode)
+{
+ if (S_ISREG(mode))
+ return S_IFREG | ce_permissions(mode);
+ if (S_ISLNK(mode))
+ return S_IFLNK;
+ if (S_ISDIR(mode))
+ return S_IFDIR;
+ return S_IFGITLINK;
+}
+
/*
* The object type is stored in 3 bits.
*/
--
2.40.0.172.g72fe1174621
next prev parent reply other threads:[~2023-04-11 7:43 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 14/24] object.h: move an inline function and some defines from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 15/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 16/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 17/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 18/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 19/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 20/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 21/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 22/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 23/24] chdir-notify, quote: replace cache.h include with path.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
2023-04-03 16:23 ` [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren
2023-04-04 1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 14/24] object.h: move some inline functions and defines from cache.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 15/24] treewide: remove cache.h inclusion due to object.h changes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 16/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 17/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 18/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 19/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 20/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 21/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
2023-04-05 17:28 ` Calvin Wan
2023-04-07 6:07 ` Elijah Newren
2023-04-10 15:52 ` Calvin Wan
2023-04-10 16:47 ` Elijah Newren
2023-04-04 1:22 ` [PATCH v2 22/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 23/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
2023-04-04 1:22 ` [PATCH v2 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
2023-04-05 17:30 ` [PATCH v2 00/24] Header cleanups (splitting up cache.h) Calvin Wan
2023-04-07 7:08 ` Elijah Newren
2023-04-10 15:54 ` Calvin Wan
2023-04-11 3:00 ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
2023-04-11 3:00 ` [PATCH v3 01/23] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
2023-04-11 3:00 ` [PATCH v3 02/23] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
2023-04-11 3:00 ` [PATCH v3 03/23] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
2023-04-11 3:00 ` [PATCH v3 04/23] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
2023-04-11 3:00 ` [PATCH v3 05/23] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
2023-04-11 7:41 ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
2023-04-11 7:41 ` [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion Elijah Newren
2023-04-15 11:06 ` [PATCH/RFD] fix connection via git protocol Michael J Gruber
2023-04-16 5:47 ` Elijah Newren
2023-04-16 5:51 ` Elijah Newren
2023-04-16 11:21 ` Michael J Gruber
2023-04-17 7:38 ` Jeff King
2023-04-17 16:33 ` Junio C Hamano
2023-04-17 18:31 ` Junio C Hamano
2023-04-18 3:39 ` Jeff King
2023-04-18 20:47 ` Junio C Hamano
2023-04-18 1:56 ` Elijah Newren
2023-04-18 3:40 ` Jeff King
2023-04-17 16:29 ` Junio C Hamano
2023-04-18 1:55 ` Elijah Newren
2023-04-18 21:00 ` Junio C Hamano
2023-04-18 21:24 ` Eric Sunshine
2023-04-19 3:16 ` Elijah Newren
2023-04-24 20:57 ` Junio C Hamano
2023-04-19 3:15 ` Elijah Newren
2023-04-11 7:41 ` [PATCH v3 08/23] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren
2023-04-11 7:41 ` [PATCH v3 09/23] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren
2023-04-11 7:41 ` [PATCH v3 10/23] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren
2023-04-11 7:41 ` [PATCH v3 11/23] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren
2023-04-11 7:41 ` [PATCH v3 12/23] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren
2023-04-11 7:41 ` [PATCH v3 13/23] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren
2023-04-11 7:41 ` Elijah Newren [this message]
2023-04-11 7:41 ` [PATCH v3 15/23] treewide: remove cache.h inclusion due to object.h changes Elijah Newren
2023-04-11 7:41 ` [PATCH v3 16/23] editor: move editor-related functions and declarations into common file Elijah Newren
2023-04-11 7:41 ` [PATCH v3 17/23] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren
2023-04-11 7:41 ` [PATCH v3 18/23] pager.h: move declarations for pager.c functions from cache.h Elijah Newren
2023-04-11 7:42 ` [PATCH v3 19/23] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren
2023-04-11 7:42 ` [PATCH v3 20/23] cache.h: remove unnecessary includes Elijah Newren
2023-04-11 7:42 ` [PATCH v3 21/23] treewide: remove double forward declaration of read_in_full Elijah Newren
2023-04-11 7:42 ` [PATCH v3 22/23] treewide: reduce includes of cache.h in other headers Elijah Newren
2023-04-11 7:42 ` [PATCH v3 23/23] mailmap, quote: move declarations of global vars to correct unit Elijah Newren
2023-04-11 7:47 ` [PATCH v3 00/23] Header cleanups (splitting up cache.h) Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230411074204.3024420-9-newren@gmail.com \
--to=newren@gmail$(echo .)com \
--cc=calvinwan@google$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox