Browse Source

object-store: move object access functions to object-store.h

This should make these functions easier to find and cache.h less
overwhelming to read.

In particular, this moves:
- read_object_file
- oid_object_info
- write_object_file

As a result, most of the codebase needs to #include object-store.h.
In this patch the #include is only added to files that would fail to
compile otherwise.  It would be better to #include wherever
identifiers from the header are used.  That can happen later
when we have better tooling for it.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Stefan Beller 7 years ago committed by Junio C Hamano
parent
commit
cbd53a2193
  1. 1
      apply.c
  2. 1
      archive-tar.c
  3. 1
      archive-zip.c
  4. 1
      archive.c
  5. 1
      blame.c
  6. 1
      builtin/blame.c
  7. 1
      builtin/cat-file.c
  8. 1
      builtin/checkout.c
  9. 1
      builtin/clone.c
  10. 1
      builtin/commit-tree.c
  11. 1
      builtin/describe.c
  12. 1
      builtin/difftool.c
  13. 1
      builtin/fast-export.c
  14. 1
      builtin/fetch.c
  15. 1
      builtin/fmt-merge-msg.c
  16. 1
      builtin/hash-object.c
  17. 1
      builtin/log.c
  18. 1
      builtin/ls-tree.c
  19. 1
      builtin/merge-tree.c
  20. 1
      builtin/mktag.c
  21. 1
      builtin/mktree.c
  22. 1
      builtin/notes.c
  23. 1
      builtin/prune.c
  24. 1
      builtin/receive-pack.c
  25. 1
      builtin/reflog.c
  26. 1
      builtin/remote.c
  27. 1
      builtin/rev-list.c
  28. 1
      builtin/show-ref.c
  29. 1
      builtin/tag.c
  30. 1
      builtin/unpack-file.c
  31. 1
      builtin/unpack-objects.c
  32. 1
      builtin/verify-commit.c
  33. 1
      bulk-checkin.c
  34. 1
      bundle.c
  35. 1
      cache-tree.c
  36. 117
      cache.h
  37. 1
      combine-diff.c
  38. 1
      commit.c
  39. 1
      config.c
  40. 1
      convert.c
  41. 1
      diff.c
  42. 1
      diffcore-rename.c
  43. 1
      dir.c
  44. 1
      entry.c
  45. 1
      fetch-pack.c
  46. 1
      fsck.c
  47. 1
      grep.c
  48. 1
      list-objects-filter.c
  49. 1
      list-objects.c
  50. 1
      log-tree.c
  51. 1
      mailmap.c
  52. 1
      match-trees.c
  53. 1
      merge-blobs.c
  54. 1
      merge-recursive.c
  55. 1
      notes-cache.c
  56. 1
      notes-merge.c
  57. 1
      notes.c
  58. 117
      object-store.h
  59. 1
      object.c
  60. 1
      pack-bitmap-write.c
  61. 5
      packfile.h
  62. 1
      read-cache.c
  63. 1
      ref-filter.c
  64. 1
      refs.c
  65. 1
      remote-testsvn.c
  66. 1
      remote.c
  67. 1
      rerere.c
  68. 1
      revision.c
  69. 1
      send-pack.c
  70. 1
      sequencer.c
  71. 1
      shallow.c
  72. 1
      submodule-config.c
  73. 1
      tag.c
  74. 1
      tree-walk.c
  75. 1
      tree.c
  76. 1
      unpack-trees.c
  77. 1
      upload-pack.c
  78. 1
      walker.c
  79. 1
      xdiff-interface.c

1
apply.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@

#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "delta.h"
#include "diff.h"

1
archive-tar.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#include "config.h"
#include "tar.h"
#include "archive.h"
#include "object-store.h"
#include "streaming.h"
#include "run-command.h"


1
archive-zip.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "archive.h"
#include "streaming.h"
#include "utf8.h"
#include "object-store.h"
#include "userdiff.h"
#include "xdiff-interface.h"


1
archive.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "tree-walk.h"
#include "attr.h"

1
blame.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "refs.h"
#include "object-store.h"
#include "cache-tree.h"
#include "mergesort.h"
#include "diff.h"

1
builtin/blame.c

@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
#include "line-log.h"
#include "dir.h"
#include "progress.h"
#include "object-store.h"
#include "blame.h"

static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");

1
builtin/cat-file.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "tree-walk.h"
#include "sha1-array.h"
#include "packfile.h"
#include "object-store.h"

struct batch_options {
int enabled;

1
builtin/checkout.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "lockfile.h"
#include "parse-options.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"

1
builtin/clone.c

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
#include "parse-options.h"
#include "fetch-pack.h"
#include "refs.h"
#include "object-store.h"
#include "tree.h"
#include "tree-walk.h"
#include "unpack-trees.h"

1
builtin/commit-tree.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "builtin.h"

1
builtin/describe.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "hashmap.h"
#include "argv-array.h"
#include "run-command.h"
#include "object-store.h"
#include "revision.h"
#include "list-objects.h"


1
builtin/difftool.c

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include "argv-array.h"
#include "strbuf.h"
#include "lockfile.h"
#include "object-store.h"
#include "dir.h"

static char *diff_gui_tool;

1
builtin/fast-export.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "object.h"
#include "tag.h"

1
builtin/fetch.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
#include "config.h"
#include "repository.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "builtin.h"
#include "string-list.h"

1
builtin/fmt-merge-msg.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"

1
builtin/hash-object.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
*/
#include "builtin.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "quote.h"
#include "parse-options.h"

1
builtin/log.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "cache.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "color.h"
#include "commit.h"
#include "diff.h"

1
builtin/ls-tree.c

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"

1
builtin/merge-tree.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "builtin.h"
#include "tree-walk.h"
#include "xdiff-interface.h"
#include "object-store.h"
#include "blob.h"
#include "exec_cmd.h"
#include "merge-blobs.h"

1
builtin/mktag.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "builtin.h"
#include "tag.h"
#include "replace-object.h"
#include "object-store.h"

/*
* A signature file has a very simple fixed format: four lines

1
builtin/mktree.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "quote.h"
#include "tree.h"
#include "parse-options.h"
#include "object-store.h"

static struct treeent {
unsigned mode;

1
builtin/notes.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "config.h"
#include "builtin.h"
#include "notes.h"
#include "object-store.h"
#include "blob.h"
#include "pretty.h"
#include "refs.h"

1
builtin/prune.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "reachable.h"
#include "parse-options.h"
#include "progress.h"
#include "object-store.h"

static const char * const prune_usage[] = {
N_("git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]"),

1
builtin/receive-pack.c

@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
#include "tmp-objdir.h"
#include "oidset.h"
#include "packfile.h"
#include "object-store.h"
#include "protocol.h"

static const char * const receive_pack_usage[] = {

1
builtin/reflog.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "builtin.h"
#include "config.h"
#include "lockfile.h"
#include "object-store.h"
#include "commit.h"
#include "refs.h"
#include "dir.h"

1
builtin/remote.c

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
#include "strbuf.h"
#include "run-command.h"
#include "refs.h"
#include "object-store.h"
#include "argv-array.h"

static const char * const builtin_remote_usage[] = {

1
builtin/rev-list.c

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "list-objects.h"
#include "list-objects-filter.h"
#include "list-objects-filter-options.h"
#include "object-store.h"
#include "pack.h"
#include "pack-bitmap.h"
#include "builtin.h"

1
builtin/show-ref.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "builtin.h"
#include "cache.h"
#include "refs.h"
#include "object-store.h"
#include "object.h"
#include "tag.h"
#include "string-list.h"

1
builtin/tag.c

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include "config.h"
#include "builtin.h"
#include "refs.h"
#include "object-store.h"
#include "tag.h"
#include "run-command.h"
#include "parse-options.h"

1
builtin/unpack-file.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "builtin.h"
#include "config.h"
#include "object-store.h"

static char *create_temp_file(struct object_id *oid)
{

1
builtin/unpack-objects.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "builtin.h"
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "object.h"
#include "delta.h"
#include "pack.h"

1
builtin/verify-commit.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "cache.h"
#include "config.h"
#include "builtin.h"
#include "object-store.h"
#include "commit.h"
#include "run-command.h"
#include <signal.h>

1
bulk-checkin.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "pack.h"
#include "strbuf.h"
#include "packfile.h"
#include "object-store.h"

static struct bulk_checkin_state {
unsigned plugged:1;

1
bundle.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "lockfile.h"
#include "bundle.h"
#include "object-store.h"
#include "object.h"
#include "commit.h"
#include "diff.h"

1
cache-tree.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "tree.h"
#include "tree-walk.h"
#include "cache-tree.h"
#include "object-store.h"

#ifndef DEBUG
#define DEBUG 0

117
cache.h

@ -1183,32 +1183,6 @@ extern char *xdg_config_home(const char *filename); @@ -1183,32 +1183,6 @@ extern char *xdg_config_home(const char *filename);
*/
extern char *xdg_cache_home(const char *filename);

extern void *read_object_file_extended(const struct object_id *oid,
enum object_type *type,
unsigned long *size, int lookup_replace);
static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
{
return read_object_file_extended(oid, type, size, 1);
}

/* Read and unpack an object file into memory, write memory to an object file */
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);

extern int hash_object_file(const void *buf, unsigned long len,
const char *type, struct object_id *oid);

extern int write_object_file(const void *buf, unsigned long len,
const char *type, struct object_id *oid);

extern int hash_object_file_literally(const void *buf, unsigned long len,
const char *type, struct object_id *oid,
unsigned flags);

extern int pretend_object_file(void *, unsigned long, enum object_type,
struct object_id *oid);

extern int force_object_loose(const struct object_id *oid, time_t mtime);

extern int git_open_cloexec(const char *name, int flags);
#define git_open(name) git_open_cloexec(name, O_RDONLY)
extern int unpack_sha1_header(git_zstream *stream, unsigned char *map, unsigned long mapsize, void *buffer, unsigned long bufsiz);
@ -1218,43 +1192,6 @@ extern int check_object_signature(const struct object_id *oid, void *buf, unsign @@ -1218,43 +1192,6 @@ extern int check_object_signature(const struct object_id *oid, void *buf, unsign

extern int finalize_object_file(const char *tmpfile, const char *filename);

/*
* Open the loose object at path, check its hash, and return the contents,
* type, and size. If the object is a blob, then "contents" may return NULL,
* to allow streaming of large blobs.
*
* Returns 0 on success, negative on error (details may be written to stderr).
*/
int read_loose_object(const char *path,
const struct object_id *expected_oid,
enum object_type *type,
unsigned long *size,
void **contents);

/*
* Convenience for sha1_object_info_extended() with a NULL struct
* object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass
* nonzero flags to also set other flags.
*/
extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);
static inline int has_sha1_file(const unsigned char *sha1)
{
return has_sha1_file_with_flags(sha1, 0);
}

/* Same as the above, except for struct object_id. */
extern int has_object_file(const struct object_id *oid);
extern int has_object_file_with_flags(const struct object_id *oid, int flags);

/*
* Return true iff an alternate object database has a loose object
* with the specified name. This function does not respect replace
* references.
*/
extern int has_loose_object_nonlocal(const unsigned char *sha1);

extern void assert_oid_type(const struct object_id *oid, enum object_type expect);

/* Helper to check and "touch" a file */
extern int check_and_freshen_file(const char *fn, int freshen);

@ -1624,60 +1561,6 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path, @@ -1624,60 +1561,6 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,
#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);

struct object_info {
/* Request */
enum object_type *typep;
unsigned long *sizep;
off_t *disk_sizep;
unsigned char *delta_base_sha1;
struct strbuf *type_name;
void **contentp;

/* Response */
enum {
OI_CACHED,
OI_LOOSE,
OI_PACKED,
OI_DBCACHED
} whence;
union {
/*
* struct {
* ... Nothing to expose in this case
* } cached;
* struct {
* ... Nothing to expose in this case
* } loose;
*/
struct {
struct packed_git *pack;
off_t offset;
unsigned int is_delta;
} packed;
} u;
};

/*
* Initializer for a "struct object_info" that wants no items. You may
* also memset() the memory to all-zeroes.
*/
#define OBJECT_INFO_INIT {NULL}

/* Invoke lookup_replace_object() on the given hash */
#define OBJECT_INFO_LOOKUP_REPLACE 1
/* Allow reading from a loose object file of unknown/bogus type */
#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
/* Do not check cached storage */
#define OBJECT_INFO_SKIP_CACHED 4
/* Do not retry packed storage after checking packed and loose storage */
#define OBJECT_INFO_QUICK 8
/* Do not check loose object */
#define OBJECT_INFO_IGNORE_LOOSE 16

int oid_object_info_extended(struct repository *r,
const struct object_id *,
struct object_info *, unsigned flags);

/*
* Set this to 0 to prevent sha1_object_info_extended() from fetching missing
* blobs. This has a difference only if extensions.partialClone is set.

1
combine-diff.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "object-store.h"
#include "commit.h"
#include "blob.h"
#include "diff.h"

1
commit.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "tag.h"
#include "commit.h"
#include "object-store.h"
#include "pkt-line.h"
#include "utf8.h"
#include "diff.h"

1
config.c

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
#include "quote.h"
#include "hashmap.h"
#include "string-list.h"
#include "object-store.h"
#include "utf8.h"
#include "dir.h"


1
convert.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#define NO_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "attr.h"
#include "run-command.h"
#include "quote.h"

1
diff.c

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include "attr.h"
#include "run-command.h"
#include "utf8.h"
#include "object-store.h"
#include "userdiff.h"
#include "submodule-config.h"
#include "submodule.h"

1
diffcore-rename.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "cache.h"
#include "diff.h"
#include "diffcore.h"
#include "object-store.h"
#include "hashmap.h"
#include "progress.h"


1
dir.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "cache.h"
#include "config.h"
#include "dir.h"
#include "object-store.h"
#include "attr.h"
#include "refs.h"
#include "wildmatch.h"

1
entry.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "blob.h"
#include "object-store.h"
#include "dir.h"
#include "streaming.h"
#include "submodule.h"

1
fetch-pack.c

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
#include "sha1-array.h"
#include "oidset.h"
#include "packfile.h"
#include "object-store.h"

static int transfer_unpack_limit = -1;
static int fetch_unpack_limit = -1;

1
fsck.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "object-store.h"
#include "object.h"
#include "blob.h"
#include "tree.h"

1
grep.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "grep.h"
#include "object-store.h"
#include "userdiff.h"
#include "xdiff-interface.h"
#include "diff.h"

1
list-objects-filter.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "list-objects-filter.h"
#include "list-objects-filter-options.h"
#include "oidset.h"
#include "object-store.h"

/* Remember to update object flag allocation in object.h */
/*

1
list-objects.c

@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
#include "list-objects-filter.h"
#include "list-objects-filter-options.h"
#include "packfile.h"
#include "object-store.h"

static void process_blob(struct rev_info *revs,
struct blob *blob,

1
log-tree.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "diff.h"
#include "object-store.h"
#include "commit.h"
#include "tag.h"
#include "graph.h"

1
mailmap.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "string-list.h"
#include "mailmap.h"
#include "object-store.h"

#define DEBUG_MAILMAP 0
#if DEBUG_MAILMAP

1
match-trees.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "tree.h"
#include "tree-walk.h"
#include "object-store.h"

static int score_missing(unsigned mode, const char *path)
{

1
merge-blobs.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "ll-merge.h"
#include "blob.h"
#include "merge-blobs.h"
#include "object-store.h"

static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
{

1
merge-recursive.c

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
#include "advice.h"
#include "lockfile.h"
#include "cache-tree.h"
#include "object-store.h"
#include "commit.h"
#include "blob.h"
#include "builtin.h"

1
notes-cache.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "notes-cache.h"
#include "object-store.h"
#include "commit.h"
#include "refs.h"


1
notes-merge.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "commit.h"
#include "refs.h"
#include "object-store.h"
#include "diff.h"
#include "diffcore.h"
#include "xdiff-interface.h"

1
notes.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "notes.h"
#include "object-store.h"
#include "blob.h"
#include "tree.h"
#include "utf8.h"

117
object-store.h

@ -137,4 +137,121 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha @@ -137,4 +137,121 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha

void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);

extern void *read_object_file_extended(const struct object_id *oid,
enum object_type *type,
unsigned long *size, int lookup_replace);
static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
{
return read_object_file_extended(oid, type, size, 1);
}

/* Read and unpack an object file into memory, write memory to an object file */
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);

extern int hash_object_file(const void *buf, unsigned long len,
const char *type, struct object_id *oid);

extern int write_object_file(const void *buf, unsigned long len,
const char *type, struct object_id *oid);

extern int hash_object_file_literally(const void *buf, unsigned long len,
const char *type, struct object_id *oid,
unsigned flags);

extern int pretend_object_file(void *, unsigned long, enum object_type,
struct object_id *oid);

extern int force_object_loose(const struct object_id *oid, time_t mtime);

/*
* Open the loose object at path, check its hash, and return the contents,
* type, and size. If the object is a blob, then "contents" may return NULL,
* to allow streaming of large blobs.
*
* Returns 0 on success, negative on error (details may be written to stderr).
*/
int read_loose_object(const char *path,
const struct object_id *expected_oid,
enum object_type *type,
unsigned long *size,
void **contents);

/*
* Convenience for sha1_object_info_extended() with a NULL struct
* object_info. OBJECT_INFO_SKIP_CACHED is automatically set; pass
* nonzero flags to also set other flags.
*/
extern int has_sha1_file_with_flags(const unsigned char *sha1, int flags);
static inline int has_sha1_file(const unsigned char *sha1)
{
return has_sha1_file_with_flags(sha1, 0);
}

/* Same as the above, except for struct object_id. */
extern int has_object_file(const struct object_id *oid);
extern int has_object_file_with_flags(const struct object_id *oid, int flags);

/*
* Return true iff an alternate object database has a loose object
* with the specified name. This function does not respect replace
* references.
*/
extern int has_loose_object_nonlocal(const unsigned char *sha1);

extern void assert_oid_type(const struct object_id *oid, enum object_type expect);

struct object_info {
/* Request */
enum object_type *typep;
unsigned long *sizep;
off_t *disk_sizep;
unsigned char *delta_base_sha1;
struct strbuf *type_name;
void **contentp;

/* Response */
enum {
OI_CACHED,
OI_LOOSE,
OI_PACKED,
OI_DBCACHED
} whence;
union {
/*
* struct {
* ... Nothing to expose in this case
* } cached;
* struct {
* ... Nothing to expose in this case
* } loose;
*/
struct {
struct packed_git *pack;
off_t offset;
unsigned int is_delta;
} packed;
} u;
};

/*
* Initializer for a "struct object_info" that wants no items. You may
* also memset() the memory to all-zeroes.
*/
#define OBJECT_INFO_INIT {NULL}

/* Invoke lookup_replace_object() on the given hash */
#define OBJECT_INFO_LOOKUP_REPLACE 1
/* Allow reading from a loose object file of unknown/bogus type */
#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
/* Do not check cached storage */
#define OBJECT_INFO_SKIP_CACHED 4
/* Do not retry packed storage after checking packed and loose storage */
#define OBJECT_INFO_QUICK 8
/* Do not check loose object */
#define OBJECT_INFO_IGNORE_LOOSE 16

int oid_object_info_extended(struct repository *r,
const struct object_id *,
struct object_info *, unsigned flags);

#endif /* OBJECT_STORE_H */

1
object.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "object.h"
#include "replace-object.h"
#include "object-store.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"

1
pack-bitmap-write.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "object-store.h"
#include "commit.h"
#include "tag.h"
#include "diff.h"

5
packfile.h

@ -3,6 +3,11 @@ @@ -3,6 +3,11 @@

#include "oidset.h"

/* in object-store.h */
struct packed_git;
struct object_info;
enum object_type;

/*
* Generate the filename to be used for a pack file with checksum "sha1" and
* extension "ext". The result is written into the strbuf "buf", overwriting

1
read-cache.c

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "cache-tree.h"
#include "refs.h"
#include "dir.h"
#include "object-store.h"
#include "tree.h"
#include "commit.h"
#include "blob.h"

1
ref-filter.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "parse-options.h"
#include "refs.h"
#include "wildmatch.h"
#include "object-store.h"
#include "commit.h"
#include "remote.h"
#include "color.h"

1
refs.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "iterator.h"
#include "refs.h"
#include "refs/refs-internal.h"
#include "object-store.h"
#include "object.h"
#include "tag.h"
#include "submodule.h"

1
remote-testsvn.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "refs.h"
#include "remote.h"
#include "object-store.h"
#include "strbuf.h"
#include "url.h"
#include "exec_cmd.h"

1
remote.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "config.h"
#include "remote.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"

1
rerere.c

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "ll-merge.h"
#include "attr.h"
#include "pathspec.h"
#include "object-store.h"
#include "sha1-lookup.h"

#define RESOLVED 0

1
revision.c

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
#include "cache.h"
#include "object-store.h"
#include "tag.h"
#include "blob.h"
#include "tree.h"

1
send-pack.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "config.h"
#include "commit.h"
#include "refs.h"
#include "object-store.h"
#include "pkt-line.h"
#include "sideband.h"
#include "run-command.h"

1
sequencer.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "config.h"
#include "lockfile.h"
#include "dir.h"
#include "object-store.h"
#include "object.h"
#include "commit.h"
#include "sequencer.h"

1
shallow.c

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
#include "cache.h"
#include "tempfile.h"
#include "lockfile.h"
#include "object-store.h"
#include "commit.h"
#include "tag.h"
#include "pkt-line.h"

1
submodule-config.c

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
#include "submodule-config.h"
#include "submodule.h"
#include "strbuf.h"
#include "object-store.h"
#include "parse-options.h"

/*

1
tag.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "tag.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "blob.h"

1
tree-walk.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "tree-walk.h"
#include "unpack-trees.h"
#include "dir.h"
#include "object-store.h"
#include "tree.h"
#include "pathspec.h"


1
tree.c

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include "cache.h"
#include "cache-tree.h"
#include "tree.h"
#include "object-store.h"
#include "blob.h"
#include "commit.h"
#include "tag.h"

1
unpack-trees.c

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
#include "submodule.h"
#include "submodule-config.h"
#include "fsmonitor.h"
#include "object-store.h"
#include "fetch-object.h"

/*

1
upload-pack.c

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
#include "refs.h"
#include "pkt-line.h"
#include "sideband.h"
#include "object-store.h"
#include "tag.h"
#include "object.h"
#include "commit.h"

1
walker.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "walker.h"
#include "object-store.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"

1
xdiff-interface.c

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
#include "object-store.h"
#include "xdiff-interface.h"
#include "xdiff/xtypes.h"
#include "xdiff/xdiffi.h"

Loading…
Cancel
Save