git only checks ceiling directories when its search ascends to a parent directory. A ceiling directory matching the starting directory will not prevent git from finding a repository in the starting directory or a parent directory. libgit2 handled the former case correctly, but differed from git in the latter case: given a ceiling directory matching the starting directory, but no repository at the starting directory, libgit2 would stop the search at that point rather than finding a repository in a parent directory. Test case using git command-line tools: /tmp$ git init x Initialized empty Git repository in /tmp/x/.git/ /tmp$ cd x/ /tmp/x$ mkdir subdir /tmp/x$ cd subdir/ /tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x git rev-parse --git-dir fatal: Not a git repository (or any of the parent directories): .git /tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x/subdir git rev-parse --git-dir /tmp/x/.git Fix the testsuite to test this case (in one case fixing a test that depended on the current behavior), and then fix find_repo to handle this case correctly. In the process, simplify and document the logic in find_repo(): - Separate the concepts of "currently checking a .git directory" and "number of iterations left before going further counts as a search" into two separate variables, in_dot_git and min_iterations. - Move the logic to handle in_dot_git and append /.git to the top of the loop. - Only search ceiling_dirs and find ceiling_offset after running out of min_iterations; since ceiling_offset only tracks the longest matching ceiling directory, if ceiling_dirs contained both the current directory and a parent directory, this change makes find_repo stop the search at the parent directory.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
attr | Loading commit data... | |
blame | Loading commit data... | |
buf | Loading commit data... | |
checkout | Loading commit data... | |
cherrypick | Loading commit data... | |
clar | Loading commit data... | |
clone | Loading commit data... | |
commit | Loading commit data... | |
config | Loading commit data... | |
core | Loading commit data... | |
date | Loading commit data... | |
describe | Loading commit data... | |
diff | Loading commit data... | |
fetchhead | Loading commit data... | |
filter | Loading commit data... | |
graph | Loading commit data... | |
index | Loading commit data... | |
iterator | Loading commit data... | |
merge | Loading commit data... | |
network | Loading commit data... | |
notes | Loading commit data... | |
object | Loading commit data... | |
odb | Loading commit data... | |
online | Loading commit data... | |
pack | Loading commit data... | |
path | Loading commit data... | |
perf | Loading commit data... | |
rebase | Loading commit data... | |
refs | Loading commit data... | |
remote | Loading commit data... | |
repo | Loading commit data... | |
reset | Loading commit data... | |
resources | Loading commit data... | |
revert | Loading commit data... | |
revwalk | Loading commit data... | |
stash | Loading commit data... | |
status | Loading commit data... | |
stress | Loading commit data... | |
submodule | Loading commit data... | |
threads | Loading commit data... | |
trace | Loading commit data... | |
transport | Loading commit data... | |
win32 | Loading commit data... | |
README.md | Loading commit data... | |
clar.c | Loading commit data... | |
clar.h | Loading commit data... | |
clar_libgit2.c | Loading commit data... | |
clar_libgit2.h | Loading commit data... | |
clar_libgit2_timer.c | Loading commit data... | |
clar_libgit2_timer.h | Loading commit data... | |
clar_libgit2_trace.c | Loading commit data... | |
clar_libgit2_trace.h | Loading commit data... | |
generate.py | Loading commit data... | |
generate_crlf.sh | Loading commit data... | |
main.c | Loading commit data... | |
valgrind-supp-mac.txt | Loading commit data... |