Skip to content

Commit 41227cb

Browse files
newrengitster
authored andcommitted
hash.h: move some oid-related declarations from cache.h
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. The change to line-log.h might look unrelated, but line-log.h includes diffcore.h, which previously included cache.h, which included the kitchen sink. Since this patch makes diffcore.h no longer include cache.h, the compiler complains about the 'struct string_list *' function parameter. Add a forward declaration for struct string_list to address this. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 36bf195 commit 41227cb

File tree

7 files changed

+42
-37
lines changed

7 files changed

+42
-37
lines changed

cache.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,40 +1363,6 @@ struct object_context {
13631363
char *path;
13641364
};
13651365

1366-
#define GET_OID_QUIETLY 01
1367-
#define GET_OID_COMMIT 02
1368-
#define GET_OID_COMMITTISH 04
1369-
#define GET_OID_TREE 010
1370-
#define GET_OID_TREEISH 020
1371-
#define GET_OID_BLOB 040
1372-
#define GET_OID_FOLLOW_SYMLINKS 0100
1373-
#define GET_OID_RECORD_PATH 0200
1374-
#define GET_OID_ONLY_TO_DIE 04000
1375-
#define GET_OID_REQUIRE_PATH 010000
1376-
1377-
#define GET_OID_DISAMBIGUATORS \
1378-
(GET_OID_COMMIT | GET_OID_COMMITTISH | \
1379-
GET_OID_TREE | GET_OID_TREEISH | \
1380-
GET_OID_BLOB)
1381-
1382-
enum get_oid_result {
1383-
FOUND = 0,
1384-
MISSING_OBJECT = -1, /* The requested object is missing */
1385-
SHORT_NAME_AMBIGUOUS = -2,
1386-
/* The following only apply when symlinks are followed */
1387-
DANGLING_SYMLINK = -4, /*
1388-
* The initial symlink is there, but
1389-
* (transitively) points to a missing
1390-
* in-tree file
1391-
*/
1392-
SYMLINK_LOOP = -5,
1393-
NOT_DIR = -6, /*
1394-
* Somewhere along the symlink chain, a path is
1395-
* requested which contains a file as a
1396-
* non-final element.
1397-
*/
1398-
};
1399-
14001366
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
14011367
__attribute__((format (printf, 2, 3)))
14021368
int get_oidf(struct object_id *oid, const char *fmt, ...);

diffcore.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
#ifndef DIFFCORE_H
55
#define DIFFCORE_H
66

7-
#include "cache.h"
7+
#include "hash.h"
88

99
struct diff_options;
10+
struct mem_pool;
11+
struct oid_array;
1012
struct repository;
1113
struct strintmap;
1214
struct strmap;

hash.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,40 @@ struct object_id {
123123
int algo; /* XXX requires 4-byte alignment */
124124
};
125125

126+
#define GET_OID_QUIETLY 01
127+
#define GET_OID_COMMIT 02
128+
#define GET_OID_COMMITTISH 04
129+
#define GET_OID_TREE 010
130+
#define GET_OID_TREEISH 020
131+
#define GET_OID_BLOB 040
132+
#define GET_OID_FOLLOW_SYMLINKS 0100
133+
#define GET_OID_RECORD_PATH 0200
134+
#define GET_OID_ONLY_TO_DIE 04000
135+
#define GET_OID_REQUIRE_PATH 010000
136+
137+
#define GET_OID_DISAMBIGUATORS \
138+
(GET_OID_COMMIT | GET_OID_COMMITTISH | \
139+
GET_OID_TREE | GET_OID_TREEISH | \
140+
GET_OID_BLOB)
141+
142+
enum get_oid_result {
143+
FOUND = 0,
144+
MISSING_OBJECT = -1, /* The requested object is missing */
145+
SHORT_NAME_AMBIGUOUS = -2,
146+
/* The following only apply when symlinks are followed */
147+
DANGLING_SYMLINK = -4, /*
148+
* The initial symlink is there, but
149+
* (transitively) points to a missing
150+
* in-tree file
151+
*/
152+
SYMLINK_LOOP = -5,
153+
NOT_DIR = -6, /*
154+
* Somewhere along the symlink chain, a path is
155+
* requested which contains a file as a
156+
* non-final element.
157+
*/
158+
};
159+
126160
/* A suitably aligned type for stack allocations of hash contexts. */
127161
union git_hash_ctx {
128162
git_SHA_CTX sha1;

line-log.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
struct rev_info;
77
struct commit;
8+
struct string_list;
89

910
/* A range [start,end]. Lines are numbered starting at 0, and the
1011
* ranges include start but exclude end. */

submodule-config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#ifndef SUBMODULE_CONFIG_CACHE_H
22
#define SUBMODULE_CONFIG_CACHE_H
33

4-
#include "cache.h"
54
#include "config.h"
65
#include "hashmap.h"
76
#include "submodule.h"

t/helper/test-submodule-nested-repo-config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "test-tool.h"
2+
#include "cache.h"
23
#include "submodule-config.h"
34

45
static void die_usage(const char **argv, const char *msg)

tree-walk.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef TREE_WALK_H
22
#define TREE_WALK_H
33

4-
#include "cache.h"
4+
#include "hash.h"
5+
6+
struct index_state;
57

68
#define MAX_TRAVERSE_TREES 8
79

0 commit comments

Comments
 (0)