summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-01-10 15:43:08 +0100
committerVicent Marti <tanoku@gmail.com>2013-01-10 15:43:08 +0100
commit8fe6bc5c47640537a20c351adc5ccaa6a212312b (patch)
treee2f7d925ae509bc1435a2347d795120166127d84
parent891a4681ebba330f9ef33c609c5435e580ca1551 (diff)
downloadlibgit2-8fe6bc5c47640537a20c351adc5ccaa6a212312b.tar.gz
odb: Refresh on `exists` query too
-rw-r--r--src/odb.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/odb.c b/src/odb.c
index a0d30630a..24381e70e 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -529,6 +529,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
git_odb_object *object;
unsigned int i;
bool found = false;
+ bool refreshed = false;
assert(db && id);
@@ -537,6 +538,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
return (int)true;
}
+attempt_lookup:
for (i = 0; i < db->backends.length && !found; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
@@ -545,6 +547,16 @@ int git_odb_exists(git_odb *db, const git_oid *id)
found = b->exists(b, id);
}
+ if (!found && !refreshed) {
+ if (git_odb_refresh(db) < 0) {
+ giterr_clear();
+ return (int)false;
+ }
+
+ refreshed = true;
+ goto attempt_lookup;
+ }
+
return (int)found;
}
@@ -674,7 +686,6 @@ int git_odb_read_prefix(
}
attempt_lookup:
-
for (i = 0; i < db->backends.length; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;