diff options
author | Jeff King <peff@peff.net> | 2015-04-02 14:37:40 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-04-02 12:29:15 -0700 |
commit | 84ccad8dec1b8675699d70412def098d61456c55 (patch) | |
tree | 0be73fae8b41992942fca51fd30825d883944ba3 /builtin/remote-ext.c | |
parent | Merge branch 'maint-1.9' into maint-2.0 (diff) | |
download | tgif-84ccad8dec1b8675699d70412def098d61456c55.tar.xz |
init: don't set core.worktree when initializing /.git
If you create a git repository in the root directory with
"git init /", we erroneously write a core.worktree entry.
This isn't _wrong_, in the sense that it's OK to set
core.worktree when we don't need to. But it is unnecessarily
surprising if you later move the .git directory to another
path (which usually moves the relative working tree, but is
foiled if there is an explicit worktree set).
The problem is that we check whether core.worktree is
necessary by seeing if we can make the git_dir by
concatenating "/.git" onto the working tree. That would lead
to "//.git" in this instance, but we actually have "/.git"
(without the doubled slash).
We can fix this by special-casing the root directory. I also
split the logic out into its own function to make the
conditional a bit more readable (and used skip_prefix, which
I think makes it a little more obvious what is going on).
No tests, as we would need to be able to write to "/" to do
so. I did manually confirm that:
sudo git init /
cd /
git rev-parse --show-toplevel
git config core.worktree
still finds the top-level correctly (as "/"), and does not
set any core.worktree variable.
Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/remote-ext.c')
0 files changed, 0 insertions, 0 deletions