summaryrefslogtreecommitdiff
path: root/convert.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-04-02 18:37:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-04-02 19:29:15 (GMT)
commit84ccad8dec1b8675699d70412def098d61456c55 (patch)
tree0be73fae8b41992942fca51fd30825d883944ba3 /convert.h
parent282616c72d1d08a77ca4fe1186cb708c38408d87 (diff)
downloadgit-84ccad8dec1b8675699d70412def098d61456c55.zip
git-84ccad8dec1b8675699d70412def098d61456c55.tar.gz
git-84ccad8dec1b8675699d70412def098d61456c55.tar.bz2
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 'convert.h')
0 files changed, 0 insertions, 0 deletions