summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-08-30 00:02:16 -0700
committerJunio C Hamano <gitster@pobox.com>2017-09-07 08:49:45 +0900
commitc913d55a08fefe01abafb7205f7ea4ad6e0bd633 (patch)
tree12190cac9c464a5f5f83d41a582e880d883568d9
parent65cf04bc0fdc6bca98b9dca4e302942faa1d7cd2 (diff)
downloadgit-c913d55a08fefe01abafb7205f7ea4ad6e0bd633.tar.gz
object-store: add repository argument to foreach_alt_odb
Add a repository argument to allow foreach_alt_odb callers to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. While at it, move the declaration to object-store.h, where it should be easier to find. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/count-objects.c2
-rw-r--r--builtin/submodule--helper.c4
-rw-r--r--cache.h2
-rw-r--r--object-store.h4
-rw-r--r--sha1_file.c4
-rw-r--r--transport.c4
6 files changed, 13 insertions, 7 deletions
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 9334648dcc..843a7d7d7e 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -155,7 +155,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
printf("prune-packable: %lu\n", packed_loose);
printf("garbage: %lu\n", garbage);
printf("size-garbage: %s\n", garbage_buf.buf);
- foreach_alt_odb(print_alternate, NULL);
+ foreach_alt_odb(the_repository, print_alternate, NULL);
strbuf_release(&loose_buf);
strbuf_release(&pack_buf);
strbuf_release(&garbage_buf);
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 818fe74f0a..299a71b90c 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -6,6 +6,7 @@
#include "quote.h"
#include "pathspec.h"
#include "dir.h"
+#include "object-store.h"
#include "submodule.h"
#include "submodule-config.h"
#include "string-list.h"
@@ -598,7 +599,8 @@ static void prepare_possible_alternates(const char *sm_name,
die(_("Value '%s' for submodule.alternateErrorStrategy is not recognized"), error_strategy);
if (!strcmp(sm_alternate, "superproject"))
- foreach_alt_odb(add_possible_reference_from_superproject, &sas);
+ foreach_alt_odb(the_repository,
+ add_possible_reference_from_superproject, &sas);
else if (!strcmp(sm_alternate, "no"))
; /* do nothing */
else
diff --git a/cache.h b/cache.h
index 5770224167..abec62dc9b 100644
--- a/cache.h
+++ b/cache.h
@@ -1524,8 +1524,6 @@ struct alternate_object_database {
char path[FLEX_ARRAY];
};
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
diff --git a/object-store.h b/object-store.h
index e749c952d5..eef8d3b653 100644
--- a/object-store.h
+++ b/object-store.h
@@ -57,4 +57,8 @@ struct packed_git {
#define prepare_alt_odb(r) prepare_alt_odb_##r()
extern void prepare_alt_odb_the_repository(void);
+typedef int alt_odb_fn(struct alternate_object_database *, void *);
+#define foreach_alt_odb(r, fn, cb) foreach_alt_odb_##r(fn, cb)
+extern int foreach_alt_odb_the_repository(alt_odb_fn, void*);
+
#endif /* OBJECT_STORE_H */
diff --git a/sha1_file.c b/sha1_file.c
index 9211c73920..8c599dbfc2 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -606,7 +606,7 @@ out:
return ref_git;
}
-int foreach_alt_odb(alt_odb_fn fn, void *cb)
+int foreach_alt_odb_the_repository(alt_odb_fn fn, void *cb)
{
struct alternate_object_database *ent;
int r = 0;
@@ -2031,7 +2031,7 @@ int for_each_loose_object(each_loose_object_fn cb, void *data, unsigned flags)
alt.cb = cb;
alt.data = data;
- return foreach_alt_odb(loose_from_alt_odb, &alt);
+ return foreach_alt_odb(the_repository, loose_from_alt_odb, &alt);
}
static int check_stream_sha1(git_zstream *stream,
diff --git a/transport.c b/transport.c
index d75ff0514d..426a3a3a80 100644
--- a/transport.c
+++ b/transport.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "transport.h"
+#include "repository.h"
#include "run-command.h"
#include "pkt-line.h"
#include "fetch-pack.h"
@@ -11,6 +12,7 @@
#include "bundle.h"
#include "dir.h"
#include "refs.h"
+#include "object-store.h"
#include "branch.h"
#include "url.h"
#include "submodule.h"
@@ -1286,5 +1288,5 @@ void for_each_alternate_ref(alternate_ref_fn fn, void *data)
struct alternate_refs_data cb;
cb.fn = fn;
cb.data = data;
- foreach_alt_odb(refs_from_alternate_cb, &cb);
+ foreach_alt_odb(the_repository, refs_from_alternate_cb, &cb);
}