allow checkout on top of an existing tree
diff --git a/got/got.c b/got/got.c
index fec08d6..1041ba9 100644
--- a/got/got.c
+++ b/got/got.c
@@ -276,7 +276,7 @@ cmd_checkout(int argc, char *argv[])
goto done;
error = got_worktree_init(worktree_path, head_ref, path_prefix, repo);
- if (error != NULL)
+ if (error != NULL && !(error->code == GOT_ERR_ERRNO && errno == EEXIST))
goto done;
error = got_worktree_open(&worktree, worktree_path);
diff --git a/lib/worktree.c b/lib/worktree.c
index 7329316..70d2944 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -426,6 +426,9 @@ add_file_on_disk(struct got_worktree *worktree, struct got_fileindex *fileindex,
} else if (!S_ISREG(sb.st_mode)) {
/* TODO file is obstructed; do something */
err = got_error(GOT_ERR_FILE_OBSTRUCTED);
+ } else {
+ /* TODO: Merge the file! */
+ return NULL;
}
}
return err;