assume good path input in got_worktree_init()
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
diff --git a/lib/worktree.c b/lib/worktree.c
index b05a2c2..26980ac 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -133,8 +133,6 @@ got_worktree_init(const char *path, struct got_reference *head_ref,
const char *prefix, struct got_repository *repo)
{
const struct got_error *err = NULL;
- char *abspath = NULL;
- char *normpath = NULL;
char *gotpath = NULL;
char *refstr = NULL;
char *path_repos = NULL;
@@ -143,29 +141,14 @@ got_worktree_init(const char *path, struct got_reference *head_ref,
if (!got_path_is_absolute(prefix))
return got_error(GOT_ERR_BAD_PATH);
- if (got_path_is_absolute(path)) {
- abspath = strdup(path);
- if (abspath == NULL)
- return got_error(GOT_ERR_NO_MEM);
- } else {
- abspath = got_path_get_absolute(path);
- if (abspath == NULL)
- return got_error(GOT_ERR_BAD_PATH);
- }
-
/* Create top-level directory (may already exist). */
- normpath = got_path_normalize(abspath);
- if (normpath == NULL) {
- err = got_error(GOT_ERR_BAD_PATH);
- goto done;
- }
- if (mkdir(normpath, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
+ if (mkdir(path, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
err = got_error_from_errno();
goto done;
}
/* Create .got directory (may already exist). */
- if (asprintf(&gotpath, "%s/%s", normpath, GOT_WORKTREE_GOT_DIR) == -1) {
+ if (asprintf(&gotpath, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
err = got_error(GOT_ERR_NO_MEM);
goto done;
}
@@ -214,8 +197,6 @@ got_worktree_init(const char *path, struct got_reference *head_ref,
goto done;
done:
- free(abspath);
- free(normpath);
free(gotpath);
free(formatstr);
free(refstr);