diff options
Diffstat (limited to 'environment.c')
-rw-r--r-- | environment.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/environment.c b/environment.c index e72a02d0d5..aaca0e91ac 100644 --- a/environment.c +++ b/environment.c @@ -17,6 +17,7 @@ #include "argv-array.h" #include "object-store.h" #include "chdir-notify.h" +#include "shallow.h" int trust_executable_bit = 1; int trust_ctime = 1; @@ -254,8 +255,11 @@ static int git_work_tree_initialized; */ void set_git_work_tree(const char *new_work_tree) { + struct strbuf realpath = STRBUF_INIT; + if (git_work_tree_initialized) { - new_work_tree = real_path(new_work_tree); + strbuf_realpath(&realpath, new_work_tree, 1); + new_work_tree = realpath.buf; if (strcmp(new_work_tree, the_repository->worktree)) die("internal error: work tree has already been set\n" "Current worktree: %s\nNew worktree: %s", @@ -264,6 +268,8 @@ void set_git_work_tree(const char *new_work_tree) } git_work_tree_initialized = 1; repo_set_worktree(the_repository, new_work_tree); + + strbuf_release(&realpath); } const char *get_git_work_tree(void) @@ -345,11 +351,20 @@ static void update_relative_gitdir(const char *name, free(path); } -void set_git_dir(const char *path) +void set_git_dir(const char *path, int make_realpath) { + struct strbuf realpath = STRBUF_INIT; + + if (make_realpath) { + strbuf_realpath(&realpath, path, 1); + path = realpath.buf; + } + set_git_dir_1(path); if (!is_absolute_path(path)) chdir_notify_register(NULL, update_relative_gitdir, NULL); + + strbuf_release(&realpath); } const char *get_log_output_encoding(void) |