summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-04-25 04:28:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-25 04:28:52 (GMT)
commitff6eb825f0aa1f45230c10fbb0cf8d484c927c55 (patch)
treee64f3f038b0f888c0ddc0a5c97e0d266068b82a4 /setup.c
parent5d8da91e707668227464c9ba0e74b5fea1ee3b7e (diff)
parentfb9c2d27039a23457cb9710d86e00c51dfb910dc (diff)
downloadgit-ff6eb825f0aa1f45230c10fbb0cf8d484c927c55.zip
git-ff6eb825f0aa1f45230c10fbb0cf8d484c927c55.tar.gz
git-ff6eb825f0aa1f45230c10fbb0cf8d484c927c55.tar.bz2
Merge branch 'jk/relative-directory-fix'
Some codepaths, including the refs API, get and keep relative paths, that go out of sync when the process does chdir(2). The chdir-notify API is introduced to let these codepaths adjust these cached paths to the new current directory. * jk/relative-directory-fix: refs: use chdir_notify to update cached relative paths set_work_tree: use chdir_notify add chdir-notify API trace.c: export trace_setup_key set_git_dir: die when setenv() fails
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/setup.c b/setup.c
index 664453f..3e03d44 100644
--- a/setup.c
+++ b/setup.c
@@ -3,6 +3,7 @@
#include "config.h"
#include "dir.h"
#include "string-list.h"
+#include "chdir-notify.h"
static int inside_git_dir = -1;
static int inside_work_tree = -1;
@@ -378,7 +379,7 @@ int is_inside_work_tree(void)
void setup_work_tree(void)
{
- const char *work_tree, *git_dir;
+ const char *work_tree;
static int initialized = 0;
if (initialized)
@@ -388,10 +389,7 @@ void setup_work_tree(void)
die(_("unable to set up work tree using invalid config"));
work_tree = get_git_work_tree();
- git_dir = get_git_dir();
- if (!is_absolute_path(git_dir))
- git_dir = real_path(get_git_dir());
- if (!work_tree || chdir(work_tree))
+ if (!work_tree || chdir_notify(work_tree))
die(_("this operation must be run in a work tree"));
/*
@@ -401,7 +399,6 @@ void setup_work_tree(void)
if (getenv(GIT_WORK_TREE_ENVIRONMENT))
setenv(GIT_WORK_TREE_ENVIRONMENT, ".", 1);
- set_git_dir(remove_leading_path(git_dir, work_tree));
initialized = 1;
}