diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-11-11 16:55:33 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2016-11-14 10:53:08 +0100 |
commit | 0f316096115513b5a07eb4df3883ba45ada28a07 (patch) | |
tree | 6435b108e2862dde4f5baed8718ec3244ea850a8 /tests/repo | |
parent | 4dbaf3cd6208e7ce1f0d6be714c1a7cfa646259c (diff) | |
download | libgit2-0f316096115513b5a07eb4df3883ba45ada28a07.tar.gz |
repository: do not interpret all files as gitlinks in discovery
When trying to find a discovery, we walk up the directory
structure checking if there is a ".git" file or directory and, if
so, check its validity. But in the case that we've got a ".git"
file, we do not want to unconditionally assume that the file is
in fact a ".git" file and treat it as such, as we would error out
if it is not.
Fix the issue by only treating a file as a gitlink file if it
ends with "/.git". This allows users of the function to discover
a repository by handing in any path contained inside of a git
repository.
Diffstat (limited to 'tests/repo')
-rw-r--r-- | tests/repo/discover.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/repo/discover.c b/tests/repo/discover.c index ca916e341..48aa27581 100644 --- a/tests/repo/discover.c +++ b/tests/repo/discover.c @@ -189,3 +189,13 @@ void test_repo_discover__ceiling_should_not_affect_gitdir_redirection(void) ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB, ceiling_dirs.ptr, SUB_REPOSITORY_GITDIR); ensure_repository_discover(REPOSITORY_ALTERNATE_FOLDER_SUB_SUB_SUB, ceiling_dirs.ptr, DISCOVER_FOLDER); } + +void test_repo_discover__discovery_starting_at_file_succeeds(void) +{ + int fd; + + cl_assert((fd = p_creat(SUB_REPOSITORY_FOLDER "/file", 0600)) >= 0); + cl_assert(p_close(fd) == 0); + + ensure_repository_discover(SUB_REPOSITORY_FOLDER "/file", ceiling_dirs.ptr, SUB_REPOSITORY_GITDIR); +} |