diff options
author | Jonathan Tan <jonathantanmy@google.com> | 2018-09-12 15:47:37 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-09-13 20:56:19 (GMT) |
commit | 8708ca09a67aeccab1d6852382cfd9267a8a395e (patch) | |
tree | 78eb4e662c0c0c5a571604ae360f355b48c3c043 /fetch-object.c | |
parent | 1d4361b0f344188ab5eec6dcea01f61a3a3a1670 (diff) | |
download | git-8708ca09a67aeccab1d6852382cfd9267a8a395e.zip git-8708ca09a67aeccab1d6852382cfd9267a8a395e.tar.gz git-8708ca09a67aeccab1d6852382cfd9267a8a395e.tar.bz2 |
fetch-object: unify fetch_object[s] functions
There are fetch_object() and fetch_objects() helpers in
fetch-object.h; as the latter takes "struct oid_array",
the former cannot be made into a thin wrapper around the
latter without an extra allocation and set-up cost.
Update fetch_objects() to take an array of "struct object_id"
and number of elements in it as separate parameters, remove
fetch_object(), and adjust all existing callers of these
functions to use the new fetch_objects().
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fetch-object.c')
-rw-r--r-- | fetch-object.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/fetch-object.c b/fetch-object.c index 853624f..1af1bf8 100644 --- a/fetch-object.c +++ b/fetch-object.c @@ -23,21 +23,15 @@ static void fetch_refs(const char *remote_name, struct ref *ref) fetch_if_missing = original_fetch_if_missing; } -void fetch_object(const char *remote_name, const unsigned char *sha1) -{ - struct ref *ref = alloc_ref(sha1_to_hex(sha1)); - hashcpy(ref->old_oid.hash, sha1); - fetch_refs(remote_name, ref); -} - -void fetch_objects(const char *remote_name, const struct oid_array *to_fetch) +void fetch_objects(const char *remote_name, const struct object_id *oids, + int oid_nr) { struct ref *ref = NULL; int i; - for (i = 0; i < to_fetch->nr; i++) { - struct ref *new_ref = alloc_ref(oid_to_hex(&to_fetch->oid[i])); - oidcpy(&new_ref->old_oid, &to_fetch->oid[i]); + for (i = 0; i < oid_nr; i++) { + struct ref *new_ref = alloc_ref(oid_to_hex(&oids[i])); + oidcpy(&new_ref->old_oid, &oids[i]); new_ref->next = ref; ref = new_ref; } |