remote: add promisor and partial clone config to the doc
[git.git] / fetch-object.c
blobeac4d448ef2ce97c2eb0a434d3b133c1c9224552
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"
8 static int fetch_refs(const char *remote_name, struct ref *ref)
10 struct remote *remote;
11 struct transport *transport;
12 int original_fetch_if_missing = fetch_if_missing;
13 int res;
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]);
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;
26 return res;
29 int fetch_objects(const char *remote_name, const struct object_id *oids,
30 int oid_nr)
32 struct ref *ref = NULL;
33 int i;
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;
42 return fetch_refs(remote_name, ref);