diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-04-25 06:28:52 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-04-25 06:28:52 +0200 |
commit | ff6eb825f0aa1f45230c10fbb0cf8d484c927c55 (patch) | |
tree | e64f3f038b0f888c0ddc0a5c97e0d266068b82a4 /setup.c | |
parent | Merge branch 'jk/flockfile-stdio' (diff) | |
parent | refs: use chdir_notify to update cached relative paths (diff) | |
download | git-ff6eb825f0aa1f45230c10fbb0cf8d484c927c55.tar.xz git-ff6eb825f0aa1f45230c10fbb0cf8d484c927c55.zip |
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.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -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; } |