commit - f0559eb5490cba70e142360c71d5ab1863eab10e
commit + cffc0aa45ba6718abca889b1e53198b6e9faea8c
blob - b4eef2f832a548ecc2f563f7ce8b2bf13d0eddcb
blob + 9363f9a78c59dc1c3863a5a0450aeba950e71e2b
--- got/got.c
+++ got/got.c
{
const struct got_error *error;
struct got_repository *repo = NULL;
+ struct got_worktree *worktree = NULL;
struct got_commit_object *commit = NULL;
struct got_object_id *id = NULL;
char *repo_path = NULL, *path = NULL, *cwd = NULL, *in_repo_path = NULL;
error = got_error_from_errno();
goto done;
}
+
+ error = got_worktree_open(&worktree, cwd);
+ if (error && error->code != GOT_ERR_NOT_WORKTREE)
+ goto done;
+ error = NULL;
+
+ repo_path = worktree ?
+ strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd);
if (repo_path == NULL) {
- repo_path = strdup(cwd);
- if (repo_path == NULL) {
- error = got_error_from_errno();
- goto done;
- }
+ error = got_error_from_errno();
+ goto done;
}
error = apply_unveil(repo_path, NULL);
free(repo_path);
free(cwd);
free(id);
+ if (worktree)
+ got_worktree_close(worktree);
if (repo) {
const struct got_error *repo_error;
repo_error = got_repo_close(repo);