summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/setup.c b/setup.c
index dadc666..03cd84f 100644
--- a/setup.c
+++ b/setup.c
@@ -7,10 +7,13 @@ static int inside_work_tree = -1;
char *prefix_path(const char *prefix, int len, const char *path)
{
const char *orig = path;
- char *sanitized = xmalloc(len + strlen(path) + 1);
- if (is_absolute_path(orig))
- strcpy(sanitized, path);
- else {
+ char *sanitized;
+ if (is_absolute_path(orig)) {
+ const char *temp = real_path(path);
+ sanitized = xmalloc(len + strlen(temp) + 1);
+ strcpy(sanitized, temp);
+ } else {
+ sanitized = xmalloc(len + strlen(path) + 1);
if (len)
memcpy(sanitized, prefix, len);
strcpy(sanitized + len, path);
@@ -218,7 +221,7 @@ void setup_work_tree(void)
work_tree = get_git_work_tree();
git_dir = get_git_dir();
if (!is_absolute_path(git_dir))
- git_dir = make_absolute_path(git_dir);
+ git_dir = real_path(get_git_dir());
if (!work_tree || chdir(work_tree))
die("This operation must be run in a work tree");
@@ -229,7 +232,7 @@ void setup_work_tree(void)
if (getenv(GIT_WORK_TREE_ENVIRONMENT))
setenv(GIT_WORK_TREE_ENVIRONMENT, ".", 1);
- set_git_dir(make_relative_path(git_dir, work_tree));
+ set_git_dir(relative_path(git_dir, work_tree));
initialized = 1;
}
@@ -309,7 +312,7 @@ const char *read_gitfile_gently(const char *path)
if (!is_git_directory(dir))
die("Not a git repository: %s", dir);
- path = make_absolute_path(dir);
+ path = real_path(dir);
free(buf);
return path;
@@ -389,7 +392,7 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
if (!prefixcmp(cwd, worktree) &&
cwd[strlen(worktree)] == '/') { /* cwd inside worktree */
- set_git_dir(make_absolute_path(gitdirenv));
+ set_git_dir(real_path(gitdirenv));
if (chdir(worktree))
die_errno("Could not chdir to '%s'", worktree);
cwd[len++] = '/';
@@ -414,7 +417,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
/* --work-tree is set without --git-dir; use discovered one */
if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
if (offset != len && !is_absolute_path(gitdir))
- gitdir = xstrdup(make_absolute_path(gitdir));
+ gitdir = xstrdup(real_path(gitdir));
if (chdir(cwd))
die_errno("Could not come back to cwd");
return setup_explicit_git_dir(gitdir, cwd, len, nongit_ok);
@@ -422,7 +425,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
/* #16.2, #17.2, #20.2, #21.2, #24, #25, #28, #29 (see t1510) */
if (is_bare_repository_cfg > 0) {
- set_git_dir(offset == len ? gitdir : make_absolute_path(gitdir));
+ set_git_dir(offset == len ? gitdir : real_path(gitdir));
if (chdir(cwd))
die_errno("Could not come back to cwd");
return NULL;