Skip to content

Commit c743a1b

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f629333 commit c743a1b

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

fetch-object.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
#include "transport.h"
66
#include "fetch-object.h"
77

8-
static void fetch_refs(const char *remote_name, struct ref *ref)
8+
static int fetch_refs(const char *remote_name, struct ref *ref)
99
{
1010
struct remote *remote;
1111
struct transport *transport;
1212
int original_fetch_if_missing = fetch_if_missing;
13+
int res;
1314

1415
fetch_if_missing = 0;
1516
remote = remote_get(remote_name);
@@ -19,12 +20,14 @@ static void fetch_refs(const char *remote_name, struct ref *ref)
1920

2021
transport_set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
2122
transport_set_option(transport, TRANS_OPT_NO_DEPENDENTS, "1");
22-
transport_fetch_refs(transport, ref);
23+
res = transport_fetch_refs(transport, ref);
2324
fetch_if_missing = original_fetch_if_missing;
25+
26+
return res;
2427
}
2528

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)
2831
{
2932
struct ref *ref = NULL;
3033
int i;
@@ -36,5 +39,5 @@ void fetch_objects(const char *remote_name, const struct object_id *oids,
3639
new_ref->next = ref;
3740
ref = new_ref;
3841
}
39-
fetch_refs(remote_name, ref);
42+
return fetch_refs(remote_name, ref);
4043
}

fetch-object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
struct object_id;
55

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);
88

99
#endif

sha1-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,8 +1373,8 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,
13731373
!already_retried && r == the_repository &&
13741374
!(flags & OBJECT_INFO_FOR_PREFETCH)) {
13751375
/*
1376-
* TODO Investigate having fetch_object() return
1377-
* TODO error/success and stopping the music here.
1376+
* TODO Investigate checking fetch_object() return
1377+
* TODO value and stopping on error here.
13781378
* TODO Pass a repository struct through fetch_object,
13791379
* such that arbitrary repositories work.
13801380
*/

0 commit comments

Comments
 (0)