commit - b2df341bd0e5b6145674f4e7edb341352c3baddc
commit + 83c8b3b81dddacaeb4db8081fdcfd68c514f4276
blob - 9211257edffc6c044b811ae3a636cf3be929909c
blob + 4bb4b6a375cb9ca3b1be8695a35b8dc74bda43c3
--- lib/repository.c
+++ lib/repository.c
if (len >= 2) {
err = match_packed_object(id, repo, id_str_prefix);
if (err)
- return err;
+ goto done;
object_dir = strndup(id_str_prefix, 2);
- if (object_dir == NULL)
- return got_error_from_errno("strdup");
+ if (object_dir == NULL) {
+ err = got_error_from_errno("strdup");
+ goto done;
+ }
err = match_loose_object(id, path_objects, object_dir,
id_str_prefix, repo);
} else if (len == 1) {
int i;
for (i = 0; i < 0xf; i++) {
if (asprintf(&object_dir, "%s%.1x", id_str_prefix, i)
- == -1)
- return got_error_from_errno("asprintf");
+ == -1) {
+ err = got_error_from_errno("asprintf");
+ goto done;
+ }
err = match_packed_object(id, repo, object_dir);
if (err)
- return err;
+ goto done;
err = match_loose_object(id, path_objects, object_dir,
id_str_prefix, repo);
if (err)
- break;
+ goto done;
}
- } else
- return got_error(GOT_ERR_BAD_OBJ_ID_STR);
-
+ } else {
+ err = got_error(GOT_ERR_BAD_OBJ_ID_STR);
+ goto done;
+ }
+done:
free(object_dir);
if (err) {
free(*id);