diff options
author | Jeff King <peff@peff.net> | 2018-03-30 14:35:12 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-30 12:50:03 -0700 |
commit | fb9c2d27039a23457cb9710d86e00c51dfb910dc (patch) | |
tree | b5a6eb64aaea881017bdf5e935f6accc42c21b8d /refs/packed-backend.c | |
parent | set_work_tree: use chdir_notify (diff) | |
download | tgif-fb9c2d27039a23457cb9710d86e00c51dfb910dc.tar.xz |
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 <rafa.almas@gmail.com>
Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/packed-backend.c')
-rw-r--r-- | refs/packed-backend.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 65288c6472..369c34f886 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -5,6 +5,7 @@ #include "packed-backend.h" #include "../iterator.h" #include "../lockfile.h" +#include "../chdir-notify.h" enum mmap_strategy { /* @@ -202,6 +203,8 @@ struct ref_store *packed_ref_store_create(const char *path, refs->store_flags = store_flags; refs->path = xstrdup(path); + chdir_notify_reparent("packed-refs", &refs->path); + return ref_store; } |