commit - 09fe317aa5456c8be46403735c10a133dd02c017
commit + 2cb4bacb7c1ad57cef8ae02b159583485cec240d
blob - b05a2c27cf5358de8999bc351d603c3251e7aace
blob + 26980ac94f87f3f8c0a73840aca3870230a857b4
--- lib/worktree.c
+++ lib/worktree.c
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;
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;
}
goto done;
done:
- free(abspath);
- free(normpath);
free(gotpath);
free(formatstr);
free(refstr);