Skip to content

Commit 6daeb66

Browse files
pks-tgitster
authored andcommitted
odb: stop including "odb/source.h"
The "odb.h" header currently includes the "odb/source.h" file. This is somewhat roundabout though: most callers shouldn't have to care about the `struct odb_source`, but should rather use the ODB-level functions. Furthermore, it means that a couple of definitions have to live on the source level even though they should be part of the generic interface. Reverse the relation between "odb/source.h" and "odb.h" and move the enums and typedefs that relate to the generic interfaces back into "odb.h". Add the necessary includes to all files that rely on the transitive include. Suggested-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6cdef94 commit 6daeb66

File tree

8 files changed

+56
-52
lines changed

8 files changed

+56
-52
lines changed

builtin/multi-pack-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "strbuf.h"
1010
#include "trace2.h"
1111
#include "odb.h"
12+
#include "odb/source.h"
1213
#include "replace-object.h"
1314
#include "repository.h"
1415

builtin/submodule--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "object-file.h"
3030
#include "object-name.h"
3131
#include "odb.h"
32+
#include "odb/source.h"
3233
#include "advice.h"
3334
#include "branch.h"
3435
#include "list-objects-filter-options.h"

odb.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "hashmap.h"
55
#include "object.h"
6-
#include "odb/source.h"
76
#include "oidset.h"
87
#include "oidmap.h"
98
#include "string-list.h"
@@ -12,6 +11,7 @@
1211
struct oidmap;
1312
struct oidtree;
1413
struct strbuf;
14+
struct strvec;
1515
struct repository;
1616
struct multi_pack_index;
1717

@@ -339,6 +339,42 @@ struct object_info {
339339
*/
340340
#define OBJECT_INFO_INIT { 0 }
341341

342+
/* Flags that can be passed to `odb_read_object_info_extended()`. */
343+
enum object_info_flags {
344+
/* Invoke lookup_replace_object() on the given hash. */
345+
OBJECT_INFO_LOOKUP_REPLACE = (1 << 0),
346+
347+
/* Do not reprepare object sources when the first lookup has failed. */
348+
OBJECT_INFO_QUICK = (1 << 1),
349+
350+
/*
351+
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
352+
* nonzero).
353+
*/
354+
OBJECT_INFO_SKIP_FETCH_OBJECT = (1 << 2),
355+
356+
/* Die if object corruption (not just an object being missing) was detected. */
357+
OBJECT_INFO_DIE_IF_CORRUPT = (1 << 3),
358+
359+
/*
360+
* We have already tried reading the object, but it couldn't be found
361+
* via any of the attached sources, and are now doing a second read.
362+
* This second read asks the individual sources to also evaluate
363+
* whether any on-disk state may have changed that may have caused the
364+
* object to appear.
365+
*
366+
* This flag is for internal use, only. The second read only occurs
367+
* when `OBJECT_INFO_QUICK` was not passed.
368+
*/
369+
OBJECT_INFO_SECOND_READ = (1 << 4),
370+
371+
/*
372+
* This is meant for bulk prefetching of missing blobs in a partial
373+
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK.
374+
*/
375+
OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK),
376+
};
377+
342378
/*
343379
* Read object info from the object database and populate the `object_info`
344380
* structure. Returns 0 on success, a negative error code otherwise.
@@ -432,6 +468,18 @@ enum odb_for_each_object_flags {
432468
ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
433469
};
434470

471+
/*
472+
* A callback function that can be used to iterate through objects. If given,
473+
* the optional `oi` parameter will be populated the same as if you would call
474+
* `odb_read_object_info()`.
475+
*
476+
* Returning a non-zero error code will cause iteration to abort. The error
477+
* code will be propagated.
478+
*/
479+
typedef int (*odb_for_each_object_cb)(const struct object_id *oid,
480+
struct object_info *oi,
481+
void *cb_data);
482+
435483
/*
436484
* Iterate through all objects contained in the object database. Note that
437485
* objects may be iterated over multiple times in case they are either stored

odb/source.h

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define ODB_SOURCE_H
33

44
#include "object.h"
5+
#include "odb.h"
56

67
enum odb_source_type {
78
/*
@@ -14,61 +15,10 @@ enum odb_source_type {
1415
ODB_SOURCE_FILES,
1516
};
1617

17-
/* Flags that can be passed to `odb_read_object_info_extended()`. */
18-
enum object_info_flags {
19-
/* Invoke lookup_replace_object() on the given hash. */
20-
OBJECT_INFO_LOOKUP_REPLACE = (1 << 0),
21-
22-
/* Do not reprepare object sources when the first lookup has failed. */
23-
OBJECT_INFO_QUICK = (1 << 1),
24-
25-
/*
26-
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
27-
* nonzero).
28-
*/
29-
OBJECT_INFO_SKIP_FETCH_OBJECT = (1 << 2),
30-
31-
/* Die if object corruption (not just an object being missing) was detected. */
32-
OBJECT_INFO_DIE_IF_CORRUPT = (1 << 3),
33-
34-
/*
35-
* We have already tried reading the object, but it couldn't be found
36-
* via any of the attached sources, and are now doing a second read.
37-
* This second read asks the individual sources to also evaluate
38-
* whether any on-disk state may have changed that may have caused the
39-
* object to appear.
40-
*
41-
* This flag is for internal use, only. The second read only occurs
42-
* when `OBJECT_INFO_QUICK` was not passed.
43-
*/
44-
OBJECT_INFO_SECOND_READ = (1 << 4),
45-
46-
/*
47-
* This is meant for bulk prefetching of missing blobs in a partial
48-
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK.
49-
*/
50-
OBJECT_INFO_FOR_PREFETCH = (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK),
51-
};
52-
5318
struct object_id;
54-
struct object_info;
5519
struct odb_read_stream;
56-
struct odb_transaction;
57-
struct odb_write_stream;
5820
struct strvec;
5921

60-
/*
61-
* A callback function that can be used to iterate through objects. If given,
62-
* the optional `oi` parameter will be populated the same as if you would call
63-
* `odb_read_object_info()`.
64-
*
65-
* Returning a non-zero error code will cause iteration to abort. The error
66-
* code will be propagated.
67-
*/
68-
typedef int (*odb_for_each_object_cb)(const struct object_id *oid,
69-
struct object_info *oi,
70-
void *cb_data);
71-
7222
/*
7323
* The source is the part of the object database that stores the actual
7424
* objects. It thus encapsulates the logic to read and write the specific

odb/streaming.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "environment.h"
88
#include "repository.h"
99
#include "odb.h"
10+
#include "odb/source.h"
1011
#include "odb/streaming.h"
1112
#include "replace-object.h"
1213

repository.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "abspath.h"
33
#include "repository.h"
44
#include "odb.h"
5+
#include "odb/source.h"
56
#include "config.h"
67
#include "object.h"
78
#include "lockfile.h"

submodule-config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "strbuf.h"
1515
#include "object-name.h"
1616
#include "odb.h"
17+
#include "odb/source.h"
1718
#include "parse-options.h"
1819
#include "thread-utils.h"
1920
#include "tree-walk.h"

tmp-objdir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "strvec.h"
1212
#include "quote.h"
1313
#include "odb.h"
14+
#include "odb/source.h"
1415
#include "repository.h"
1516

1617
struct tmp_objdir {

0 commit comments

Comments
 (0)