dir.h: refactor to no longer need to include cache.h
Moving a few functions around allows us to make dir.h no longer need to include cache.h. This commit is best viewed with: git log -1 -p --color-moved Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 24, 2023 at 00:09 UTC
ac48adf488794417b1060b5ed2377a9fd4c33c17
5 files changed
+43
-35
cache.h
+11
-20
@@ -14,9 +14,11 @@
14
#include "pack-revindex.h"
15
#include "hash.h"
16
#include "path.h"
17
+#include "pathspec.h"
18
#include "object.h"
19
#include "oid-array.h"
20
#include "repository.h"
21
+#include "statinfo.h"
22
#include "mem-pool.h"
23
24
typedef struct git_zstream {
@@ -119,26 +121,6 @@ struct cache_header {
121
#define INDEX_FORMAT_LB 2
122
#define INDEX_FORMAT_UB 4
123
122
-/*
123
- * The "cache_time" is just the low 32 bits of the
124
- * time. It doesn't matter if it overflows - we only
125
- * check it for equality in the 32 bits we save.
126
- */
127
-struct cache_time {
128
- uint32_t sec;
129
- uint32_t nsec;
130
-};
131
-
132
-struct stat_data {
133
- struct cache_time sd_ctime;
134
- struct cache_time sd_mtime;
135
- unsigned int sd_dev;
136
- unsigned int sd_ino;
137
- unsigned int sd_uid;
138
- unsigned int sd_gid;
139
- unsigned int sd_size;
140
-};
141
-
124
struct cache_entry {
125
struct hashmap_entry ent;
126
struct stat_data ce_stat_data;
@@ -294,6 +276,15 @@ static inline unsigned int canon_mode(unsigned int mode)
276
return S_IFGITLINK;
277
}
278
279
+static inline int ce_path_match(struct index_state *istate,
280
+ const struct cache_entry *ce,
281
+ const struct pathspec *pathspec,
282
+ char *seen)
283
+{
284
+ return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
285
+ S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
286
+}
287
+
288
#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
289
290
#define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */
dir.h
+2
-14
@@ -1,8 +1,9 @@
1
#ifndef DIR_H
2
#define DIR_H
3
4
-#include "cache.h"
4
#include "hashmap.h"
5
+#include "pathspec.h"
6
+#include "statinfo.h"
7
#include "strbuf.h"
8
9
/**
@@ -363,10 +364,6 @@ int count_slashes(const char *s);
364
int simple_length(const char *match);
365
int no_wildcard(const char *string);
366
char *common_prefix(const struct pathspec *pathspec);
366
-int match_pathspec(struct index_state *istate,
367
- const struct pathspec *pathspec,
368
- const char *name, int namelen,
369
- int prefix, char *seen, int is_dir);
367
int report_path_error(const char *ps_matched, const struct pathspec *pathspec);
368
int within_depth(const char *name, int namelen, int depth, int max_depth);
369
@@ -533,15 +530,6 @@ int submodule_path_match(struct index_state *istate,
530
const char *submodule_name,
531
char *seen);
532
536
-static inline int ce_path_match(struct index_state *istate,
537
- const struct cache_entry *ce,
538
- const struct pathspec *pathspec,
539
- char *seen)
540
-{
541
- return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
542
- S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
543
-}
544
-
533
static inline int dir_path_match(struct index_state *istate,
534
const struct dir_entry *ent,
535
const struct pathspec *pathspec,
pathspec.h
+5
@@ -171,6 +171,11 @@ int match_pathspec_attrs(struct index_state *istate,
171
const char *name, int namelen,
172
const struct pathspec_item *item);
173
174
+int match_pathspec(struct index_state *istate,
175
+ const struct pathspec *pathspec,
176
+ const char *name, int namelen,
177
+ int prefix, char *seen, int is_dir);
178
+
179
/*
180
* Determine whether a pathspec will match only entire index entries (non-sparse
181
* files and/or entire sparse directories). If the pathspec has the potential to
statinfo.h
new
+24
@@ -0,0 +1,24 @@
1
+#ifndef STATINFO_H
2
+#define STATINFO_H
3
+
4
+/*
5
+ * The "cache_time" is just the low 32 bits of the
6
+ * time. It doesn't matter if it overflows - we only
7
+ * check it for equality in the 32 bits we save.
8
+ */
9
+struct cache_time {
10
+ uint32_t sec;
11
+ uint32_t nsec;
12
+};
13
+
14
+struct stat_data {
15
+ struct cache_time sd_ctime;
16
+ struct cache_time sd_mtime;
17
+ unsigned int sd_dev;
18
+ unsigned int sd_ino;
19
+ unsigned int sd_uid;
20
+ unsigned int sd_gid;
21
+ unsigned int sd_size;
22
+};
23
+
24
+#endif
trace2/tr2_sysenv.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include "cache.h"
1
+#include "git-compat-util.h"
2
#include "config.h"
3
#include "dir.h"
4
#include "tr2_sysenv.h"