commit - 31b4484f27afc8ceaf636ad8c97d8a9aa119693e
commit + e82b1d8119d413101f11883e43119759a433edc4
blob - da29a068a7af497d7562f8b2baa800ae4def94a6
blob + 60a273ea713af45d42943ac3274ba6081c775576
--- lib/object.c
+++ lib/object.c
return err;
*fd = open(path, O_RDONLY | O_NOFOLLOW);
if (*fd == -1) {
- if (errno == ENOENT)
- err = got_error_no_obj(id);
- else
- err = got_error_from_errno2("open", path);
+ err = got_error_from_errno2("open", path);
goto done;
}
done:
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 = got_object_get_path(&path, id, repo);
if (err)
return err;
fd = open(path, O_RDONLY | O_NOFOLLOW);
if (fd == -1) {
- if (errno != ENOENT) {
+ if (errno == ENOENT)
+ err = got_error_no_obj(id);
+ else
err = got_error_from_errno2("open", path);
- goto done;
- }
- err = open_packed_object(obj, id, repo);
+ goto done;
} else {
err = read_object_header_privsep(obj, repo, fd);
if (err)
{
const struct got_error *err = NULL;
struct got_packidx *packidx = NULL;
- int idx, fd;
+ int idx;
char *path_packfile;
if (check_cache) {
} else
*commit = NULL;
- err = open_loose_object(&fd, id, repo);
- if (err) {
+ err = got_repo_search_packidx(&packidx, &idx, repo, id);
+ if (err == NULL) {
struct got_pack *pack = NULL;
- if (err->code != GOT_ERR_NO_OBJ)
- return err;
-
- err = got_repo_search_packidx(&packidx, &idx, repo, id);
- if (err)
- return err;
-
err = get_packfile_path(&path_packfile, packidx);
if (err)
return err;
}
err = read_packed_commit_privsep(commit, pack,
packidx, idx, id);
- } else
+ } else if (err->code == GOT_ERR_NO_OBJ) {
+ int fd;
+
+ err = open_loose_object(&fd, id, repo);
+ if (err)
+ return err;
err = read_commit_privsep(commit, fd, repo);
+ }
if (err == NULL) {
(*commit)->refcnt++;
{
const struct got_error *err = NULL;
struct got_packidx *packidx = NULL;
- int fd, idx;
+ int idx;
char *path_packfile;
if (check_cache) {
} else
*tree = NULL;
- err = open_loose_object(&fd, id, repo);
- if (err) {
+ err = got_repo_search_packidx(&packidx, &idx, repo, id);
+ if (err == NULL) {
struct got_pack *pack = NULL;
- if (err->code != GOT_ERR_NO_OBJ)
- return err;
-
- err = got_repo_search_packidx(&packidx, &idx, repo, id);
- if (err)
- return err;
-
err = get_packfile_path(&path_packfile, packidx);
if (err)
return err;
pack = got_repo_get_cached_pack(repo, path_packfile);
if (pack == NULL) {
- err = got_repo_cache_pack(&pack, repo,
- path_packfile, packidx);
+ err = got_repo_cache_pack(&pack, repo, path_packfile,
+ packidx);
if (err)
return err;
}
err = read_packed_tree_privsep(tree, pack,
packidx, idx, id);
- } else
+ } else if (err->code == GOT_ERR_NO_OBJ) {
+ int fd;
+
+ err = open_loose_object(&fd, id, repo);
+ if (err)
+ return err;
err = read_tree_privsep(tree, fd, repo);
+ }
if (err == NULL) {
(*tree)->refcnt++;
int idx;
char *path_packfile;
uint8_t *outbuf;
- int infd, outfd;
+ int outfd;
size_t size, hdrlen;
struct stat sb;
goto done;
}
- err = open_loose_object(&infd, id, repo);
- if (err) {
+ err = got_repo_search_packidx(&packidx, &idx, repo, id);
+ if (err == NULL) {
struct got_pack *pack = NULL;
-
- if (err->code != GOT_ERR_NO_OBJ)
- goto done;
- err = got_repo_search_packidx(&packidx, &idx, repo, id);
- if (err)
- goto done;
-
err = get_packfile_path(&path_packfile, packidx);
if (err)
goto done;
}
err = read_packed_blob_privsep(&outbuf, &size, &hdrlen, outfd,
pack, packidx, idx, id);
- } else
+ } else if (err->code == GOT_ERR_NO_OBJ) {
+ int infd;
+
+ err = open_loose_object(&infd, id, repo);
+ if (err)
+ goto done;
err = read_blob_privsep(&outbuf, &size, &hdrlen, outfd, infd,
repo);
+ }
if (err)
goto done;
{
const struct got_error *err = NULL;
struct got_packidx *packidx = NULL;
- int fd, idx;
+ int idx;
char *path_packfile;
if (check_cache) {
} else
*tag = NULL;
- err = open_loose_object(&fd, id, repo);
- if (err) {
+ err = got_repo_search_packidx(&packidx, &idx, repo, id);
+ if (err == NULL) {
struct got_pack *pack = NULL;
- if (err->code != GOT_ERR_NO_OBJ)
- return err;
-
- err = got_repo_search_packidx(&packidx, &idx, repo, id);
- if (err)
- return err;
-
err = get_packfile_path(&path_packfile, packidx);
if (err)
return err;
pack = got_repo_get_cached_pack(repo, path_packfile);
if (pack == NULL) {
- err = got_repo_cache_pack(&pack, repo,
- path_packfile, packidx);
+ err = got_repo_cache_pack(&pack, repo, path_packfile,
+ packidx);
if (err)
return err;
}
- err = read_packed_tag_privsep(tag, pack, packidx, idx, id);
- } else
+ err = read_packed_tag_privsep(tag, pack,
+ packidx, idx, id);
+ } else if (err->code == GOT_ERR_NO_OBJ) {
+ int fd;
+
+ err = open_loose_object(&fd, id, repo);
+ if (err)
+ return err;
err = read_tag_privsep(tag, fd, repo);
+ }
if (err == NULL) {
(*tag)->refcnt++;
err = got_repo_cache_tag(repo, id, *tag);
}
+
return err;
}