commit - 0f92850ea290f1ce78faa0f9ba874abec8477dea
commit + eaccb85f7218ef3615353170a2a64ec1c48028e2
blob - 6eb1b51ed3c706b530176f8baa1f130982d4e4ce
blob + 5fa0ba16f4cea03fe2779a8bf459fbf903861185
--- lib/got_lib_worktree.h
+++ lib/got_lib_worktree.h
char *root_path;
char *repo_path;
char *path_prefix;
- char *base;
+ struct got_object_id *base_commit_id;
char *head_ref;
/*
blob - 091974e1f03ab5beccb3a5411a64b8b933ba03be
blob + 4656e2e4a0598b526e576e75b85fc270885e00a5
--- lib/worktree.c
+++ lib/worktree.c
char *path_got;
char *formatstr = NULL;
char *path_lock = NULL;
+ char *base_commit_id_str = NULL;
int version, fd = -1;
const char *errstr;
+ struct got_repository *repo = NULL;
*worktree = NULL;
GOT_WORKTREE_REPOSITORY);
if (err)
goto done;
+
err = read_meta_file(&(*worktree)->path_prefix, path_got,
GOT_WORKTREE_PATH_PREFIX);
if (err)
goto done;
- err = read_meta_file(&(*worktree)->base, path_got,
+ err = read_meta_file(&base_commit_id_str, path_got,
GOT_WORKTREE_BASE_COMMIT);
if (err)
goto done;
+ err = got_repo_open(&repo, (*worktree)->repo_path);
+ if (err)
+ goto done;
+
+ err = got_object_resolve_id_str(&(*worktree)->base_commit_id, repo,
+ base_commit_id_str);
+ if (err)
+ goto done;
+
err = read_meta_file(&(*worktree)->head_ref, path_got,
GOT_WORKTREE_HEAD_REF);
if (err)
goto done;
done:
+ if (repo)
+ got_repo_close(repo);
free(path_got);
free(path_lock);
+ free(base_commit_id_str);
if (err) {
if (fd != -1)
close(fd);
free(worktree->root_path);
free(worktree->repo_path);
free(worktree->path_prefix);
- free(worktree->base);
+ free(worktree->base_commit_id);
free(worktree->head_ref);
if (worktree->lockfd != -1)
close(worktree->lockfd);
void *progress_arg, got_worktree_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL, *unlockerr;
- struct got_object_id *commit_id = NULL;
struct got_commit_object *commit = NULL;
struct got_tree_object *tree = NULL;
char *fileindex_path = NULL, *new_fileindex_path = NULL;
if (err)
return err;
- err = got_object_resolve_id_str(&commit_id, repo, worktree->base);
- if (err)
- goto done;
-
fileindex = got_fileindex_alloc();
if (fileindex == NULL) {
err = got_error_from_errno();
if (err)
goto done;
- err = got_object_open_as_commit(&commit, repo, commit_id);
+ err = got_object_open_as_commit(&commit, repo,
+ worktree->base_commit_id);
if (err)
goto done;
got_object_tree_close(tree);
if (commit)
got_object_commit_close(commit);
- free(commit_id);
if (new_fileindex_path)
unlink(new_fileindex_path);
if (new_index)