Coverage Report

Created: 2025-12-31 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/git/odb.h
Line
Count
Source
1
#ifndef ODB_H
2
#define ODB_H
3
4
#include "hashmap.h"
5
#include "object.h"
6
#include "oidset.h"
7
#include "oidmap.h"
8
#include "string-list.h"
9
#include "thread-utils.h"
10
11
struct oidmap;
12
struct oidtree;
13
struct strbuf;
14
struct repository;
15
struct multi_pack_index;
16
17
/*
18
 * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing
19
 * blobs. This has a difference only if extensions.partialClone is set.
20
 *
21
 * Its default value is 1.
22
 */
23
extern int fetch_if_missing;
24
25
/*
26
 * Compute the exact path an alternate is at and returns it. In case of
27
 * error NULL is returned and the human readable error is added to `err`
28
 * `path` may be relative and should point to $GIT_DIR.
29
 * `err` must not be null.
30
 */
31
char *compute_alternate_path(const char *path, struct strbuf *err);
32
33
/*
34
 * The source is the part of the object database that stores the actual
35
 * objects. It thus encapsulates the logic to read and write the specific
36
 * on-disk format. An object database can have multiple sources:
37
 *
38
 *   - The primary source, which is typically located in "$GIT_DIR/objects".
39
 *     This is where new objects are usually written to.
40
 *
41
 *   - Alternate sources, which are configured via "objects/info/alternates" or
42
 *     via the GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable. These
43
 *     alternate sources are only used to read objects.
44
 */
45
struct odb_source {
46
  struct odb_source *next;
47
48
  /* Object database that owns this object source. */
49
  struct object_database *odb;
50
51
  /* Private state for loose objects. */
52
  struct odb_source_loose *loose;
53
54
  /*
55
   * private data
56
   *
57
   * should only be accessed directly by packfile.c and midx.c
58
   */
59
  struct multi_pack_index *midx;
60
61
  /*
62
   * Figure out whether this is the local source of the owning
63
   * repository, which would typically be its ".git/objects" directory.
64
   * This local object directory is usually where objects would be
65
   * written to.
66
   */
67
  bool local;
68
69
  /*
70
   * This object store is ephemeral, so there is no need to fsync.
71
   */
72
  int will_destroy;
73
74
  /*
75
   * Path to the source. If this is a relative path, it is relative to
76
   * the current working directory.
77
   */
78
  char *path;
79
};
80
81
struct packed_git;
82
struct packfile_store;
83
struct cached_object_entry;
84
struct odb_transaction;
85
86
/*
87
 * The object database encapsulates access to objects in a repository. It
88
 * manages one or more sources that store the actual objects which are
89
 * configured via alternates.
90
 */
91
struct object_database {
92
  /* Repository that owns this database. */
93
  struct repository *repo;
94
95
  /*
96
   * State of current current object database transaction. Only one
97
   * transaction may be pending at a time. Is NULL when no transaction is
98
   * configured.
99
   */
100
  struct odb_transaction *transaction;
101
102
  /*
103
   * Set of all object directories; the main directory is first (and
104
   * cannot be NULL after initialization). Subsequent directories are
105
   * alternates.
106
   */
107
  struct odb_source *sources;
108
  struct odb_source **sources_tail;
109
  struct kh_odb_path_map *source_by_path;
110
111
  int loaded_alternates;
112
113
  /*
114
   * A list of alternate object directories loaded from the environment;
115
   * this should not generally need to be accessed directly, but will
116
   * populate the "sources" list when odb_prepare_alternates() is run.
117
   */
118
  char *alternate_db;
119
120
  /*
121
   * Objects that should be substituted by other objects
122
   * (see git-replace(1)).
123
   */
124
  struct oidmap replace_map;
125
  unsigned replace_map_initialized : 1;
126
  pthread_mutex_t replace_mutex; /* protect object replace functions */
127
128
  struct commit_graph *commit_graph;
129
  unsigned commit_graph_attempted : 1; /* if loading has been attempted */
130
131
  /* Should only be accessed directly by packfile.c and midx.c. */
132
  struct packfile_store *packfiles;
133
134
  /*
135
   * This is meant to hold a *small* number of objects that you would
136
   * want odb_read_object() to be able to return, but yet you do not want
137
   * to write them into the object store (e.g. a browse-only
138
   * application).
139
   */
140
  struct cached_object_entry *cached_objects;
141
  size_t cached_object_nr, cached_object_alloc;
142
143
  /*
144
   * A fast, rough count of the number of objects in the repository.
145
   * These two fields are not meant for direct access. Use
146
   * repo_approximate_object_count() instead.
147
   */
148
  unsigned long approximate_object_count;
149
  unsigned approximate_object_count_valid : 1;
150
151
  /*
152
   * Submodule source paths that will be added as additional sources to
153
   * allow lookup of submodule objects via the main object database.
154
   */
155
  struct string_list submodule_source_paths;
156
};
157
158
/*
159
 * Create a new object database for the given repository.
160
 *
161
 * If the primary source parameter is set it will override the usual primary
162
 * object directory derived from the repository's common directory. The
163
 * alternate sources are expected to be a PATH_SEP-separated list of secondary
164
 * sources. Note that these alternate sources will be added in addition to, not
165
 * instead of, the alternates identified by the primary source.
166
 *
167
 * Returns the newly created object database.
168
 */
169
struct object_database *odb_new(struct repository *repo,
170
        const char *primary_source,
171
        const char *alternate_sources);
172
173
/* Free the object database and release all resources. */
174
void odb_free(struct object_database *o);
175
176
/*
177
 * Close the object database and all of its sources so that any held resources
178
 * will be released. The database can still be used after closing it, in which
179
 * case these resources may be reallocated.
180
 */
181
void odb_close(struct object_database *o);
182
183
/*
184
 * Clear caches, reload alternates and then reload object sources so that new
185
 * objects may become accessible.
186
 */
187
void odb_reprepare(struct object_database *o);
188
189
/*
190
 * Starts an ODB transaction. Subsequent objects are written to the transaction
191
 * and not committed until odb_transaction_commit() is invoked on the
192
 * transaction. If the ODB already has a pending transaction, NULL is returned.
193
 */
194
struct odb_transaction *odb_transaction_begin(struct object_database *odb);
195
196
/*
197
 * Commits an ODB transaction making the written objects visible. If the
198
 * specified transaction is NULL, the function is a no-op.
199
 */
200
void odb_transaction_commit(struct odb_transaction *transaction);
201
202
/*
203
 * Find source by its object directory path. Returns a `NULL` pointer in case
204
 * the source could not be found.
205
 */
206
struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir);
207
208
/* Same as `odb_find_source()`, but dies in case the source doesn't exist. */
209
struct odb_source *odb_find_source_or_die(struct object_database *odb, const char *obj_dir);
210
211
/*
212
 * Replace the current writable object directory with the specified temporary
213
 * object directory; returns the former primary source.
214
 */
215
struct odb_source *odb_set_temporary_primary_source(struct object_database *odb,
216
                const char *dir, int will_destroy);
217
218
/*
219
 * Restore the primary source that was previously replaced by
220
 * `odb_set_temporary_primary_source()`.
221
 */
222
void odb_restore_primary_source(struct object_database *odb,
223
        struct odb_source *restore_source,
224
        const char *old_path);
225
226
/*
227
 * Call odb_add_submodule_source_by_path() to add the submodule at the given
228
 * path to a list. The object stores of all submodules in that list will be
229
 * added as additional sources in the object store when looking up objects.
230
 */
231
void odb_add_submodule_source_by_path(struct object_database *odb,
232
              const char *path);
233
234
/*
235
 * Iterate through all alternates of the database and execute the provided
236
 * callback function for each of them. Stop iterating once the callback
237
 * function returns a non-zero value, in which case the value is bubbled up
238
 * from the callback.
239
 */
240
typedef int odb_for_each_alternate_fn(struct odb_source *, void *);
241
int odb_for_each_alternate(struct object_database *odb,
242
         odb_for_each_alternate_fn cb, void *payload);
243
244
/*
245
 * Iterate through all alternates of the database and yield their respective
246
 * references.
247
 */
248
typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *);
249
void odb_for_each_alternate_ref(struct object_database *odb,
250
        odb_for_each_alternate_ref_fn cb, void *payload);
251
252
/*
253
 * Create a temporary file rooted in the primary alternate's directory, or die
254
 * on failure. The filename is taken from "pattern", which should have the
255
 * usual "XXXXXX" trailer, and the resulting filename is written into the
256
 * "template" buffer. Returns the open descriptor.
257
 */
258
int odb_mkstemp(struct object_database *odb,
259
    struct strbuf *temp_filename, const char *pattern);
260
261
/*
262
 * Prepare alternate object sources for the given database by reading
263
 * "objects/info/alternates" and opening the respective sources.
264
 */
265
void odb_prepare_alternates(struct object_database *odb);
266
267
/*
268
 * Check whether the object database has any alternates. The primary object
269
 * source does not count as alternate.
270
 */
271
int odb_has_alternates(struct object_database *odb);
272
273
/*
274
 * Add the directory to the on-disk alternates file; the new entry will also
275
 * take effect in the current process.
276
 */
277
void odb_add_to_alternates_file(struct object_database *odb,
278
        const char *dir);
279
280
/*
281
 * Add the directory to the in-memory list of alternate sources (along with any
282
 * recursive alternates it points to), but do not modify the on-disk alternates
283
 * file.
284
 */
285
struct odb_source *odb_add_to_alternates_memory(struct object_database *odb,
286
            const char *dir);
287
288
/*
289
 * Read an object from the database. Returns the object data and assigns object
290
 * type and size to the `type` and `size` pointers, if these pointers are
291
 * non-NULL. Returns a `NULL` pointer in case the object does not exist.
292
 *
293
 * This function dies on corrupt objects; the callers who want to deal with
294
 * them should arrange to call odb_read_object_info_extended() and give error
295
 * messages themselves.
296
 */
297
void *odb_read_object(struct object_database *odb,
298
          const struct object_id *oid,
299
          enum object_type *type,
300
          unsigned long *size);
301
302
void *odb_read_object_peeled(struct object_database *odb,
303
           const struct object_id *oid,
304
           enum object_type required_type,
305
           unsigned long *size,
306
           struct object_id *oid_ret);
307
308
/*
309
 * Add an object file to the in-memory object store, without writing it
310
 * to disk.
311
 *
312
 * Callers are responsible for calling write_object_file to record the
313
 * object in persistent storage before writing any other new objects
314
 * that reference it.
315
 */
316
int odb_pretend_object(struct object_database *odb,
317
           void *buf, unsigned long len, enum object_type type,
318
           struct object_id *oid);
319
320
struct object_info {
321
  /* Request */
322
  enum object_type *typep;
323
  unsigned long *sizep;
324
  off_t *disk_sizep;
325
  struct object_id *delta_base_oid;
326
  void **contentp;
327
328
  /* Response */
329
  enum {
330
    OI_CACHED,
331
    OI_LOOSE,
332
    OI_PACKED,
333
    OI_DBCACHED
334
  } whence;
335
  union {
336
    /*
337
     * struct {
338
     *  ... Nothing to expose in this case
339
     * } cached;
340
     * struct {
341
     *  ... Nothing to expose in this case
342
     * } loose;
343
     */
344
    struct {
345
      struct packed_git *pack;
346
      off_t offset;
347
      unsigned int is_delta;
348
    } packed;
349
  } u;
350
};
351
352
/*
353
 * Initializer for a "struct object_info" that wants no items. You may
354
 * also memset() the memory to all-zeroes.
355
 */
356
0
#define OBJECT_INFO_INIT { 0 }
357
358
/* Invoke lookup_replace_object() on the given hash */
359
0
#define OBJECT_INFO_LOOKUP_REPLACE 1
360
/* Do not retry packed storage after checking packed and loose storage */
361
0
#define OBJECT_INFO_QUICK 8
362
/*
363
 * Do not attempt to fetch the object if missing (even if fetch_is_missing is
364
 * nonzero).
365
 */
366
0
#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
367
/*
368
 * This is meant for bulk prefetching of missing blobs in a partial
369
 * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
370
 */
371
0
#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
372
373
/* Die if object corruption (not just an object being missing) was detected. */
374
0
#define OBJECT_INFO_DIE_IF_CORRUPT 32
375
376
/*
377
 * Read object info from the object database and populate the `object_info`
378
 * structure. Returns 0 on success, a negative error code otherwise.
379
 */
380
int odb_read_object_info_extended(struct object_database *odb,
381
          const struct object_id *oid,
382
          struct object_info *oi,
383
          unsigned flags);
384
385
/*
386
 * Read a subset of object info for the given object ID. Returns an `enum
387
 * object_type` on success, a negative error code otherwise. If successful and
388
 * `sizep` is non-NULL, then the size of the object will be written to the
389
 * pointer.
390
 */
391
int odb_read_object_info(struct object_database *odb,
392
       const struct object_id *oid,
393
       unsigned long *sizep);
394
395
enum {
396
  /* Retry packed storage after checking packed and loose storage */
397
  HAS_OBJECT_RECHECK_PACKED = (1 << 0),
398
  /* Allow fetching the object in case the repository has a promisor remote. */
399
  HAS_OBJECT_FETCH_PROMISOR = (1 << 1),
400
};
401
402
/*
403
 * Returns 1 if the object exists. This function will not lazily fetch objects
404
 * in a partial clone by default.
405
 */
406
int odb_has_object(struct object_database *odb,
407
       const struct object_id *oid,
408
       unsigned flags);
409
410
int odb_freshen_object(struct object_database *odb,
411
           const struct object_id *oid);
412
413
void odb_assert_oid_type(struct object_database *odb,
414
       const struct object_id *oid, enum object_type expect);
415
416
/*
417
 * Enabling the object read lock allows multiple threads to safely call the
418
 * following functions in parallel: odb_read_object(),
419
 * odb_read_object_peeled(), odb_read_object_info() and odb().
420
 *
421
 * obj_read_lock() and obj_read_unlock() may also be used to protect other
422
 * section which cannot execute in parallel with object reading. Since the used
423
 * lock is a recursive mutex, these sections can even contain calls to object
424
 * reading functions. However, beware that in these cases zlib inflation won't
425
 * be performed in parallel, losing performance.
426
 *
427
 * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If
428
 * any of its callees end up calling it, this recursive call won't benefit from
429
 * parallel inflation.
430
 */
431
void enable_obj_read_lock(void);
432
void disable_obj_read_lock(void);
433
434
extern int obj_read_use_lock;
435
extern pthread_mutex_t obj_read_mutex;
436
437
static inline void obj_read_lock(void)
438
0
{
439
0
  if(obj_read_use_lock)
440
0
    pthread_mutex_lock(&obj_read_mutex);
441
0
}
Unexecuted instantiation: run-command.c:obj_read_lock
Unexecuted instantiation: config.c:obj_read_lock
Unexecuted instantiation: dir.c:obj_read_lock
Unexecuted instantiation: mailmap.c:obj_read_lock
Unexecuted instantiation: object-file.c:obj_read_lock
Unexecuted instantiation: object-name.c:obj_read_lock
Unexecuted instantiation: object.c:obj_read_lock
Unexecuted instantiation: odb.c:obj_read_lock
Unexecuted instantiation: streaming.c:obj_read_lock
Unexecuted instantiation: pack-write.c:obj_read_lock
Unexecuted instantiation: packfile.c:obj_read_lock
Unexecuted instantiation: path.c:obj_read_lock
Unexecuted instantiation: promisor-remote.c:obj_read_lock
Unexecuted instantiation: read-cache.c:obj_read_lock
Unexecuted instantiation: refs.c:obj_read_lock
Unexecuted instantiation: remote.c:obj_read_lock
Unexecuted instantiation: replace-object.c:obj_read_lock
Unexecuted instantiation: repo-settings.c:obj_read_lock
Unexecuted instantiation: repository.c:obj_read_lock
Unexecuted instantiation: revision.c:obj_read_lock
Unexecuted instantiation: setup.c:obj_read_lock
Unexecuted instantiation: shallow.c:obj_read_lock
Unexecuted instantiation: submodule-config.c:obj_read_lock
Unexecuted instantiation: submodule.c:obj_read_lock
Unexecuted instantiation: tag.c:obj_read_lock
Unexecuted instantiation: tmp-objdir.c:obj_read_lock
Unexecuted instantiation: tree-walk.c:obj_read_lock
Unexecuted instantiation: tree.c:obj_read_lock
Unexecuted instantiation: attr.c:obj_read_lock
Unexecuted instantiation: bisect.c:obj_read_lock
Unexecuted instantiation: bloom.c:obj_read_lock
Unexecuted instantiation: bundle-uri.c:obj_read_lock
Unexecuted instantiation: bundle.c:obj_read_lock
Unexecuted instantiation: cache-tree.c:obj_read_lock
Unexecuted instantiation: combine-diff.c:obj_read_lock
Unexecuted instantiation: commit-graph.c:obj_read_lock
Unexecuted instantiation: commit-reach.c:obj_read_lock
Unexecuted instantiation: commit.c:obj_read_lock
Unexecuted instantiation: connected.c:obj_read_lock
Unexecuted instantiation: convert.c:obj_read_lock
Unexecuted instantiation: diff.c:obj_read_lock
Unexecuted instantiation: diffcore-rename.c:obj_read_lock
Unexecuted instantiation: fetch-pack.c:obj_read_lock
Unexecuted instantiation: fsck.c:obj_read_lock
Unexecuted instantiation: grep.c:obj_read_lock
Unexecuted instantiation: list-objects.c:obj_read_lock
Unexecuted instantiation: log-tree.c:obj_read_lock
Unexecuted instantiation: loose.c:obj_read_lock
Unexecuted instantiation: merge-ort.c:obj_read_lock
Unexecuted instantiation: midx.c:obj_read_lock
Unexecuted instantiation: notes-cache.c:obj_read_lock
Unexecuted instantiation: notes.c:obj_read_lock
Unexecuted instantiation: pack-check.c:obj_read_lock
Unexecuted instantiation: pack-revindex.c:obj_read_lock
Unexecuted instantiation: send-pack.c:obj_read_lock
Unexecuted instantiation: sequencer.c:obj_read_lock
Unexecuted instantiation: transport-helper.c:obj_read_lock
Unexecuted instantiation: unpack-trees.c:obj_read_lock
Unexecuted instantiation: xdiff-interface.c:obj_read_lock
Unexecuted instantiation: apply.c:obj_read_lock
Unexecuted instantiation: entry.c:obj_read_lock
Unexecuted instantiation: list-objects-filter.c:obj_read_lock
Unexecuted instantiation: match-trees.c:obj_read_lock
Unexecuted instantiation: rerere.c:obj_read_lock
442
443
static inline void obj_read_unlock(void)
444
0
{
445
0
  if(obj_read_use_lock)
446
0
    pthread_mutex_unlock(&obj_read_mutex);
447
0
}
Unexecuted instantiation: run-command.c:obj_read_unlock
Unexecuted instantiation: config.c:obj_read_unlock
Unexecuted instantiation: dir.c:obj_read_unlock
Unexecuted instantiation: mailmap.c:obj_read_unlock
Unexecuted instantiation: object-file.c:obj_read_unlock
Unexecuted instantiation: object-name.c:obj_read_unlock
Unexecuted instantiation: object.c:obj_read_unlock
Unexecuted instantiation: odb.c:obj_read_unlock
Unexecuted instantiation: streaming.c:obj_read_unlock
Unexecuted instantiation: pack-write.c:obj_read_unlock
Unexecuted instantiation: packfile.c:obj_read_unlock
Unexecuted instantiation: path.c:obj_read_unlock
Unexecuted instantiation: promisor-remote.c:obj_read_unlock
Unexecuted instantiation: read-cache.c:obj_read_unlock
Unexecuted instantiation: refs.c:obj_read_unlock
Unexecuted instantiation: remote.c:obj_read_unlock
Unexecuted instantiation: replace-object.c:obj_read_unlock
Unexecuted instantiation: repo-settings.c:obj_read_unlock
Unexecuted instantiation: repository.c:obj_read_unlock
Unexecuted instantiation: revision.c:obj_read_unlock
Unexecuted instantiation: setup.c:obj_read_unlock
Unexecuted instantiation: shallow.c:obj_read_unlock
Unexecuted instantiation: submodule-config.c:obj_read_unlock
Unexecuted instantiation: submodule.c:obj_read_unlock
Unexecuted instantiation: tag.c:obj_read_unlock
Unexecuted instantiation: tmp-objdir.c:obj_read_unlock
Unexecuted instantiation: tree-walk.c:obj_read_unlock
Unexecuted instantiation: tree.c:obj_read_unlock
Unexecuted instantiation: attr.c:obj_read_unlock
Unexecuted instantiation: bisect.c:obj_read_unlock
Unexecuted instantiation: bloom.c:obj_read_unlock
Unexecuted instantiation: bundle-uri.c:obj_read_unlock
Unexecuted instantiation: bundle.c:obj_read_unlock
Unexecuted instantiation: cache-tree.c:obj_read_unlock
Unexecuted instantiation: combine-diff.c:obj_read_unlock
Unexecuted instantiation: commit-graph.c:obj_read_unlock
Unexecuted instantiation: commit-reach.c:obj_read_unlock
Unexecuted instantiation: commit.c:obj_read_unlock
Unexecuted instantiation: connected.c:obj_read_unlock
Unexecuted instantiation: convert.c:obj_read_unlock
Unexecuted instantiation: diff.c:obj_read_unlock
Unexecuted instantiation: diffcore-rename.c:obj_read_unlock
Unexecuted instantiation: fetch-pack.c:obj_read_unlock
Unexecuted instantiation: fsck.c:obj_read_unlock
Unexecuted instantiation: grep.c:obj_read_unlock
Unexecuted instantiation: list-objects.c:obj_read_unlock
Unexecuted instantiation: log-tree.c:obj_read_unlock
Unexecuted instantiation: loose.c:obj_read_unlock
Unexecuted instantiation: merge-ort.c:obj_read_unlock
Unexecuted instantiation: midx.c:obj_read_unlock
Unexecuted instantiation: notes-cache.c:obj_read_unlock
Unexecuted instantiation: notes.c:obj_read_unlock
Unexecuted instantiation: pack-check.c:obj_read_unlock
Unexecuted instantiation: pack-revindex.c:obj_read_unlock
Unexecuted instantiation: send-pack.c:obj_read_unlock
Unexecuted instantiation: sequencer.c:obj_read_unlock
Unexecuted instantiation: transport-helper.c:obj_read_unlock
Unexecuted instantiation: unpack-trees.c:obj_read_unlock
Unexecuted instantiation: xdiff-interface.c:obj_read_unlock
Unexecuted instantiation: apply.c:obj_read_unlock
Unexecuted instantiation: entry.c:obj_read_unlock
Unexecuted instantiation: list-objects-filter.c:obj_read_unlock
Unexecuted instantiation: match-trees.c:obj_read_unlock
Unexecuted instantiation: rerere.c:obj_read_unlock
448
/* Flags for for_each_*_object(). */
449
enum for_each_object_flags {
450
  /* Iterate only over local objects, not alternates. */
451
  FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),
452
453
  /* Only iterate over packs obtained from the promisor remote. */
454
  FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),
455
456
  /*
457
   * Visit objects within a pack in packfile order rather than .idx order
458
   */
459
  FOR_EACH_OBJECT_PACK_ORDER = (1<<2),
460
461
  /* Only iterate over packs that are not marked as kept in-core. */
462
  FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3),
463
464
  /* Only iterate over packs that do not have .keep files. */
465
  FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4),
466
};
467
468
enum {
469
  /*
470
   * By default, `odb_write_object()` does not actually write anything
471
   * into the object store, but only computes the object ID. This flag
472
   * changes that so that the object will be written as a loose object
473
   * and persisted.
474
   */
475
  WRITE_OBJECT_PERSIST = (1 << 0),
476
477
  /*
478
   * Do not print an error in case something goes wrong.
479
   */
480
  WRITE_OBJECT_SILENT = (1 << 1),
481
};
482
483
/*
484
 * Write an object into the object database. The object is being written into
485
 * the local alternate of the repository. If provided, the converted object ID
486
 * as well as the compatibility object ID are written to the respective
487
 * pointers.
488
 *
489
 * Returns 0 on success, a negative error code otherwise.
490
 */
491
int odb_write_object_ext(struct object_database *odb,
492
       const void *buf, unsigned long len,
493
       enum object_type type,
494
       struct object_id *oid,
495
       struct object_id *compat_oid,
496
       unsigned flags);
497
498
static inline int odb_write_object(struct object_database *odb,
499
           const void *buf, unsigned long len,
500
           enum object_type type,
501
           struct object_id *oid)
502
0
{
503
  return odb_write_object_ext(odb, buf, len, type, oid, NULL, 0);
504
0
}
Unexecuted instantiation: run-command.c:odb_write_object
Unexecuted instantiation: config.c:odb_write_object
Unexecuted instantiation: dir.c:odb_write_object
Unexecuted instantiation: mailmap.c:odb_write_object
Unexecuted instantiation: object-file.c:odb_write_object
Unexecuted instantiation: object-name.c:odb_write_object
Unexecuted instantiation: object.c:odb_write_object
Unexecuted instantiation: odb.c:odb_write_object
Unexecuted instantiation: streaming.c:odb_write_object
Unexecuted instantiation: pack-write.c:odb_write_object
Unexecuted instantiation: packfile.c:odb_write_object
Unexecuted instantiation: path.c:odb_write_object
Unexecuted instantiation: promisor-remote.c:odb_write_object
Unexecuted instantiation: read-cache.c:odb_write_object
Unexecuted instantiation: refs.c:odb_write_object
Unexecuted instantiation: remote.c:odb_write_object
Unexecuted instantiation: replace-object.c:odb_write_object
Unexecuted instantiation: repo-settings.c:odb_write_object
Unexecuted instantiation: repository.c:odb_write_object
Unexecuted instantiation: revision.c:odb_write_object
Unexecuted instantiation: setup.c:odb_write_object
Unexecuted instantiation: shallow.c:odb_write_object
Unexecuted instantiation: submodule-config.c:odb_write_object
Unexecuted instantiation: submodule.c:odb_write_object
Unexecuted instantiation: tag.c:odb_write_object
Unexecuted instantiation: tmp-objdir.c:odb_write_object
Unexecuted instantiation: tree-walk.c:odb_write_object
Unexecuted instantiation: tree.c:odb_write_object
Unexecuted instantiation: attr.c:odb_write_object
Unexecuted instantiation: bisect.c:odb_write_object
Unexecuted instantiation: bloom.c:odb_write_object
Unexecuted instantiation: bundle-uri.c:odb_write_object
Unexecuted instantiation: bundle.c:odb_write_object
Unexecuted instantiation: cache-tree.c:odb_write_object
Unexecuted instantiation: combine-diff.c:odb_write_object
Unexecuted instantiation: commit-graph.c:odb_write_object
Unexecuted instantiation: commit-reach.c:odb_write_object
Unexecuted instantiation: commit.c:odb_write_object
Unexecuted instantiation: connected.c:odb_write_object
Unexecuted instantiation: convert.c:odb_write_object
Unexecuted instantiation: diff.c:odb_write_object
Unexecuted instantiation: diffcore-rename.c:odb_write_object
Unexecuted instantiation: fetch-pack.c:odb_write_object
Unexecuted instantiation: fsck.c:odb_write_object
Unexecuted instantiation: grep.c:odb_write_object
Unexecuted instantiation: list-objects.c:odb_write_object
Unexecuted instantiation: log-tree.c:odb_write_object
Unexecuted instantiation: loose.c:odb_write_object
Unexecuted instantiation: merge-ort.c:odb_write_object
Unexecuted instantiation: midx.c:odb_write_object
Unexecuted instantiation: notes-cache.c:odb_write_object
Unexecuted instantiation: notes.c:odb_write_object
Unexecuted instantiation: pack-check.c:odb_write_object
Unexecuted instantiation: pack-revindex.c:odb_write_object
Unexecuted instantiation: send-pack.c:odb_write_object
Unexecuted instantiation: sequencer.c:odb_write_object
Unexecuted instantiation: transport-helper.c:odb_write_object
Unexecuted instantiation: unpack-trees.c:odb_write_object
Unexecuted instantiation: xdiff-interface.c:odb_write_object
Unexecuted instantiation: apply.c:odb_write_object
Unexecuted instantiation: entry.c:odb_write_object
Unexecuted instantiation: list-objects-filter.c:odb_write_object
Unexecuted instantiation: match-trees.c:odb_write_object
Unexecuted instantiation: rerere.c:odb_write_object
505
506
struct odb_write_stream {
507
  const void *(*read)(struct odb_write_stream *, unsigned long *len);
508
  void *data;
509
  int is_finished;
510
};
511
512
int odb_write_object_stream(struct object_database *odb,
513
          struct odb_write_stream *stream, size_t len,
514
          struct object_id *oid);
515
516
#endif /* ODB_H */