summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/fetch-pack.c2
-rw-r--r--builtin/receive-pack.c2
-rw-r--r--transport.c20
-rw-r--r--transport.h2
4 files changed, 20 insertions, 6 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 85aff029b2..60a17c74ef 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -226,7 +226,7 @@ static void insert_one_alternate_ref(const struct ref *ref, void *unused)
static void insert_alternate_refs(void)
{
- foreach_alt_odb(refs_from_alternate_cb, insert_one_alternate_ref);
+ for_each_alternate_ref(insert_one_alternate_ref, NULL);
}
#define INITIAL_FLUSH 16
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index e1ba4dc697..6bb1281666 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -738,7 +738,7 @@ static void add_one_alternate_ref(const struct ref *ref, void *unused)
static void add_alternate_refs(void)
{
- foreach_alt_odb(refs_from_alternate_cb, add_one_alternate_ref);
+ for_each_alternate_ref(add_one_alternate_ref, NULL);
}
int cmd_receive_pack(int argc, const char **argv, const char *prefix)
diff --git a/transport.c b/transport.c
index a02f79aae3..1a3998ee51 100644
--- a/transport.c
+++ b/transport.c
@@ -1190,14 +1190,20 @@ literal_copy:
return xstrdup(url);
}
-int refs_from_alternate_cb(struct alternate_object_database *e, void *cb)
+struct alternate_refs_data {
+ alternate_ref_fn *fn;
+ void *data;
+};
+
+static int refs_from_alternate_cb(struct alternate_object_database *e,
+ void *data)
{
char *other;
size_t len;
struct remote *remote;
struct transport *transport;
const struct ref *extra;
- alternate_ref_fn *ref_fn = cb;
+ struct alternate_refs_data *cb = data;
e->name[-1] = '\0';
other = xstrdup(real_path(e->base));
@@ -1218,8 +1224,16 @@ int refs_from_alternate_cb(struct alternate_object_database *e, void *cb)
for (extra = transport_get_remote_refs(transport);
extra;
extra = extra->next)
- ref_fn(extra, NULL);
+ cb->fn(extra, cb->data);
transport_disconnect(transport);
free(other);
return 0;
}
+
+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);
+}
diff --git a/transport.h b/transport.h
index efb1968869..161d724bba 100644
--- a/transport.h
+++ b/transport.h
@@ -167,6 +167,6 @@ void transport_print_push_status(const char *dest, struct ref *refs,
int verbose, int porcelain, int *nonfastforward);
typedef void alternate_ref_fn(const struct ref *, void *);
-extern int refs_from_alternate_cb(struct alternate_object_database *e, void *cb);
+extern void for_each_alternate_ref(alternate_ref_fn, void *);
#endif