diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-03-13 21:10:42 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-14 14:24:16 -0700 |
commit | ce9b8aab5d9a40a84b4868fa890654900ab2d4cc (patch) | |
tree | 32efa4a4d030ab0d31a5d69aee9436b3a1874320 /t/helper/test-read-cache.c | |
parent | setup: prepare setup_discovered_git_dir() for the root directory (diff) | |
download | tgif-ce9b8aab5d9a40a84b4868fa890654900ab2d4cc.tar.xz |
setup_git_directory_1(): avoid changing global state
For historical reasons, Git searches for the .git/ directory (or the
.git file) by changing the working directory successively to the parent
directory of the current directory, until either anything was found or
until a ceiling or a mount point is hit.
Further global state may be changed in case a .git/ directory was found.
We do have a use case, though, where we would like to find the .git/
directory without having any global state touched, though: when we read
the early config e.g. for the pager or for alias expansion.
Let's just move all of code that changes any global state out of the
function `setup_git_directory_gently_1()` into
`setup_git_directory_gently()`.
In subsequent patches, we will use the _1() function in a new
`discover_git_directory()` function that we will then use for the early
config code.
Note: the new loop is a *little* tricky, as we have to handle the root
directory specially: we cannot simply strip away the last component
including the slash, as the root directory only has that slash. To remedy
that, we introduce the `min_offset` variable that holds the minimal length
of an absolute path, and using that to special-case the root directory,
including an early exit before trying to find the parent of the root
directory.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/helper/test-read-cache.c')
0 files changed, 0 insertions, 0 deletions