path: root/t/
diff options
authorJeff King <>2018-03-30 18:35:12 (GMT)
committerJunio C Hamano <>2018-03-30 19:50:03 (GMT)
commitfb9c2d27039a23457cb9710d86e00c51dfb910dc (patch)
treeb5a6eb64aaea881017bdf5e935f6accc42c21b8d /t/
parent8500e0de3fe2e33ba503d432a4a5301ce2fb60fa (diff)
refs: use chdir_notify to update cached relative paths
Commit f57f37e2e1 (files-backend: remove the use of git_path(), 2017-03-26) introduced a regression when a relative $GIT_DIR is used in a working tree: - when we initialize the ref backend, we make a copy of get_git_dir(), which may be relative - later, we may call setup_work_tree() and chdir to the root of the working tree - further calls to the ref code will use the stored git directory, but relative paths will now point to the wrong place The new test in t1501 demonstrates one such instance (the bug causes us to write the ref update to the nonsense "relative/relative/.git"). Since setup_work_tree() now uses chdir_notify, we can just ask it update our relative paths when necessary. Reported-by: Rafael Ascensao <> Helped-by: Nguyễn Thái Ngọc Duy <> Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 't/')
1 files changed, 12 insertions, 0 deletions
diff --git a/t/ b/t/
index b06210e..a5db533 100755
--- a/t/
+++ b/t/
@@ -431,4 +431,16 @@ test_expect_success 'error out gracefully on invalid $GIT_WORK_TREE' '
+test_expect_success 'refs work with relative gitdir and work tree' '
+ git init relative &&
+ git -C relative commit --allow-empty -m one &&
+ git -C relative commit --allow-empty -m two &&
+ GIT_DIR=relative/.git GIT_WORK_TREE=relative git reset HEAD^ &&
+ git -C relative log -1 --format=%s >actual &&
+ echo one >expect &&
+ test_cmp expect actual