commit 0c48fee25cfbd876833d857ed3810028847225b0 from: Stefan Sperling date: Mon Mar 11 17:15:28 2019 UTC refuse to create got worktree at a git repo path commit - 0cd1c46a9e4b3e3a7c7f2947c3eded6fb5439516 commit + 0c48fee25cfbd876833d857ed3810028847225b0 blob - 65ff442b096e36f03c632555fd6def55aea92bc4 blob + 67326beff75d161b6b1590cd639b5563c4349e5a --- include/got_error.h +++ include/got_error.h @@ -79,6 +79,7 @@ #define GOT_ERR_UUID 63 #define GOT_ERR_LOCKFILE_TIMEOUT 64 #define GOT_ERR_BAD_REF_NAME 65 +#define GOT_ERR_WORKTREE_REPO 66 static const struct got_error { int code; @@ -148,6 +149,7 @@ static const struct got_error { { GOT_ERR_UUID, "uuid error" }, { GOT_ERR_LOCKFILE_TIMEOUT,"lockfile timeout" }, { GOT_ERR_BAD_REF_NAME, "bad reference name" }, + { GOT_ERR_WORKTREE_REPO,"cannot create worktree inside a git repository" }, }; /* blob - b42d708e36334e931b05947d1446757aa3433d93 blob + 352980fef7bc6bc18f72804c17919ced4a0e94f6 --- lib/worktree.c +++ lib/worktree.c @@ -207,6 +207,11 @@ got_worktree_init(const char *path, struct got_referen char *basestr = NULL; char *uuidstr = NULL; + if (strcmp(path, got_repo_get_path(repo)) == 0) { + err = got_error(GOT_ERR_WORKTREE_REPO); + goto done; + } + err = got_ref_resolve(&commit_id, repo, head_ref); if (err) return err;