summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-10-15 22:33:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-16 17:10:35 (GMT)
commitfe1b22686f26bed3047294cc4552e50ce58fa954 (patch)
tree76003cce3bc3e009618e1ff1956924a1c1e52562 /sha1_file.c
parenta136f6d8ff290ab486c85cd12d1a9a47d53b432d (diff)
downloadgit-fe1b22686f26bed3047294cc4552e50ce58fa954.zip
git-fe1b22686f26bed3047294cc4552e50ce58fa954.tar.gz
git-fe1b22686f26bed3047294cc4552e50ce58fa954.tar.bz2
foreach_alt_odb: propagate return value from callback
We check the return value of the callback and stop iterating if it is non-zero. However, we do not make the non-zero return value available to the caller, so they have no way of knowing whether the operation succeeded or not (technically they can keep their own error flag in the callback data, but that is unlike our other for_each functions). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 6f18c22..aaa3c52 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -412,14 +412,18 @@ void add_to_alternates_file(const char *reference)
link_alt_odb_entries(alt, strlen(alt), '\n', NULL, 0);
}
-void foreach_alt_odb(alt_odb_fn fn, void *cb)
+int foreach_alt_odb(alt_odb_fn fn, void *cb)
{
struct alternate_object_database *ent;
+ int r = 0;
prepare_alt_odb();
- for (ent = alt_odb_list; ent; ent = ent->next)
- if (fn(ent, cb))
- return;
+ for (ent = alt_odb_list; ent; ent = ent->next) {
+ r = fn(ent, cb);
+ if (r)
+ break;
+ }
+ return r;
}
void prepare_alt_odb(void)