mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b76a0f0b97
commit
e3215123d1
1 changed files with 5 additions and 2 deletions
|
@ -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)
|
struct git_repository *is_git_repository(const char *filename, const char **branchp)
|
||||||
{
|
{
|
||||||
int flen, blen, ret;
|
int flen, blen, ret;
|
||||||
|
int offset = 1;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
git_repository *repo;
|
git_repository *repo;
|
||||||
char *loc, *branch;
|
char *loc, *branch;
|
||||||
|
@ -223,8 +224,10 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
|
||||||
blen++;
|
blen++;
|
||||||
|
|
||||||
/* Ignore slashes at the end of the repo name */
|
/* Ignore slashes at the end of the repo name */
|
||||||
while (flen && filename[flen-1] == '/')
|
while (flen && filename[flen-1] == '/') {
|
||||||
flen--;
|
flen--;
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!flen)
|
if (!flen)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -248,7 +251,7 @@ struct git_repository *is_git_repository(const char *filename, const char **bran
|
||||||
if (!loc)
|
if (!loc)
|
||||||
return dummy_git_repository;
|
return dummy_git_repository;
|
||||||
|
|
||||||
branch = format_string("%.*s", blen, filename+flen+1);
|
branch = format_string("%.*s", blen, filename + flen + offset);
|
||||||
if (!branch) {
|
if (!branch) {
|
||||||
free(loc);
|
free(loc);
|
||||||
return dummy_git_repository;
|
return dummy_git_repository;
|
||||||
|
|
Loading…
Add table
Reference in a new issue