fetch-object: make functions return an error code
The callers of the fetch_object() and fetch_objects() might be interested in knowing if these functions succeeded or not. 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
2e860675b6572cf476e99888134a5b307fd7eb62
3 files changed
+12
-9
fetch-object.c
+8
-5
@@ -5,11 +5,12 @@
5
#include "transport.h"
6
#include "fetch-object.h"
7
8
-static void fetch_refs(const char *remote_name, struct ref *ref)
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);
@@ -19,12 +20,14 @@ static void fetch_refs(const char *remote_name, struct ref *ref)
20
21
transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
22
transport_set_option(transport, TRANS_OPT_NO_DEPENDENTS, "1");
22
- transport_fetch_refs(transport, ref);
23
+ res = transport_fetch_refs(transport, ref);
24
fetch_if_missing = original_fetch_if_missing;
25
+
26
+ return res;
27
}
28
26
-void fetch_objects(const char *remote_name, const struct object_id *oids,
27
- int oid_nr)
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;
@@ -36,5 +39,5 @@ void fetch_objects(const char *remote_name, const struct object_id *oids,
39
new_ref->next = ref;
40
ref = new_ref;
41
}
39
- fetch_refs(remote_name, ref);
42
+ return fetch_refs(remote_name, ref);
43
}
fetch-object.h
+2
-2
@@ -3,7 +3,7 @@
3
4
struct object_id;
5
6
-void fetch_objects(const char *remote_name, const struct object_id *oids,
7
- int oid_nr);
6
+int fetch_objects(const char *remote_name, const struct object_id *oids,
7
+ int oid_nr);
8
9
#endif
sha1-file.c
+2
-2
@@ -1381,8 +1381,8 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,
1381
!already_retried && r == the_repository &&
1382
!(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
1383
/*
1384
- * TODO Investigate having fetch_object() return
1385
- * TODO error/success and stopping the music here.
1384
+ * TODO Investigate checking fetch_object() return
1385
+ * TODO value and stopping on error here.
1386
* TODO Pass a repository struct through fetch_object,
1387
* such that arbitrary repositories work.
1388
*/