From e3215123d1d34f98bf72ded187ad9ee201db9789 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 28 May 2015 08:14:16 -0700 Subject: 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 --- git-access.c | 7 +++++-- 1 file 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; -- cgit v1.2.3-70-g09d2