diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/repository.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/repository.c b/src/repository.c index 4e0f9d491..ce313280e 100644 --- a/src/repository.c +++ b/src/repository.c @@ -871,13 +871,16 @@ const char *git_repository_workdir(git_repository *repo) int git_repository_set_workdir(git_repository *repo, const char *workdir) { + git_buf path = GIT_BUF_INIT; + assert(repo && workdir); - free(repo->workdir); + if (git_path_prettify_dir(&path, workdir, NULL) < 0) + return -1; - repo->workdir = git__strdup(workdir); - GITERR_CHECK_ALLOC(repo->workdir); + free(repo->workdir); + repo->workdir = git_buf_detach(&path); repo->is_bare = 0; return 0; } |