commit - 65a9bbe94592ac5bec831087f9873db4dde02199
commit + 59790a325126d5fa5d7b2a0af2b2db6357d55063
blob - 72fdee411ab19fe805fb6515f5618f4fb8bac2c0
blob + a72d11debea5876add9fbb37115769267317b374
--- lib/object.c
+++ lib/object.c
return NULL;
}
+ err = open_packed_object(obj, id, repo);
+ if (err && err->code != GOT_ERR_NO_OBJ)
+ return err;
+ if (*obj) {
+ (*obj)->refcnt++;
+ return got_repo_cache_object(repo, id, *obj);
+ }
+
err = object_path(&path, id, repo);
if (err)
return err;
fd = open(path, O_RDONLY | O_NOFOLLOW, GOT_DEFAULT_FILE_MODE);
if (fd == -1) {
- if (errno != ENOENT) {
+ if (errno == ENOENT)
+ err = got_error(GOT_ERR_NO_OBJ);
+ else
err = got_error_from_errno();
- goto done;
- }
- err = open_packed_object(obj, id, repo);
- if (err)
- goto done;
- if (*obj == NULL)
- err = got_error(GOT_ERR_NO_OBJ);
+ goto done;
} else {
err = got_object_read_header_privsep(obj, repo, fd);
if (err)
memcpy((*obj)->id.sha1, id->sha1, SHA1_DIGEST_LENGTH);
}
- if (err == NULL) {
- (*obj)->refcnt++;
- err = got_repo_cache_object(repo, id, *obj);
- }
+ (*obj)->refcnt++;
+ err = got_repo_cache_object(repo, id, *obj);
done:
free(path);
if (fd != -1)