summaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/environment.c b/environment.c
index e72a02d0d5..10c9061c43 100644
--- a/environment.c
+++ b/environment.c
@@ -254,8 +254,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 +267,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 +350,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)