summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-28 08:14:16 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-28 08:14:16 -0700
commite3215123d1d34f98bf72ded187ad9ee201db9789 (patch)
treee0369bdebf3d453d309ed44178b8a988dffb4cf7
parentb76a0f0b97a463bffeeb263e583dc6ed06302a6a (diff)
downloadsubsurface-e3215123d1d34f98bf72ded187ad9ee201db9789.tar.gz
Fix parsing of git branch encoded in file name
If the folder has a trailing '/' we picked the wrong substring as branch name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--git-access.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/git-access.c b/git-access.c
index bc8903331..7e1a47ee1 100644
--- a/git-access.c
+++ b/git-access.c
@@ -209,6 +209,7 @@ static struct git_repository *is_remote_git_repository(const char *remote, const
struct git_repository *is_git_repository(const char *filename, const char **branchp)
{
int flen, blen, ret;
+ int offset = 1;
struct stat st;
git_repository *repo;
char *loc, *branch;
@@ -223,8 +224,10 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
blen++;
/* Ignore slashes at the end of the repo name */
- while (flen && filename[flen-1] == '/')
+ while (flen && filename[flen-1] == '/') {
flen--;
+ offset++;
+ }
if (!flen)
return NULL;
@@ -248,7 +251,7 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
if (!loc)
return dummy_git_repository;
- branch = format_string("%.*s", blen, filename+flen+1);
+ branch = format_string("%.*s", blen, filename + flen + offset);
if (!branch) {
free(loc);
return dummy_git_repository;