summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2018-03-23 18:20:56 +0100
committerJunio C Hamano <gitster@pobox.com>2018-03-23 11:06:01 -0700
commit0d4a132144a14ae6801523960cbc1939a9bab6c1 (patch)
treec17d22ae0e9b8e01d10c699c9514d8c28345e613
parent90c62155d65a6bec5c2c293c8ece0b22173f63a3 (diff)
downloadgit-0d4a132144a14ae6801523960cbc1939a9bab6c1.tar.gz
object-store: migrate alternates struct and functions from cache.h
Migrate the struct alternate_object_database and all its related functions to the object store as these functions are easier found in that header. The migration is just a verbatim copy, no need to include the object store header at any C file, because cache.h includes repository.h which in turn includes the object-store.h Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/clone.c1
-rw-r--r--builtin/count-objects.c1
-rw-r--r--builtin/fsck.c1
-rw-r--r--builtin/submodule--helper.c1
-rw-r--r--cache.h51
-rw-r--r--object-store.h51
-rw-r--r--packfile.c1
-rw-r--r--sha1_name.c1
-rw-r--r--submodule.c1
-rw-r--r--t/helper/test-ref-store.c1
-rw-r--r--tmp-objdir.c1
-rw-r--r--transport.c1
12 files changed, 61 insertions, 51 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 101c27a593..855947f1ab 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -27,6 +27,7 @@
#include "connected.h"
#include "packfile.h"
#include "list-objects-filter-options.h"
+#include "object-store.h"
/*
* Overall FIXMEs:
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 33343818c8..ced8958e43 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -11,6 +11,7 @@
#include "parse-options.h"
#include "quote.h"
#include "packfile.h"
+#include "object-store.h"
static unsigned long garbage;
static off_t size_garbage;
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 7a8a679d4f..b0eba4c3c9 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -16,6 +16,7 @@
#include "streaming.h"
#include "decorate.h"
#include "packfile.h"
+#include "object-store.h"
#define REACHABLE 0x0001
#define SEEN 0x0002
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index b1daca995f..6d8e002be7 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -16,6 +16,7 @@
#include "revision.h"
#include "diffcore.h"
#include "diff.h"
+#include "object-store.h"
#define OPT_QUIET (1 << 0)
#define OPT_CACHED (1 << 1)
diff --git a/cache.h b/cache.h
index 41ba67cc16..41530d5d16 100644
--- a/cache.h
+++ b/cache.h
@@ -1576,57 +1576,6 @@ extern int has_dirs_only_path(const char *name, int len, int prefix_len);
extern void schedule_dir_for_removal(const char *name, int len);
extern void remove_scheduled_dirs(void);
-extern struct alternate_object_database {
- struct alternate_object_database *next;
-
- /* see alt_scratch_buf() */
- struct strbuf scratch;
- size_t base_len;
-
- /*
- * Used to store the results of readdir(3) calls when searching
- * for unique abbreviated hashes. This cache is never
- * invalidated, thus it's racy and not necessarily accurate.
- * That's fine for its purpose; don't use it for tasks requiring
- * greater accuracy!
- */
- char loose_objects_subdir_seen[256];
- struct oid_array loose_objects_cache;
-
- char path[FLEX_ARRAY];
-} *alt_odb_list;
-extern void prepare_alt_odb(void);
-extern char *compute_alternate_path(const char *path, struct strbuf *err);
-typedef int alt_odb_fn(struct alternate_object_database *, void *);
-extern int foreach_alt_odb(alt_odb_fn, void*);
-
-/*
- * Allocate a "struct alternate_object_database" but do _not_ actually
- * add it to the list of alternates.
- */
-struct alternate_object_database *alloc_alt_odb(const char *dir);
-
-/*
- * Add the directory to the on-disk alternates file; the new entry will also
- * take effect in the current process.
- */
-extern void add_to_alternates_file(const char *dir);
-
-/*
- * Add the directory to the in-memory list of alternates (along with any
- * recursive alternates it points to), but do not modify the on-disk alternates
- * file.
- */
-extern void add_to_alternates_memory(const char *dir);
-
-/*
- * Returns a scratch strbuf pre-filled with the alternate object directory,
- * including a trailing slash, which can be used to access paths in the
- * alternate. Always use this over direct access to alt->scratch, as it
- * cleans up any previous use of the scratch buffer.
- */
-extern struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
-
struct pack_window {
struct pack_window *next;
unsigned char *base;
diff --git a/object-store.h b/object-store.h
index abfaae059b..5002e373cd 100644
--- a/object-store.h
+++ b/object-store.h
@@ -1,6 +1,57 @@
#ifndef OBJECT_STORE_H
#define OBJECT_STORE_H
+extern struct alternate_object_database {
+ struct alternate_object_database *next;
+
+ /* see alt_scratch_buf() */
+ struct strbuf scratch;
+ size_t base_len;
+
+ /*
+ * Used to store the results of readdir(3) calls when searching
+ * for unique abbreviated hashes. This cache is never
+ * invalidated, thus it's racy and not necessarily accurate.
+ * That's fine for its purpose; don't use it for tasks requiring
+ * greater accuracy!
+ */
+ char loose_objects_subdir_seen[256];
+ struct oid_array loose_objects_cache;
+
+ char path[FLEX_ARRAY];
+} *alt_odb_list;
+void prepare_alt_odb(void);
+char *compute_alternate_path(const char *path, struct strbuf *err);
+typedef int alt_odb_fn(struct alternate_object_database *, void *);
+int foreach_alt_odb(alt_odb_fn, void*);
+
+/*
+ * Allocate a "struct alternate_object_database" but do _not_ actually
+ * add it to the list of alternates.
+ */
+struct alternate_object_database *alloc_alt_odb(const char *dir);
+
+/*
+ * Add the directory to the on-disk alternates file; the new entry will also
+ * take effect in the current process.
+ */
+void add_to_alternates_file(const char *dir);
+
+/*
+ * Add the directory to the in-memory list of alternates (along with any
+ * recursive alternates it points to), but do not modify the on-disk alternates
+ * file.
+ */
+void add_to_alternates_memory(const char *dir);
+
+/*
+ * Returns a scratch strbuf pre-filled with the alternate object directory,
+ * including a trailing slash, which can be used to access paths in the
+ * alternate. Always use this over direct access to alt->scratch, as it
+ * cleans up any previous use of the scratch buffer.
+ */
+struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
+
struct raw_object_store {
/*
* Path to the repository's object store.
diff --git a/packfile.c b/packfile.c
index 7dbe8739d1..c6651682a7 100644
--- a/packfile.c
+++ b/packfile.c
@@ -13,6 +13,7 @@
#include "tag.h"
#include "tree-walk.h"
#include "tree.h"
+#include "object-store.h"
char *odb_pack_name(struct strbuf *buf,
const unsigned char *sha1,
diff --git a/sha1_name.c b/sha1_name.c
index 611c7d24dd..434025bf03 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -10,6 +10,7 @@
#include "dir.h"
#include "sha1-array.h"
#include "packfile.h"
+#include "object-store.h"
static int get_oid_oneline(const char *, struct object_id *, struct commit_list *);
diff --git a/submodule.c b/submodule.c
index 47ddc9b273..b03e5f5045 100644
--- a/submodule.c
+++ b/submodule.c
@@ -21,6 +21,7 @@
#include "remote.h"
#include "worktree.h"
#include "parse-options.h"
+#include "object-store.h"
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP;
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 7120634b04..7314b5943e 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "refs.h"
#include "worktree.h"
+#include "object-store.h"
static const char *notnull(const char *arg, const char *name)
{
diff --git a/tmp-objdir.c b/tmp-objdir.c
index b2d9280f10..fea3f55545 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -6,6 +6,7 @@
#include "strbuf.h"
#include "argv-array.h"
#include "quote.h"
+#include "object-store.h"
struct tmp_objdir {
struct strbuf path;
diff --git a/transport.c b/transport.c
index 00d48b5b56..3afc632472 100644
--- a/transport.c
+++ b/transport.c
@@ -18,6 +18,7 @@
#include "sha1-array.h"
#include "sigchain.h"
#include "transport-internal.h"
+#include "object-store.h"
static void set_upstreams(struct transport *transport, struct ref *refs,
int pretend)