Skip to content

Commit 1a79326

Browse files
pks-tgitster
authored andcommitted
object-store: move function declarations to their respective subsystems
We carry declarations for a couple of functions in "object-store.h" that are not defined in "object-store.c", but in a different subsystem. Move these declarations to the respective headers whose matching code files carry the corresponding definition. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0b8ed25 commit 1a79326

File tree

12 files changed

+106
-103
lines changed

12 files changed

+106
-103
lines changed

builtin/count-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "parse-options.h"
1313
#include "quote.h"
1414
#include "packfile.h"
15-
#include "object-store.h"
15+
#include "object-file.h"
1616

1717
static unsigned long garbage;
1818
static off_t size_garbage;

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "commit.h"
2929
#include "commit-graph.h"
3030
#include "packfile.h"
31-
#include "object-store.h"
31+
#include "object-file.h"
3232
#include "pack.h"
3333
#include "pack-objects.h"
3434
#include "path.h"

convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "copy.h"
99
#include "gettext.h"
1010
#include "hex.h"
11-
#include "object-store.h"
11+
#include "object-file.h"
1212
#include "attr.h"
1313
#include "run-command.h"
1414
#include "quote.h"

diffcore-rename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "git-compat-util.h"
99
#include "diff.h"
1010
#include "diffcore.h"
11-
#include "object-store.h"
11+
#include "object-file.h"
1212
#include "hashmap.h"
1313
#include "mem-pool.h"
1414
#include "oid-array.h"

dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "environment.h"
1818
#include "gettext.h"
1919
#include "name-hash.h"
20-
#include "object-store.h"
20+
#include "object-file.h"
2121
#include "path.h"
2222
#include "refs.h"
2323
#include "repository.h"

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "environment.h"
1010
#include "hex.h"
1111
#include "object-name.h"
12-
#include "object-store.h"
12+
#include "object-file.h"
1313
#include "repository.h"
1414
#include "tmp-objdir.h"
1515
#include "commit.h"

object-file.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "git-zlib.h"
55
#include "object.h"
6+
#include "object-store.h"
67

78
struct index_state;
89

@@ -25,6 +26,16 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa
2526

2627
struct object_directory;
2728

29+
/*
30+
* Populate and return the loose object cache array corresponding to the
31+
* given object ID.
32+
*/
33+
struct oidtree *odb_loose_cache(struct object_directory *odb,
34+
const struct object_id *oid);
35+
36+
/* Empty the loose object cache for the specified object directory. */
37+
void odb_clear_loose_cache(struct object_directory *odb);
38+
2839
/*
2940
* Put in `buf` the name of the file in the local object database that
3041
* would be used to store a loose object with the specified oid.
@@ -42,6 +53,68 @@ int has_loose_object_nonlocal(const struct object_id *);
4253

4354
int has_loose_object(const struct object_id *);
4455

56+
void *map_loose_object(struct repository *r, const struct object_id *oid,
57+
unsigned long *size);
58+
59+
/*
60+
* Iterate over the files in the loose-object parts of the object
61+
* directory "path", triggering the following callbacks:
62+
*
63+
* - loose_object is called for each loose object we find.
64+
*
65+
* - loose_cruft is called for any files that do not appear to be
66+
* loose objects. Note that we only look in the loose object
67+
* directories "objects/[0-9a-f]{2}/", so we will not report
68+
* "objects/foobar" as cruft.
69+
*
70+
* - loose_subdir is called for each top-level hashed subdirectory
71+
* of the object directory (e.g., "$OBJDIR/f0"). It is called
72+
* after the objects in the directory are processed.
73+
*
74+
* Any callback that is NULL will be ignored. Callbacks returning non-zero
75+
* will end the iteration.
76+
*
77+
* In the "buf" variant, "path" is a strbuf which will also be used as a
78+
* scratch buffer, but restored to its original contents before
79+
* the function returns.
80+
*/
81+
typedef int each_loose_object_fn(const struct object_id *oid,
82+
const char *path,
83+
void *data);
84+
typedef int each_loose_cruft_fn(const char *basename,
85+
const char *path,
86+
void *data);
87+
typedef int each_loose_subdir_fn(unsigned int nr,
88+
const char *path,
89+
void *data);
90+
int for_each_file_in_obj_subdir(unsigned int subdir_nr,
91+
struct strbuf *path,
92+
each_loose_object_fn obj_cb,
93+
each_loose_cruft_fn cruft_cb,
94+
each_loose_subdir_fn subdir_cb,
95+
void *data);
96+
int for_each_loose_file_in_objdir(const char *path,
97+
each_loose_object_fn obj_cb,
98+
each_loose_cruft_fn cruft_cb,
99+
each_loose_subdir_fn subdir_cb,
100+
void *data);
101+
int for_each_loose_file_in_objdir_buf(struct strbuf *path,
102+
each_loose_object_fn obj_cb,
103+
each_loose_cruft_fn cruft_cb,
104+
each_loose_subdir_fn subdir_cb,
105+
void *data);
106+
107+
/*
108+
* Iterate over all accessible loose objects without respect to
109+
* reachability. By default, this includes both local and alternate objects.
110+
* The order in which objects are visited is unspecified.
111+
*
112+
* Any flags specific to packs are ignored.
113+
*/
114+
int for_each_loose_object(each_loose_object_fn, void *,
115+
enum for_each_object_flags flags);
116+
117+
45118
/**
46119
* format_object_header() is a thin wrapper around s xsnprintf() that
47120
* writes the initial "<type> <obj-len>" part of the loose object
@@ -158,6 +231,10 @@ int finalize_object_file(const char *tmpfile, const char *filename);
158231
int finalize_object_file_flags(const char *tmpfile, const char *filename,
159232
enum finalize_object_file_flags flags);
160233

234+
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
235+
unsigned long len, enum object_type type,
236+
struct object_id *oid);
237+
161238
/* Helper to check and "touch" a file */
162239
int check_and_freshen_file(const char *fn, int freshen);
163240

object-name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "oidtree.h"
2020
#include "packfile.h"
2121
#include "pretty.h"
22-
#include "object-store.h"
22+
#include "object-file.h"
2323
#include "read-cache-ll.h"
2424
#include "repo-settings.h"
2525
#include "repository.h"

object-store.h

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des
8282
*/
8383
void restore_primary_odb(struct object_directory *restore_odb, const char *old_path);
8484

85-
/*
86-
* Populate and return the loose object cache array corresponding to the
87-
* given object ID.
88-
*/
89-
struct oidtree *odb_loose_cache(struct object_directory *odb,
90-
const struct object_id *oid);
91-
92-
/* Empty the loose object cache for the specified object directory. */
93-
void odb_clear_loose_cache(struct object_directory *odb);
94-
9585
struct packed_git;
9686
struct multi_pack_index;
9787
struct cached_object_entry;
@@ -189,9 +179,6 @@ void raw_object_store_clear(struct raw_object_store *o);
189179
*/
190180
int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);
191181

192-
void *map_loose_object(struct repository *r, const struct object_id *oid,
193-
unsigned long *size);
194-
195182
void *repo_read_object_file(struct repository *r,
196183
const struct object_id *oid,
197184
enum object_type *type,
@@ -200,10 +187,6 @@ void *repo_read_object_file(struct repository *r,
200187
/* Read and unpack an object file into memory, write memory to an object file */
201188
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
202189

203-
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
204-
unsigned long len, enum object_type type,
205-
struct object_id *oid);
206-
207190
/*
208191
* Add an object file to the in-memory object store, without writing it
209192
* to disk.
@@ -340,56 +323,7 @@ static inline void obj_read_unlock(void)
340323
if(obj_read_use_lock)
341324
pthread_mutex_unlock(&obj_read_mutex);
342325
}
343-
344-
/*
345-
* Iterate over the files in the loose-object parts of the object
346-
* directory "path", triggering the following callbacks:
347-
*
348-
* - loose_object is called for each loose object we find.
349-
*
350-
* - loose_cruft is called for any files that do not appear to be
351-
* loose objects. Note that we only look in the loose object
352-
* directories "objects/[0-9a-f]{2}/", so we will not report
353-
* "objects/foobar" as cruft.
354-
*
355-
* - loose_subdir is called for each top-level hashed subdirectory
356-
* of the object directory (e.g., "$OBJDIR/f0"). It is called
357-
* after the objects in the directory are processed.
358-
*
359-
* Any callback that is NULL will be ignored. Callbacks returning non-zero
360-
* will end the iteration.
361-
*
362-
* In the "buf" variant, "path" is a strbuf which will also be used as a
363-
* scratch buffer, but restored to its original contents before
364-
* the function returns.
365-
*/
366-
typedef int each_loose_object_fn(const struct object_id *oid,
367-
const char *path,
368-
void *data);
369-
typedef int each_loose_cruft_fn(const char *basename,
370-
const char *path,
371-
void *data);
372-
typedef int each_loose_subdir_fn(unsigned int nr,
373-
const char *path,
374-
void *data);
375-
int for_each_file_in_obj_subdir(unsigned int subdir_nr,
376-
struct strbuf *path,
377-
each_loose_object_fn obj_cb,
378-
each_loose_cruft_fn cruft_cb,
379-
each_loose_subdir_fn subdir_cb,
380-
void *data);
381-
int for_each_loose_file_in_objdir(const char *path,
382-
each_loose_object_fn obj_cb,
383-
each_loose_cruft_fn cruft_cb,
384-
each_loose_subdir_fn subdir_cb,
385-
void *data);
386-
int for_each_loose_file_in_objdir_buf(struct strbuf *path,
387-
each_loose_object_fn obj_cb,
388-
each_loose_cruft_fn cruft_cb,
389-
each_loose_subdir_fn subdir_cb,
390-
void *data);
391-
392-
/* Flags for for_each_*_object() below. */
326+
/* Flags for for_each_*_object(). */
393327
enum for_each_object_flags {
394328
/* Iterate only over local objects, not alternates. */
395329
FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),
@@ -409,33 +343,6 @@ enum for_each_object_flags {
409343
FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
410344
};
411345

412-
/*
413-
* Iterate over all accessible loose objects without respect to
414-
* reachability. By default, this includes both local and alternate objects.
415-
* The order in which objects are visited is unspecified.
416-
*
417-
* Any flags specific to packs are ignored.
418-
*/
419-
int for_each_loose_object(each_loose_object_fn, void *,
420-
enum for_each_object_flags flags);
421-
422-
/*
423-
* Iterate over all accessible packed objects without respect to reachability.
424-
* By default, this includes both local and alternate packs.
425-
*
426-
* Note that some objects may appear twice if they are found in multiple packs.
427-
* Each pack is visited in an unspecified order. By default, objects within a
428-
* pack are visited in pack-idx order (i.e., sorted by oid).
429-
*/
430-
typedef int each_packed_object_fn(const struct object_id *oid,
431-
struct packed_git *pack,
432-
uint32_t pos,
433-
void *data);
434-
int for_each_object_in_pack(struct packed_git *p,
435-
each_packed_object_fn, void *data,
436-
enum for_each_object_flags flags);
437-
int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
438-
void *data, enum for_each_object_flags flags);
439346

440347
void *read_object_with_reference(struct repository *r,
441348
const struct object_id *oid,

packfile.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "list.h"
55
#include "object.h"
6+
#include "object-store.h"
67
#include "oidset.h"
78

89
/* in object-store.h */
@@ -117,6 +118,24 @@ void for_each_file_in_pack_dir(const char *objdir,
117118
each_file_in_pack_dir_fn fn,
118119
void *data);
119120

121+
/*
122+
* Iterate over all accessible packed objects without respect to reachability.
123+
* By default, this includes both local and alternate packs.
124+
*
125+
* Note that some objects may appear twice if they are found in multiple packs.
126+
* Each pack is visited in an unspecified order. By default, objects within a
127+
* pack are visited in pack-idx order (i.e., sorted by oid).
128+
*/
129+
typedef int each_packed_object_fn(const struct object_id *oid,
130+
struct packed_git *pack,
131+
uint32_t pos,
132+
void *data);
133+
int for_each_object_in_pack(struct packed_git *p,
134+
each_packed_object_fn, void *data,
135+
enum for_each_object_flags flags);
136+
int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
137+
void *data, enum for_each_object_flags flags);
138+
120139
/* A hook to report invalid files in pack directory */
121140
#define PACKDIR_FILE_PACK 1
122141
#define PACKDIR_FILE_IDX 2

0 commit comments

Comments
 (0)