blob: 42665488008bc0fffafa5d4e0455bc22b510b92a [file] [log] [blame]
Jonathan Tan88e2f9e2017-12-05 16:58:49 +00001#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
Jonathan Tanc0c578b2017-12-08 15:58:47 +00008static void fetch_refs(const char *remote_name, struct ref *ref)
Jonathan Tan88e2f9e2017-12-05 16:58:49 +00009{
10 struct remote *remote;
11 struct transport *transport;
Jonathan Tan8b4c0102017-12-08 15:27:14 +000012 int original_fetch_if_missing = fetch_if_missing;
Jonathan Tan88e2f9e2017-12-05 16:58:49 +000013
Jonathan Tan8b4c0102017-12-08 15:27:14 +000014 fetch_if_missing = 0;
Jonathan Tan88e2f9e2017-12-05 16:58:49 +000015 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
Jonathan Tan88e2f9e2017-12-05 16:58:49 +000020 transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
21 transport_set_option(transport, TRANS_OPT_NO_DEPENDENTS, "1");
Jonathan Tane2842b32018-08-01 13:13:20 -070022 transport_fetch_refs(transport, ref);
Jonathan Tan8b4c0102017-12-08 15:27:14 +000023 fetch_if_missing = original_fetch_if_missing;
Jonathan Tan88e2f9e2017-12-05 16:58:49 +000024}
Jonathan Tanc0c578b2017-12-08 15:58:47 +000025
Jonathan Tan8708ca02018-09-12 08:47:37 -070026void fetch_objects(const char *remote_name, const struct object_id *oids,
27 int oid_nr)
Jonathan Tanc0c578b2017-12-08 15:58:47 +000028{
29 struct ref *ref = NULL;
30 int i;
31
Jonathan Tan8708ca02018-09-12 08:47:37 -070032 for (i = 0; i < oid_nr; i++) {
33 struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i]));
34 oidcpy(&new_ref->old_oid, &oids[i]);
Jonathan Tane6830202018-09-12 08:47:38 -070035 new_ref->exact_oid = 1;
Jonathan Tanc0c578b2017-12-08 15:58:47 +000036 new_ref->next = ref;
37 ref = new_ref;
38 }
39 fetch_refs(remote_name, ref);
40}