Skip to content

Commit a64215b

Browse files
newrengitster
authored andcommitted
object.h: stop depending on cache.h; make cache.h depend on object.h
Things should be able to depend on object.h without pulling in all of cache.h. Move an enum to allow this. Note that a couple files previously depended on things brought in through cache.h indirectly (revision.h -> commit.h -> object.h -> cache.h). As such, this change requires making existing dependencies more explicit in half a dozen files. The inclusion of strbuf.h in some headers if of particular note: these headers directly embedded a strbuf in some new structs, meaning they should have been including strbuf.h all along but were indirectly getting the necessary definitions. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b5fa608 commit a64215b

17 files changed

+36
-32
lines changed

alloc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* up with maximal alignment because it doesn't know what the object alignment
99
* for the new allocation is.
1010
*/
11-
#include "cache.h"
11+
#include "git-compat-util.h"
1212
#include "object.h"
1313
#include "blob.h"
1414
#include "tree.h"

blame.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef BLAME_H
22
#define BLAME_H
33

4-
#include "cache.h"
54
#include "commit.h"
65
#include "xdiff-interface.h"
76
#include "revision.h"

blob.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "git-compat-util.h"
22
#include "blob.h"
33
#include "repository.h"
44
#include "alloc.h"

cache-tree.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef CACHE_TREE_H
22
#define CACHE_TREE_H
33

4-
#include "cache.h"
54
#include "tree.h"
65
#include "tree-walk.h"
76

cache.h

+1-20
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "pack-revindex.h"
1515
#include "hash.h"
1616
#include "path.h"
17+
#include "object.h"
1718
#include "oid-array.h"
1819
#include "repository.h"
1920
#include "mem-pool.h"
@@ -453,26 +454,6 @@ void prefetch_cache_entries(const struct index_state *istate,
453454
extern struct index_state the_index;
454455
#endif
455456

456-
#define TYPE_BITS 3
457-
458-
/*
459-
* Values in this enum (except those outside the 3 bit range) are part
460-
* of pack file format. See gitformat-pack(5) for more information.
461-
*/
462-
enum object_type {
463-
OBJ_BAD = -1,
464-
OBJ_NONE = 0,
465-
OBJ_COMMIT = 1,
466-
OBJ_TREE = 2,
467-
OBJ_BLOB = 3,
468-
OBJ_TAG = 4,
469-
/* 5 for future expansion */
470-
OBJ_OFS_DELTA = 6,
471-
OBJ_REF_DELTA = 7,
472-
OBJ_ANY,
473-
OBJ_MAX
474-
};
475-
476457
static inline enum object_type object_type(unsigned int mode)
477458
{
478459
return S_ISDIR(mode) ? OBJ_TREE :

diff-merges.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "git-compat-util.h"
22
#include "diff-merges.h"
33

4+
#include "gettext.h"
45
#include "revision.h"
56

67
typedef void (*diff_merges_setup_func_t)(struct rev_info *);

diff.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "pathspec.h"
99
#include "object.h"
1010
#include "oidset.h"
11+
#include "strbuf.h"
1112

1213
/**
1314
* The diff API is for programs that compare two sets of files (e.g. two trees,
@@ -71,7 +72,6 @@ struct oid_array;
7172
struct option;
7273
struct repository;
7374
struct rev_info;
74-
struct strbuf;
7575
struct userdiff_driver;
7676

7777
typedef int (*pathchange_fn_t)(struct diff_options *options,

diffcore-delta.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "git-compat-util.h"
22
#include "diff.h"
33
#include "diffcore.h"
44

fsck.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef GIT_FSCK_H
22
#define GIT_FSCK_H
33

4+
#include "object.h"
45
#include "oidset.h"
56

67
enum fsck_msg_type {

help.c

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "exec-cmd.h"
66
#include "run-command.h"
77
#include "levenshtein.h"
8+
#include "gettext.h"
89
#include "help.h"
910
#include "command-list.h"
1011
#include "string-list.h"

list-objects-filter-options.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifndef LIST_OBJECTS_FILTER_OPTIONS_H
22
#define LIST_OBJECTS_FILTER_OPTIONS_H
33

4-
#include "cache.h"
4+
#include "object.h"
55
#include "parse-options.h"
66
#include "string-list.h"
7+
#include "strbuf.h"
78

89
/*
910
* The list of defined filters for list-objects.

negotiator/noop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cache.h"
1+
#include "git-compat-util.h"
22
#include "noop.h"
33
#include "../commit.h"
44
#include "../fetch-negotiator.h"

object.h

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef OBJECT_H
22
#define OBJECT_H
33

4-
#include "cache.h"
4+
#include "hash.h"
55

66
struct buffer_slab;
77

@@ -81,6 +81,26 @@ struct object_array {
8181
*/
8282
#define FLAG_BITS 28
8383

84+
#define TYPE_BITS 3
85+
86+
/*
87+
* Values in this enum (except those outside the 3 bit range) are part
88+
* of pack file format. See gitformat-pack(5) for more information.
89+
*/
90+
enum object_type {
91+
OBJ_BAD = -1,
92+
OBJ_NONE = 0,
93+
OBJ_COMMIT = 1,
94+
OBJ_TREE = 2,
95+
OBJ_BLOB = 3,
96+
OBJ_TAG = 4,
97+
/* 5 for future expansion */
98+
OBJ_OFS_DELTA = 6,
99+
OBJ_REF_DELTA = 7,
100+
OBJ_ANY,
101+
OBJ_MAX
102+
};
103+
84104
/*
85105
* The object type is stored in 3 bits.
86106
*/

shallow.h

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "repository.h"
77
#include "strbuf.h"
88

9+
struct oid_array;
10+
911
void set_alternate_shallow_file(struct repository *r, const char *path, int override);
1012
int register_shallow(struct repository *r, const struct object_id *oid);
1113
int unregister_shallow(const struct object_id *oid);

t/helper/test-bloom.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "git-compat-util.h"
1+
#include "cache.h"
22
#include "bloom.h"
33
#include "hex.h"
44
#include "test-tool.h"

t/helper/test-example-decorate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "test-tool.h"
2-
#include "cache.h"
2+
#include "git-compat-util.h"
33
#include "object.h"
44
#include "decorate.h"
55

worktree.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef WORKTREE_H
22
#define WORKTREE_H
33

4-
#include "cache.h"
54
#include "refs.h"
65

76
struct strbuf;

0 commit comments

Comments
 (0)