Re: git diff-index with relative git-dir does not work
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Feb 9, 2010, 11:58 UTC
- Message-ID
- <fcaeb9bf1002090358v3d7f69d5ra80c186d30a1304d@mail.gmail.com>
- In-Reply-To
- <871vguy8hz.wl@dns1.atmark-techno.com>
On 2/9/10, Yasushi SHOJI <yashi@atmark-techno.com> wrote:
Show 11 quoted lines
> ... > This is because static variable 'base' in sha1_file_name is already > assigned _before_ setup_work_tree() from cmd_diff_index() is > called. setup_work_tree() eventually chdir to the given work tree dir, > but we use the old base to generate object file path. And that cause > open(2) to fail because the object file path and the current dir is > not in sync any more. > > So, is it correct to assume that we must call setup_work_tree() > _before_ any function which call getter/setter in environment.c? This > including open_sha1_file, in this case.
We must if gitdir is relative to cwd (and will be moved by setup_work_tree). Or just make gitdir absolute path.
> Also, would it be a good idea to make all builtin command to > _explicitly_ call setup_* functions, so that we can find calling order > bug?
If you agree that writing "RUN_SETUP" in git.c is explicit, then all builtin commands do explictly call setup_*. It's about relative directories and cwd being moved around.
> In that case, we must change the setup functions signature to > allow marking "not interested" or something.
I'm not sure I get your idea.
-- Duy