commit - 7472ca4ef5ea6faebee012ddfbffd20fa9efddfb
commit + 945f922947fbf90d4ae30e870a0d0262cf12bea8
blob - 277ccda9527fb4d2a732cdb084aa26a0db44e611
blob + 6629cdc24c5c18fdad568f4d00ff57c91a49268a
--- got/got.c
+++ got/got.c
if (path && path[0] != '\0') {
int obj_type;
- err = got_object_id_by_path(&obj_id2, repo, id, path);
+ err = got_object_id_by_path(&obj_id2, repo, commit, path);
if (err)
goto done;
err = got_object_id_str(&id_str2, obj_id2);
}
if (pcommit) {
err = got_object_id_by_path(&obj_id1, repo,
- qid->id, path);
+ pcommit, path);
if (err) {
if (err->code != GOT_ERR_NO_TREE_ENTRY) {
free(obj_id2);
char *link_target = NULL;
struct got_object_id *obj_id = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
struct got_blob_object *blob = NULL;
char *commit_id_str = NULL;
struct blame_cb_args bca;
worktree = NULL;
}
+ error = got_object_open_as_commit(&commit, repo, commit_id);
+ if (error)
+ goto done;
+
error = got_object_resolve_symlinks(&link_target, in_repo_path,
- commit_id, repo);
+ commit, repo);
if (error)
goto done;
- error = got_object_id_by_path(&obj_id, repo, commit_id,
+ error = got_object_id_by_path(&obj_id, repo, commit,
link_target ? link_target : in_repo_path);
if (error)
goto done;
free(cwd);
free(commit_id);
free(obj_id);
+ if (commit)
+ got_object_commit_close(commit);
if (blob)
got_object_blob_close(blob);
if (worktree)
}
static const struct got_error *
-print_tree(const char *path, struct got_object_id *commit_id,
+print_tree(const char *path, struct got_commit_object *commit,
int show_ids, int recurse, const char *root_path,
struct got_repository *repo)
{
struct got_tree_object *tree = NULL;
int nentries, i;
- err = got_object_id_by_path(&tree_id, repo, commit_id, path);
+ err = got_object_id_by_path(&tree_id, repo, commit, path);
if (err)
goto done;
err = got_error_from_errno("asprintf");
goto done;
}
- err = print_tree(child_path, commit_id, show_ids, 1,
+ err = print_tree(child_path, commit, show_ids, 1,
root_path, repo);
free(child_path);
if (err)
const char *path, *refname = NULL;
char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
char *commit_id_str = NULL;
int show_ids = 0, recurse = 0;
int ch;
worktree = NULL;
}
- error = print_tree(in_repo_path, commit_id, show_ids, recurse,
+ error = got_object_open_as_commit(&commit, repo, commit_id);
+ if (error)
+ goto done;
+
+ error = print_tree(in_repo_path, commit, show_ids, recurse,
in_repo_path, repo);
done:
free(in_repo_path);
free(repo_path);
free(cwd);
free(commit_id);
+ if (commit)
+ got_object_commit_close(commit);
if (worktree)
got_worktree_close(worktree);
if (repo) {
char *cwd = NULL, *repo_path = NULL, *label = NULL;
const char *commit_id_str = NULL;
struct got_object_id *id = NULL, *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
int ch, obj_type, i, force_path = 0;
struct got_reflist_head refs;
if (error)
goto done;
+ error = got_object_open_as_commit(&commit, repo, commit_id);
+ if (error)
+ goto done;
+
for (i = 0; i < argc; i++) {
if (force_path) {
- error = got_object_id_by_path(&id, repo, commit_id,
+ error = got_object_id_by_path(&id, repo, commit,
argv[i]);
if (error)
break;
error->code != GOT_ERR_NOT_REF)
break;
error = got_object_id_by_path(&id, repo,
- commit_id, argv[i]);
+ commit, argv[i]);
if (error)
break;
}
free(label);
free(id);
free(commit_id);
+ if (commit)
+ got_object_commit_close(commit);
if (worktree)
got_worktree_close(worktree);
if (repo) {
blob - bfcd04d64d489c45ea49ad7534c2e7289ee38820
blob + 12227984c432e81f5a1b01973031aec64920a2f6
--- gotweb/gotweb.c
+++ gotweb/gotweb.c
const struct got_error *error = NULL;
struct got_object_id *obj_id = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
struct got_blob_object *blob = NULL;
char *path = NULL, *in_repo_path = NULL;
struct gw_blame_cb_args bca;
if (error)
goto done;
- error = got_object_id_by_path(&obj_id, gw_trans->repo, commit_id,
+ error = got_object_open_as_commit(&commit, gw_trans->repo, commit_id);
+ if (error)
+ goto done;
+
+ error = got_object_id_by_path(&obj_id, gw_trans->repo, commit,
in_repo_path);
if (error)
goto done;
}
if (blob)
got_object_blob_close(blob);
+ if (commit)
+ got_object_commit_close(commit);
return error;
}
const struct got_error *error = NULL;
struct got_object_id *obj_id = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
struct got_blob_object *blob = NULL;
char *path = NULL, *in_repo_path = NULL;
int obj_type, set_mime = 0;
if (error)
goto done;
- error = got_object_id_by_path(&obj_id, gw_trans->repo, commit_id,
+ error = got_object_open_as_commit(&commit, gw_trans->repo, commit_id);
+ if (error)
+ goto done;
+
+ error = got_object_id_by_path(&obj_id, gw_trans->repo, commit,
in_repo_path);
if (error)
goto done;
free(path);
if (blob)
got_object_blob_close(blob);
+ if (commit)
+ got_object_commit_close(commit);
if (error == NULL && kerr != KCGI_OK)
error = gw_kcgi_error(kerr);
return error;
const struct got_error *error = NULL;
struct got_object_id *tree_id = NULL, *commit_id = NULL;
struct got_tree_object *tree = NULL;
+ struct got_commit_object *commit = NULL;
char *path = NULL, *in_repo_path = NULL;
char *id_str = NULL;
char *build_folder = NULL;
goto done;
}
- error = got_object_id_by_path(&tree_id, gw_trans->repo, commit_id,
+ error = got_object_open_as_commit(&commit, gw_trans->repo, commit_id);
+ if (error)
+ goto done;
+
+ error = got_object_id_by_path(&tree_id, gw_trans->repo, commit,
path);
if (error)
goto done;
done:
if (tree)
got_object_tree_close(tree);
+ if (commit)
+ got_object_commit_close(commit);
free(id_str);
free(href_blob);
free(href_blame);
blob - 592e77655be88e831265856057c0f2f4d253128e
blob + 9d6f362ad6242f2fdff94792bc113ede1710807d
--- include/got_object.h
+++ include/got_object.h
* The caller should dispose of it with free(3).
*/
const struct got_error *got_object_id_by_path(struct got_object_id **,
- struct got_repository *, struct got_object_id *, const char *);
+ struct got_repository *, struct got_commit_object *, const char *);
/*
* Obtain the type of an object.
* target path. The caller must dispose of it with free(3).
*/
const struct got_error *got_object_resolve_symlinks(char **, const char *,
- struct got_object_id *, struct got_repository *);
+ struct got_commit_object *, struct got_repository *);
/*
* Compare two trees and indicate whether the entry at the specified path
blob - 311713a52724ce5002435a63acf53baaf1a6e61f
blob + 34906057730bd12ea25ac3bb7f300ed8cac6ce46
--- lib/blame.c
+++ lib/blame.c
void *arg)
{
const struct got_error *err = NULL;
- struct got_commit_object *commit = NULL;
+ struct got_commit_object *commit = NULL, *pcommit = NULL;
struct got_object_qid *pid = NULL;
struct got_object_id *pblob_id = NULL;
struct got_blob_object *pblob = NULL;
return NULL;
}
- err = got_object_id_by_path(&pblob_id, repo, pid->id, path);
+ err = got_object_open_as_commit(&pcommit, repo, pid->id);
+ if (err)
+ goto done;
+
+ err = got_object_id_by_path(&pblob_id, repo, pcommit, path);
if (err) {
if (err->code == GOT_ERR_NO_TREE_ENTRY)
err = NULL;
diff_result_free(diff_result);
if (commit)
got_object_commit_close(commit);
+ if (pcommit)
+ got_object_commit_close(pcommit);
free(pblob_id);
if (pblob)
got_object_blob_close(pblob);
void *arg, got_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
+ struct got_commit_object *start_commit = NULL;
struct got_object_id *obj_id = NULL;
struct got_blob_object *blob = NULL;
struct got_blame *blame = NULL;
*blamep = NULL;
- err = got_object_id_by_path(&obj_id, repo, start_commit_id, path);
+ err = got_object_open_as_commit(&start_commit, repo, start_commit_id);
if (err)
goto done;
+ err = got_object_id_by_path(&obj_id, repo, start_commit, path);
+ if (err)
+ goto done;
+
err = got_object_open_as_blob(&blob, repo, obj_id, 8192);
if (err)
goto done;
free(obj_id);
if (blob)
got_object_blob_close(blob);
+ if (start_commit)
+ got_object_commit_close(start_commit);
if (err) {
if (blame)
blame_close(blame);
blob - e87849acb495b5499e6729f3d7fc1a01e4e11663
blob + 54a084ad975a8926ebfd7457ee7b7c3d144c9a8e
--- lib/commit_graph.c
+++ lib/commit_graph.c
pid = STAILQ_FIRST(&commit->parent_ids);
if (pid == NULL) {
struct got_object_id *obj_id;
- err = got_object_id_by_path(&obj_id, repo, commit_id, path);
+ err = got_object_id_by_path(&obj_id, repo, commit, path);
if (err) {
if (err->code == GOT_ERR_NO_TREE_ENTRY)
err = NULL;
struct got_object_id *merged_id, *prev_id = NULL;
int branches_differ = 0;
- err = got_object_id_by_path(&merged_id, repo, commit_id,
+ err = got_object_id_by_path(&merged_id, repo, commit,
graph->path);
if (err)
return err;
STAILQ_FOREACH(qid, &commit->parent_ids, entry) {
- struct got_object_id *id;
+ struct got_object_id *id = NULL;
+ struct got_commit_object *pcommit = NULL;
if (got_object_idset_contains(graph->open_branches,
qid->id))
continue;
- err = got_object_id_by_path(&id, repo, qid->id,
+ err = got_object_open_as_commit(&pcommit, repo,
+ qid->id);
+ if (err) {
+ free(merged_id);
+ free(prev_id);
+ return err;
+ }
+ err = got_object_id_by_path(&id, repo, pcommit,
graph->path);
+ got_object_commit_close(pcommit);
+ pcommit = NULL;
if (err) {
if (err->code == GOT_ERR_NO_TREE_ENTRY) {
branches_differ = 1;
blob - 0d464f18b808fdf0b1f3e6807a54114f16b022c6
blob + ca30358a6647e506d86ee837489f03246816cf1d
--- lib/object.c
+++ lib/object.c
}
const struct got_error *
got_object_id_by_path(struct got_object_id **id, struct got_repository *repo,
- struct got_object_id *commit_id, const char *path)
+ struct got_commit_object *commit, const char *path)
{
const struct got_error *err = NULL;
- struct got_commit_object *commit = NULL;
struct got_tree_object *tree = NULL;
*id = NULL;
- err = got_object_open_as_commit(&commit, repo, commit_id);
- if (err)
- goto done;
-
/* Handle opening of root of commit's tree. */
if (got_path_is_root_dir(path)) {
*id = got_object_id_dup(commit->tree_id);
err = got_object_tree_find_path(id, NULL, repo, tree, path);
}
done:
- if (commit)
- got_object_commit_close(commit);
if (tree)
got_object_tree_close(tree);
return err;
static const struct got_error *
resolve_symlink(char **link_target, const char *path,
- struct got_object_id *commit_id, struct got_repository *repo)
+ struct got_commit_object *commit, struct got_repository *repo)
{
const struct got_error *err = NULL;
char buf[PATH_MAX];
if (err)
return err;
- err = got_object_id_by_path(&tree_obj_id, repo, commit_id,
+ err = got_object_id_by_path(&tree_obj_id, repo, commit,
parent_path);
if (err) {
if (err->code == GOT_ERR_NO_TREE_ENTRY) {
const struct got_error *
got_object_resolve_symlinks(char **link_target, const char *path,
- struct got_object_id *commit_id, struct got_repository *repo)
+ struct got_commit_object *commit, struct got_repository *repo)
{
const struct got_error *err = NULL;
char *next_target = NULL;
do {
err = resolve_symlink(&next_target,
- *link_target ? *link_target : path, commit_id, repo);
+ *link_target ? *link_target : path, commit, repo);
if (err)
break;
if (next_target) {
blob - fbc8176eda96fecd3f552c89525ab6888296aa61
blob + 93bbd9e32f688c5cce6af6698e4027b2e7e4e875
--- lib/worktree.c
+++ lib/worktree.c
static const struct got_error *
find_tree_entry_for_checkout(int *entry_type, char **tree_relpath,
struct got_object_id **tree_id, const char *wt_relpath,
- struct got_worktree *worktree, struct got_repository *repo)
+ struct got_commit_object *base_commit, struct got_worktree *worktree,
+ struct got_repository *repo)
{
const struct got_error *err = NULL;
struct got_object_id *id = NULL;
err = got_error_from_errno("strdup");
goto done;
}
- err = got_object_id_by_path(tree_id, repo,
- worktree->base_commit_id, worktree->path_prefix);
+ err = got_object_id_by_path(tree_id, repo, base_commit,
+ worktree->path_prefix);
if (err)
goto done;
return NULL;
goto done;
}
- err = got_object_id_by_path(&id, repo, worktree->base_commit_id,
- in_repo_path);
+ err = got_object_id_by_path(&id, repo, base_commit, in_repo_path);
if (err)
goto done;
}
}
err = got_object_id_by_path(tree_id, repo,
- worktree->base_commit_id, in_repo_path);
+ base_commit, in_repo_path);
} else {
/* Check out all files within a subdirectory. */
*tree_id = got_object_id_dup(id);
err = lock_worktree(worktree, LOCK_EX);
if (err)
return err;
+
+ err = got_object_open_as_commit(&commit, repo,
+ worktree->base_commit_id);
+ if (err)
+ goto done;
/* Map all specified paths to in-repository trees. */
TAILQ_FOREACH(pe, paths, entry) {
}
err = find_tree_entry_for_checkout(&tpd->entry_type,
- &tpd->relpath, &tpd->tree_id, pe->path, worktree, repo);
+ &tpd->relpath, &tpd->tree_id, pe->path, commit,
+ worktree, repo);
if (err) {
free(tpd);
goto done;
const struct got_error *err = NULL, *sync_err;
struct got_object_id *tree_id1 = NULL, *tree_id2 = NULL;
struct got_tree_object *tree1 = NULL, *tree2 = NULL;
+ struct got_commit_object *commit1 = NULL, *commit2 = NULL;
struct check_merge_conflicts_arg cmc_arg;
struct merge_file_cb_arg arg;
char *label_orig = NULL;
if (commit_id1) {
- err = got_object_id_by_path(&tree_id1, repo, commit_id1,
+ err = got_object_open_as_commit(&commit1, repo, commit_id1);
+ if (err)
+ goto done;
+ err = got_object_id_by_path(&tree_id1, repo, commit1,
worktree->path_prefix);
if (err && err->code != GOT_ERR_NO_TREE_ENTRY)
goto done;
free(id_str);
}
- err = got_object_id_by_path(&tree_id2, repo, commit_id2,
+ err = got_object_open_as_commit(&commit2, repo, commit_id2);
+ if (err)
+ goto done;
+
+ err = got_object_id_by_path(&tree_id2, repo, commit2,
worktree->path_prefix);
if (err)
goto done;
if (sync_err && err == NULL)
err = sync_err;
done:
+ if (commit1)
+ got_object_commit_close(commit1);
+ if (commit2)
+ got_object_commit_close(commit2);
if (tree1)
got_object_tree_close(tree1);
if (tree2)
const struct got_error *err = NULL;
char *parent_path = NULL;
struct got_fileindex_entry *ie;
+ struct got_commit_object *base_commit = NULL;
struct got_tree_object *tree = NULL;
struct got_object_id *tree_id = NULL;
const struct got_tree_entry *te = NULL;
}
}
- err = got_object_id_by_path(&tree_id, a->repo,
- a->worktree->base_commit_id, tree_path);
+ err = got_object_open_as_commit(&base_commit, a->repo,
+ a->worktree->base_commit_id);
+ if (err)
+ goto done;
+
+ err = got_object_id_by_path(&tree_id, a->repo, base_commit, tree_path);
if (err) {
if (!(err->code == GOT_ERR_NO_TREE_ENTRY &&
(status == GOT_STATUS_ADD ||
if (tree)
got_object_tree_close(tree);
free(tree_id);
+ if (base_commit)
+ got_object_commit_close(base_commit);
return err;
}
int ood_errcode)
{
const struct got_error *err = NULL;
+ struct got_commit_object *commit = NULL;
struct got_object_id *id = NULL;
if (status != GOT_STATUS_ADD && staged_status != GOT_STATUS_ADD) {
* Ensure file content which local changes were based
* on matches file content in the branch head.
*/
- err = got_object_id_by_path(&id, repo, head_commit_id,
- in_repo_path);
+ err = got_object_open_as_commit(&commit, repo, head_commit_id);
+ if (err)
+ goto done;
+ err = got_object_id_by_path(&id, repo, commit, in_repo_path);
if (err) {
if (err->code == GOT_ERR_NO_TREE_ENTRY)
err = got_error(ood_errcode);
err = got_error(ood_errcode);
} else {
/* Require that added files don't exist in the branch head. */
- err = got_object_id_by_path(&id, repo, head_commit_id,
- in_repo_path);
+ err = got_object_open_as_commit(&commit, repo, head_commit_id);
+ if (err)
+ goto done;
+ err = got_object_id_by_path(&id, repo, commit, in_repo_path);
if (err && err->code != GOT_ERR_NO_TREE_ENTRY)
goto done;
err = id ? got_error(ood_errcode) : NULL;
}
done:
free(id);
+ if (commit)
+ got_object_commit_close(commit);
return err;
}
const struct got_error *err, *unlockerr, *sync_err;
struct got_reference *resolved = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
char *fileindex_path = NULL;
struct revert_file_args rfa;
struct got_object_id *tree_id = NULL;
if (err)
return err;
+ err = got_object_open_as_commit(&commit, repo,
+ worktree->base_commit_id);
+ if (err)
+ goto done;
+
err = got_ref_open(&resolved, repo,
got_ref_get_symref_target(new_base_branch), 0);
if (err)
if (err)
goto done;
- err = got_object_id_by_path(&tree_id, repo,
- worktree->base_commit_id, worktree->path_prefix);
+ err = got_object_id_by_path(&tree_id, repo, commit,
+ worktree->path_prefix);
if (err)
goto done;
got_ref_close(resolved);
free(tree_id);
free(commit_id);
+ if (commit)
+ got_object_commit_close(commit);
if (fileindex)
got_fileindex_free(fileindex);
free(fileindex_path);
const struct got_error *err, *unlockerr, *sync_err;
struct got_reference *resolved = NULL;
char *fileindex_path = NULL;
+ struct got_commit_object *commit = NULL;
struct got_object_id *tree_id = NULL;
struct revert_file_args rfa;
if (err)
return err;
+ err = got_object_open_as_commit(&commit, repo,
+ worktree->base_commit_id);
+ if (err)
+ goto done;
+
err = got_ref_open(&resolved, repo,
got_ref_get_symref_target(branch), 0);
if (err)
if (err)
goto done;
- err = got_object_id_by_path(&tree_id, repo, base_commit_id,
+ err = got_object_id_by_path(&tree_id, repo, commit,
worktree->path_prefix);
if (err)
goto done;
const struct got_error *err = NULL, *sync_err, *unlockerr;
char *fileindex_path = NULL;
struct got_object_id *tree_id = NULL, *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
err = get_fileindex_path(&fileindex_path, worktree);
if (err)
if (err)
goto done;
- err = got_object_id_by_path(&tree_id, repo, commit_id,
+ err = got_object_open_as_commit(&commit, repo, commit_id);
+ if (err)
+ goto done;
+
+ err = got_object_id_by_path(&tree_id, repo, commit,
worktree->path_prefix);
if (err)
goto done;
got_fileindex_free(fileindex);
free(fileindex_path);
free(tree_id);
+ if (commit)
+ got_object_commit_close(commit);
unlockerr = lock_worktree(worktree, LOCK_SH);
if (unlockerr && err == NULL)
{
const struct got_error *err, *unlockerr, *sync_err;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
char *fileindex_path = NULL;
struct revert_file_args rfa;
struct got_object_id *tree_id = NULL;
- err = got_object_id_by_path(&tree_id, repo,
- worktree->base_commit_id, worktree->path_prefix);
+ err = got_object_open_as_commit(&commit, repo,
+ worktree->base_commit_id);
+ if (err)
+ goto done;
+
+ err = got_object_id_by_path(&tree_id, repo, commit,
+ worktree->path_prefix);
if (err)
goto done;
done:
free(tree_id);
free(commit_id);
+ if (commit)
+ got_object_commit_close(commit);
if (fileindex)
got_fileindex_free(fileindex);
free(fileindex_path);
blob - 27730ae459b928b0915680bfbb23bad789387ecd
blob + 0c1f8bdddecfa08d332b9877c8b557307fcb4770
--- tog/tog.c
+++ tog/tog.c
static const struct got_error *
tree_view_walk_path(struct tog_tree_view_state *s,
- struct got_object_id *commit_id, const char *path)
+ struct got_commit_object *commit, const char *path)
{
const struct got_error *err = NULL;
struct got_tree_object *tree = NULL;
break;
}
- err = got_object_id_by_path(&tree_id, s->repo, commit_id,
+ err = got_object_id_by_path(&tree_id, s->repo, commit,
subpath);
if (err)
break;
if (got_path_is_root_dir(path))
return NULL;
- return tree_view_walk_path(s, entry->id, path);
+ return tree_view_walk_path(s, entry->commit, path);
}
static const struct got_error *
struct tog_blame_view_state *s = &view->state.blame;
struct tog_blame *blame = &s->blame;
const struct got_error *err = NULL;
+ struct got_commit_object *commit = NULL;
struct got_blob_object *blob = NULL;
struct got_repository *thread_repo = NULL;
struct got_object_id *obj_id = NULL;
int obj_type;
- err = got_object_id_by_path(&obj_id, s->repo, s->blamed_commit->id,
- s->path);
+ err = got_object_open_as_commit(&commit, s->repo,
+ s->blamed_commit->id);
if (err)
return err;
+
+ err = got_object_id_by_path(&obj_id, s->repo, commit, s->path);
+ if (err)
+ goto done;
err = got_object_get_type(&obj_type, s->repo, obj_id);
if (err)
s->matched_line = 0;
done:
+ if (commit)
+ got_object_commit_close(commit);
if (blob)
got_object_blob_close(blob);
free(obj_id);
if (id == NULL)
break;
if (ch == 'p') {
- struct got_commit_object *commit;
+ struct got_commit_object *commit, *pcommit;
struct got_object_qid *pid;
struct got_object_id *blob_id = NULL;
int obj_type;
break;
}
/* Check if path history ends here. */
+ err = got_object_open_as_commit(&pcommit,
+ s->repo, pid->id);
+ if (err)
+ break;
err = got_object_id_by_path(&blob_id, s->repo,
- pid->id, s->path);
+ pcommit, s->path);
+ got_object_commit_close(pcommit);
if (err) {
if (err->code == GOT_ERR_NO_TREE_ENTRY)
err = NULL;
char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL;
char *link_target = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
char *commit_id_str = NULL;
int ch;
struct tog_view *view;
goto done;
}
+ error = got_object_open_as_commit(&commit, repo, commit_id);
+ if (error)
+ goto done;
+
error = got_object_resolve_symlinks(&link_target, in_repo_path,
- commit_id, repo);
+ commit, repo);
if (error)
goto done;
free(link_target);
free(cwd);
free(commit_id);
+ if (commit)
+ got_object_commit_close(commit);
if (worktree)
got_worktree_close(worktree);
if (repo) {
struct got_worktree *worktree = NULL;
char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL;
struct got_object_id *commit_id = NULL;
+ struct got_commit_object *commit = NULL;
const char *commit_id_arg = NULL;
char *label = NULL;
struct got_reference *ref = NULL;
goto done;
}
+ error = got_object_open_as_commit(&commit, repo, commit_id);
+ if (error)
+ goto done;
+
view = view_open(0, 0, 0, 0, TOG_VIEW_TREE);
if (view == NULL) {
error = got_error_from_errno("view_open");
if (error)
goto done;
if (!got_path_is_root_dir(in_repo_path)) {
- error = tree_view_walk_path(&view->state.tree, commit_id,
+ error = tree_view_walk_path(&view->state.tree, commit,
in_repo_path);
if (error)
goto done;
struct got_repository *repo = NULL;
struct got_worktree *worktree = NULL;
struct got_object_id *commit_id = NULL, *id = NULL;
+ struct got_commit_object *commit = NULL;
char *cwd = NULL, *repo_path = NULL, *in_repo_path = NULL;
char *commit_id_str = NULL, **cmd_argv = NULL;
worktree = NULL;
}
- error = got_object_id_by_path(&id, repo, commit_id, in_repo_path);
+ error = got_object_open_as_commit(&commit, repo, commit_id);
+ if (error)
+ goto done;
+
+ error = got_object_id_by_path(&id, repo, commit, in_repo_path);
if (error) {
if (error->code != GOT_ERR_NO_TREE_ENTRY)
goto done;
if (error == NULL)
error = close_err;
}
+ if (commit)
+ got_object_commit_close(commit);
if (worktree)
got_worktree_close(worktree);
free(id);