diff options
-rw-r--r-- | src/repository.c | 2 | ||||
-rw-r--r-- | tests/repo/discover.c | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/repository.c b/src/repository.c index 7bdcefd40..5c4442360 100644 --- a/src/repository.c +++ b/src/repository.c @@ -410,7 +410,7 @@ static int find_repo( break; } } - else if (S_ISREG(st.st_mode)) { + else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) { error = read_gitfile(&repo_link, path.ptr); if (error < 0) break; 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); +} |