summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-11-13 21:02:01 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-11-13 21:03:17 (GMT)
commite90e81202b07f9bf036018e95d7cd1af6a7288ee (patch)
treea14a6c9ec6afdac8fce670e9ee0f301f090116d9
parenta9b66dd62fe1c7a3458ff5885a273b58ffda07dd (diff)
downloadeeshow-e90e81202b07f9bf036018e95d7cd1af6a7288ee.zip
eeshow-e90e81202b07f9bf036018e95d7cd1af6a7288ee.tar.gz
eeshow-e90e81202b07f9bf036018e95d7cd1af6a7288ee.tar.bz2
file/git-file.c (select_repo): the root of relative paths is "." not "/"
-rw-r--r--file/git-file.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/file/git-file.c b/file/git-file.c
index 10e70a4..daf1aec 100644
--- a/file/git-file.c
+++ b/file/git-file.c
@@ -76,15 +76,25 @@ static git_repository *select_repo(const char *path)
* If we can't find a repo, this may be due to the file or directory
* the path points to not existing in the currently checked-out tree.
* So we trim off elements until we find a repository.
+ *
+ * @@@ should we make relative paths absolute first ?
*/
while (1) {
- progress(3, "trying \"%s\"", tmp);
- if (!git_repository_open_ext_caching(&repo, *tmp ? tmp : "/",
+ const char *try = *tmp ? tmp : *path == '/' ? "/" : ".";
+
+ progress(3, "trying \"%s\"", try);
+ if (!git_repository_open_ext_caching(&repo, try,
GIT_REPOSITORY_OPEN_CROSS_FS, NULL))
break;
- slash = strrchr(tmp, '/');
- if (!slash)
+ if (!*tmp)
break;
+ slash = strrchr(tmp, '/');
+ if (!slash) {
+ if (*path == '/')
+ break;
+ *tmp = 0;
+ continue; /* try "." */
+ }
*slash = 0;
}
free(tmp);