stop checking for a worktree in open_repo()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
diff --git a/lib/repository.c b/lib/repository.c
index 7c1144d..6112deb 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -262,14 +262,11 @@ const struct got_error *
open_repo(struct got_repository *repo, const char *path)
{
const struct got_error *err = NULL;
- struct got_worktree *worktree = NULL;
/* bare git repository? */
repo->path_git_dir = strdup(path);
- if (repo->path_git_dir == NULL) {
- err = got_error_from_errno();
- goto done;
- }
+ if (repo->path_git_dir == NULL)
+ return got_error_from_errno();
if (is_git_repo(repo)) {
repo->path = strdup(repo->path_git_dir);
if (repo->path == NULL) {
@@ -294,49 +291,14 @@ open_repo(struct got_repository *repo, const char *path)
return NULL;
}
- /* got work tree checked out from bare git repository? */
- free(repo->path_git_dir);
- repo->path_git_dir = NULL;
- err = got_worktree_open(&worktree, path);
+ err = got_error(GOT_ERR_NOT_GIT_REPO);
+done:
if (err) {
- if (err->code == GOT_ERR_ERRNO && errno == ENOENT)
- err = got_error(GOT_ERR_NOT_GIT_REPO);
- goto done;
- }
- repo->path_git_dir = strdup(worktree->repo_path);
- if (repo->path_git_dir == NULL) {
- err = got_error_from_errno();
- goto done;
- }
-
- /* got work tree checked out from git repository with working tree? */
- if (!is_git_repo(repo)) {
+ free(repo->path);
+ repo->path = NULL;
free(repo->path_git_dir);
- if (asprintf(&repo->path_git_dir, "%s/%s", worktree->repo_path,
- GOT_GIT_DIR) == -1) {
- err = got_error_from_errno();
- repo->path_git_dir = NULL;
- goto done;
- }
- if (!is_git_repo(repo)) {
- err = got_error(GOT_ERR_NOT_GIT_REPO);
- goto done;
- }
- repo->path = strdup(worktree->repo_path);
- if (repo->path == NULL) {
- err = got_error_from_errno();
- goto done;
- }
- } else {
- repo->path = strdup(repo->path_git_dir);
- if (repo->path == NULL) {
- err = got_error_from_errno();
- goto done;
- }
+ repo->path_git_dir = NULL;
}
-done:
- if (worktree)
- got_worktree_close(worktree);
return err;
}