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 <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2023-02-24 00:09:30 +00:00 committed by Junio C Hamano
parent b5fa608180
commit a64215b6cd
17 changed files with 36 additions and 32 deletions

View File

@ -8,7 +8,7 @@
* up with maximal alignment because it doesn't know what the object alignment
* for the new allocation is.
*/
#include "cache.h"
#include "git-compat-util.h"
#include "object.h"
#include "blob.h"
#include "tree.h"

View File

@ -1,7 +1,6 @@
#ifndef BLAME_H
#define BLAME_H
#include "cache.h"
#include "commit.h"
#include "xdiff-interface.h"
#include "revision.h"

2
blob.c
View File

@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "blob.h"
#include "repository.h"
#include "alloc.h"

View File

@ -1,7 +1,6 @@
#ifndef CACHE_TREE_H
#define CACHE_TREE_H
#include "cache.h"
#include "tree.h"
#include "tree-walk.h"

21
cache.h
View File

@ -14,6 +14,7 @@
#include "pack-revindex.h"
#include "hash.h"
#include "path.h"
#include "object.h"
#include "oid-array.h"
#include "repository.h"
#include "mem-pool.h"
@ -453,26 +454,6 @@ void prefetch_cache_entries(const struct index_state *istate,
extern struct index_state the_index;
#endif
#define TYPE_BITS 3
/*
* Values in this enum (except those outside the 3 bit range) are part
* of pack file format. See gitformat-pack(5) for more information.
*/
enum object_type {
OBJ_BAD = -1,
OBJ_NONE = 0,
OBJ_COMMIT = 1,
OBJ_TREE = 2,
OBJ_BLOB = 3,
OBJ_TAG = 4,
/* 5 for future expansion */
OBJ_OFS_DELTA = 6,
OBJ_REF_DELTA = 7,
OBJ_ANY,
OBJ_MAX
};
static inline enum object_type object_type(unsigned int mode)
{
return S_ISDIR(mode) ? OBJ_TREE :

View File

@ -1,6 +1,7 @@
#include "git-compat-util.h"
#include "diff-merges.h"
#include "gettext.h"
#include "revision.h"
typedef void (*diff_merges_setup_func_t)(struct rev_info *);

2
diff.h
View File

@ -8,6 +8,7 @@
#include "pathspec.h"
#include "object.h"
#include "oidset.h"
#include "strbuf.h"
/**
* The diff API is for programs that compare two sets of files (e.g. two trees,
@ -71,7 +72,6 @@ struct oid_array;
struct option;
struct repository;
struct rev_info;
struct strbuf;
struct userdiff_driver;
typedef int (*pathchange_fn_t)(struct diff_options *options,

View File

@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "diff.h"
#include "diffcore.h"

1
fsck.h
View File

@ -1,6 +1,7 @@
#ifndef GIT_FSCK_H
#define GIT_FSCK_H
#include "object.h"
#include "oidset.h"
enum fsck_msg_type {

1
help.c
View File

@ -5,6 +5,7 @@
#include "exec-cmd.h"
#include "run-command.h"
#include "levenshtein.h"
#include "gettext.h"
#include "help.h"
#include "command-list.h"
#include "string-list.h"

View File

@ -1,9 +1,10 @@
#ifndef LIST_OBJECTS_FILTER_OPTIONS_H
#define LIST_OBJECTS_FILTER_OPTIONS_H
#include "cache.h"
#include "object.h"
#include "parse-options.h"
#include "string-list.h"
#include "strbuf.h"
/*
* The list of defined filters for list-objects.

View File

@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "noop.h"
#include "../commit.h"
#include "../fetch-negotiator.h"

View File

@ -1,7 +1,7 @@
#ifndef OBJECT_H
#define OBJECT_H
#include "cache.h"
#include "hash.h"
struct buffer_slab;
@ -81,6 +81,26 @@ struct object_array {
*/
#define FLAG_BITS 28
#define TYPE_BITS 3
/*
* Values in this enum (except those outside the 3 bit range) are part
* of pack file format. See gitformat-pack(5) for more information.
*/
enum object_type {
OBJ_BAD = -1,
OBJ_NONE = 0,
OBJ_COMMIT = 1,
OBJ_TREE = 2,
OBJ_BLOB = 3,
OBJ_TAG = 4,
/* 5 for future expansion */
OBJ_OFS_DELTA = 6,
OBJ_REF_DELTA = 7,
OBJ_ANY,
OBJ_MAX
};
/*
* The object type is stored in 3 bits.
*/

View File

@ -6,6 +6,8 @@
#include "repository.h"
#include "strbuf.h"
struct oid_array;
void set_alternate_shallow_file(struct repository *r, const char *path, int override);
int register_shallow(struct repository *r, const struct object_id *oid);
int unregister_shallow(const struct object_id *oid);

View File

@ -1,4 +1,4 @@
#include "git-compat-util.h"
#include "cache.h"
#include "bloom.h"
#include "hex.h"
#include "test-tool.h"

View File

@ -1,5 +1,5 @@
#include "test-tool.h"
#include "cache.h"
#include "git-compat-util.h"
#include "object.h"
#include "decorate.h"

View File

@ -1,7 +1,6 @@
#ifndef WORKTREE_H
#define WORKTREE_H
#include "cache.h"
#include "refs.h"
struct strbuf;