On Wed, Mar 28, 2018 at 11:52 AM, Jeff King <peff@xxxxxxxx> wrote: > On Tue, Mar 27, 2018 at 07:30:24PM +0200, Duy Nguyen wrote: > >> On Tue, Mar 27, 2018 at 07:09:36PM +0200, Duy Nguyen wrote: >> > I would rather have something like ref_store_reinit() in the same >> > spirit as the second call of set_git_dir() in setup_work_tree. It is >> > hacky, but it works and keeps changes to minimal (so that it could be >> > easily replaced later). >> >> So in the name of hacky and dirty things, it would look something like >> this. This passed your test case. The test suite is still running >> (slow laptop) but I don't expect breakages there. > > I think this is the right direction. I mentioned in my last reply that > it would be nice for this to be a bit more generic, in case we need to > use it again (and also just to keep the module boundaries sane). Yes, that's why I called it hacky and dirty :) I keep thinking about this, so I will probably fix it in a nicer way. > This part confused me at first: > >> +void make_main_ref_store_use_absolute_paths(void) >> +{ >> + files_force_absolute_paths(get_main_ref_store()); >> +} >> + >> +void make_main_ref_store_use_relative_paths(const char *cwd) >> +{ >> + files_make_relative_paths(get_main_ref_store(), cwd); >> +} > > since I thought you were actually turning things into absolute paths. > But your procedure is basically "turn absolute, then after chdir, turn > them back relative". > > 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. -- Duy