Remove fetch-object.{c,h} in favor of promisor-remote.{c,h}

As fetch_objects() is now used only in promisor-remote.c and should't be used outside it, let's move it into promisor-remote.c, make it static there, and remove fetch-object.{c,h}. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Jun 25, 2019 at 15:40 UTC db27dca5cfe41ffa62f3a34cff2f7fafb2547307
4 files changed +39 -54
Makefile
-1
@@ -880,7 +880,6 @@ LIB_OBJS += ewah/ewah_io.o
880 LIB_OBJS += ewah/ewah_rlw.o
881 LIB_OBJS += exec-cmd.o
882 LIB_OBJS += fetch-negotiator.o
883 -LIB_OBJS += fetch-object.o
883 LIB_OBJS += fetch-pack.o
884 LIB_OBJS += fsck.o
885 LIB_OBJS += fsmonitor.o
fetch-object.c deleted
-43
@@ -1,43 +0,0 @@
1 -#include "cache.h"
2 -#include "packfile.h"
3 -#include "pkt-line.h"
4 -#include "strbuf.h"
5 -#include "transport.h"
6 -#include "fetch-object.h"
7 -
8 -static int fetch_refs(const char *remote_name, struct ref *ref)
9 -{
10 - struct remote *remote;
11 - struct transport *transport;
12 - int original_fetch_if_missing = fetch_if_missing;
13 - int res;
14 -
15 - fetch_if_missing = 0;
16 - remote = remote_get(remote_name);
17 - if (!remote->url[0])
18 - die(_("Remote with no URL"));
19 - transport = transport_get(remote, remote->url[0]);
20 -
21 - transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
22 - transport_set_option(transport, TRANS_OPT_NO_DEPENDENTS, "1");
23 - res = transport_fetch_refs(transport, ref);
24 - fetch_if_missing = original_fetch_if_missing;
25 -
26 - return res;
27 -}
28 -
29 -int fetch_objects(const char *remote_name, const struct object_id *oids,
30 - int oid_nr)
31 -{
32 - struct ref *ref = NULL;
33 - int i;
34 -
35 - for (i = 0; i < oid_nr; i++) {
36 - struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
37 - oidcpy(&new_ref->old_oid, &oids[i]);
38 - new_ref->exact_oid = 1;
39 - new_ref->next = ref;
40 - ref = new_ref;
41 - }
42 - return fetch_refs(remote_name, ref);
43 -}
fetch-object.h deleted
-9
@@ -1,9 +0,0 @@
1 -#ifndef FETCH_OBJECT_H
2 -#define FETCH_OBJECT_H
3 -
4 -struct object_id;
5 -
6 -int fetch_objects(const char *remote_name, const struct object_id *oids,
7 - int oid_nr);
8 -
9 -#endif
promisor-remote.c
+39 -1
@@ -2,7 +2,45 @@
2 #include "object-store.h"
3 #include "promisor-remote.h"
4 #include "config.h"
5 -#include "fetch-object.h"
5 +#include "transport.h"
6 +
7 +static int fetch_refs(const char *remote_name, struct ref *ref)
8 +{
9 + struct remote *remote;
10 + struct transport *transport;
11 + int original_fetch_if_missing = fetch_if_missing;
12 + int res;
13 +
14 + fetch_if_missing = 0;
15 + remote = remote_get(remote_name);
16 + if (!remote->url[0])
17 + die(_("Remote with no URL"));
18 + transport = transport_get(remote, remote->url[0]);
19 +
20 + transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
21 + transport_set_option(transport, TRANS_OPT_NO_DEPENDENTS, "1");
22 + res = transport_fetch_refs(transport, ref);
23 + fetch_if_missing = original_fetch_if_missing;
24 +
25 + return res;
26 +}
27 +
28 +static int fetch_objects(const char *remote_name,
29 + const struct object_id *oids,
30 + int oid_nr)
31 +{
32 + struct ref *ref = NULL;
33 + int i;
34 +
35 + for (i = 0; i < oid_nr; i++) {
36 + struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
37 + oidcpy(&new_ref->old_oid, &oids[i]);
38 + new_ref->exact_oid = 1;
39 + new_ref->next = ref;
40 + ref = new_ref;
41 + }
42 + return fetch_refs(remote_name, ref);
43 +}
44
45 static struct promisor_remote *promisors;
46 static struct promisor_remote **promisors_tail = &promisors;