mirror of
https://git.proxmox.com/git/libgit2
synced 2025-11-03 10:59:45 +00:00
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. |
||
|---|---|---|
| .. | ||
| attr | ||
| blame | ||
| buf | ||
| checkout | ||
| cherrypick | ||
| clar | ||
| clone | ||
| commit | ||
| config | ||
| core | ||
| date | ||
| describe | ||
| diff | ||
| fetchhead | ||
| filter | ||
| graph | ||
| index | ||
| merge | ||
| network | ||
| notes | ||
| object | ||
| odb | ||
| online | ||
| pack | ||
| path | ||
| perf | ||
| rebase | ||
| refs | ||
| remote | ||
| repo | ||
| reset | ||
| resources | ||
| revert | ||
| revwalk | ||
| stash | ||
| status | ||
| stress | ||
| submodule | ||
| threads | ||
| trace | ||
| transport | ||
| win32 | ||
| clar_libgit2_timer.c | ||
| clar_libgit2_timer.h | ||
| clar_libgit2_trace.c | ||
| clar_libgit2_trace.h | ||
| clar_libgit2.c | ||
| clar_libgit2.h | ||
| clar.c | ||
| clar.h | ||
| generate_crlf.sh | ||
| generate.py | ||
| main.c | ||
| README.md | ||
| valgrind-supp-mac.txt | ||
Writing Clar tests for libgit2
For information on the Clar testing framework and a detailed introduction please visit:
-
Write your modules and tests. Use good, meaningful names.
-
Make sure you actually build the tests by setting:
cmake -DBUILD_CLAR=ON build/ -
Test:
./build/libgit2_clar -
Make sure everything is fine.
-
Send your pull request. That's it.