Re: Forcing git top-level
- From
Jeff King <peff@peff.net>
- Date
- Mar 31, 2015, 18:15 UTC
- Message-ID
- <20150331181552.GC19206@peff.net>
- In-Reply-To
- <0FD999DB-3DBF-40D4-8128-715BDC49EAAB@free.fr>
On Tue, Mar 31, 2015 at 11:25:58AM +0200, Cedric Gava wrote:
> I’ve copied a .git folder located at the root (/) of a filesystem, > into another directory (/home/mydir). If I issue a git rev-parse > —show-toplevel I got "/"... > I would like to change the top-level to point to /home/mydir.
Try running "git config --unset core.worktree" in the .git dir.
It looks like "git init" will write a core.worktree entry in this case, even though it isn't technically needed. I think it is due to these lines in builtin/init-db.c:
if (!starts_with(git_dir, work_tree) ||
strcmp(git_dir + strlen(work_tree), "/.git")) {
git_config_set("core.worktree", work_tree);
}The check returns a false positive for the root directory because we only have one slash (i.e., appending "/.git" to our worktree would be "//.git" in this case).
-Peff