Re: git complains packed-refs is not a directory when used with GIT_DIR and GIT_WORK_TREE envvars.
- From
Jeff King <peff@peff.net>
- Date
- Mar 28, 2018, 17:36 UTC
- Message-ID
- <20180328173656.GA29094@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8AVcPi=0i7s9o8cy-XGFuOLr72fe9WLRnEqo1SwLJEBOw@mail.gmail.com>
On Wed, Mar 28, 2018 at 12:10:21PM +0200, Duy Nguyen wrote:
Show 9 quoted lines
> > I think it might be clearer if a single call is given both the old and > > new paths. That requires the caller of chdir() storing getcwd() before > > it moves, but I don't think that should be a big deal. > > The problem is switching relative paths relies on the old $CWD if I'm > not mistaken and we need getcwd() for this. I'd love to have one > callback that says "$CWD has been switched from this path to that > path, do whatever you need to" that can be called any time, before or > after chdir(). I'll look more into it.
I think it should be OK to save getcwd() and just construct the original path after the fact. Here's some patches which do that in a nice way.
For those just joining us, this fixes a regression that was in v2.13 (so nothing we need to worry about as part of the 2.17-rc track).
[1/4]: set_git_dir: die when setenv() fails [2/4]: add chdir-notify API [3/4]: set_work_tree: use chdir_notify [4/4]: refs: use chdir_notify to update cached relative paths
Makefile | 1 + cache.h | 2 +- chdir-notify.c | 71 +++++++++++++++++++++++++++++++++++++++++++ chdir-notify.h | 64 ++++++++++++++++++++++++++++++++++++++ environment.c | 22 ++++++++++++-- refs/files-backend.c | 4 +++ refs/packed-backend.c | 3 ++ setup.c | 9 ++---- t/t1501-work-tree.sh | 12 ++++++++ 9 files changed, 178 insertions(+), 10 deletions(-) create mode 100644 chdir-notify.c create mode 100644 chdir-notify.h
-Peff