scan-tree: fix regression in section-from-path=-1

Commit fb3655d (use struct strbuf instead of static buffers -
2013-04-06) introduced a regression in the "section-from-path" handling
when the configured value is negative.  By changing the "rel" variable
so that it includes a trailing slash, counting slashes from the end of
the string no longer gives the same answer as it did before.

Fix this by ensuring that "rel" does not have a trailing slash.

Reported-by: Julius Plenz <plenz@cis.fu-berlin.de>
Signed-off-by: John Keeping <john@keeping.me.uk>
这个提交包含在:
John Keeping 2013-04-16 18:39:58 +01:00 提交者 Jason A. Donenfeld
父节点 d483e8f569
当前提交 9a725f4f09

查看文件

@ -113,6 +113,8 @@ static void add_repo(const char *base, struct strbuf *path, repo_config_fn fn)
if (!strcmp(rel.buf + rel.len - 5, "/.git"))
strbuf_setlen(&rel, rel.len - 5);
else if (rel.len && rel.buf[rel.len - 1] == '/')
strbuf_setlen(&rel, rel.len - 1);
repo = cgit_add_repo(rel.buf);
config_fn = fn;