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