Commit 891a4681ebba330f9ef33c609c5435e580ca1551

Vicent Marti 2013-01-04T17:42:41

dat errorcode

diff --git a/src/odb.c b/src/odb.c
index d0b2323..a0d3063 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -608,7 +608,7 @@ int git_odb__read_header_or_object(
 int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
 {
 	unsigned int i;
-	int error = GIT_ENOTFOUND;
+	int error;
 	bool refreshed = false;
 	git_rawobj raw;
 
@@ -624,6 +624,7 @@ int git_odb_read(git_odb_object **out, git_odb *db, const git_oid *id)
 		return 0;
 
 attempt_lookup:
+	error = GIT_ENOTFOUND;
 
 	for (i = 0; i < db->backends.length && error < 0; ++i) {
 		backend_internal *internal = git_vector_get(&db->backends, i);
diff --git a/src/odb_pack.c b/src/odb_pack.c
index e1b44d9..9d0c4c0 100644
--- a/src/odb_pack.c
+++ b/src/odb_pack.c
@@ -600,7 +600,12 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
 	}
 
 	if (git_path_isdir(git_buf_cstr(&path)) == true) {
+		int error;
+
 		backend->pack_folder = git_buf_detach(&path);
+		error = pack_backend__refresh((git_odb_backend *)backend);
+		if (error < 0)
+			return error;
 	}
 
 	backend->parent.read = &pack_backend__read;