summaryrefslogtreecommitdiffstats
path: root/core/git-access.c
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2017-12-02 08:51:15 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-02 08:18:42 -0800
commit137e83f7f2595e373be118b724c2fd18db701c98 (patch)
treea46c5fe87ab6b85fe50d8b44525f47abad07f4f1 /core/git-access.c
parent136110784ebe2a188ca867bea3a7ff3037281a57 (diff)
downloadsubsurface-137e83f7f2595e373be118b724c2fd18db701c98.tar.gz
Fix file:// handling for git access.
Currently, in is_remote_git_repository(), git URLs of the form "file://..." are recognized as local and the "file://" prefix is removed. The shortened URL is then processed as if it was a remote URL, which of course has to fail. So far so good - this is not a remote repository after all. But the removal of the prefix is not propagated to the calling is_git_repository() function and handling as a local git repository therefore fails likewise. To fix this issue, move removal of the "file://" prefix one level up to the is_git_repository() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/git-access.c')
-rw-r--r--core/git-access.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/core/git-access.c b/core/git-access.c
index 83a8c6054..dc48546a6 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -832,15 +832,10 @@ static struct git_repository *is_remote_git_repository(char *remote, const char
if (*p++ != '/' || *p++ != '/')
return NULL;
- /* Special-case "file://", since it's already local */
- if (!strncmp(remote, "file://", 7))
- remote += 7;
-
/*
- * Ok, we found "[a-z]*://", we've simplified the
- * local repo case (because libgit2 is insanely slow
- * for that), and we think we have a real "remote
- * git" format.
+ * Ok, we found "[a-z]*://" and we think we have a real
+ * "remote git" format. The "file://" case was handled
+ * in the calling function.
*
* We now create the SHA1 hash of the whole thing,
* including the branch name. That will be our unique
@@ -905,6 +900,15 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
if (!flen || filename[--flen] != ']')
return NULL;
+ /*
+ * Special-case "file://", and treat it as a local
+ * repository since libgit2 is insanely slow for that.
+ */
+ if (!strncmp(filename, "file://", 7)) {
+ filename += 7;
+ flen -= 7;
+ }
+
/* Find the matching '[' */
blen = 0;
while (flen && filename[--flen] != '[')