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 /src | |
| 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 'src')
| -rw-r--r-- | src/repository.c | 2 |
1 files changed, 1 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; |
