For example, if I have two repos (remove-suffix is enabled):
/foo
/foo/bar
http://cgit/foo/bar/ is interpreted as "repository 'foo', command 'bar'"
instead of "repository 'foo/bar'"
*/
void cgit_parse_url(const char *url)
{
*/
void cgit_parse_url(const char *url)
{
+ char *c, *cmd, *p;
+ struct cgit_repo *repo;
ctx.repo = NULL;
if (!url || url[0] == '\0')
ctx.repo = NULL;
if (!url || url[0] == '\0')
- cmd = strchr(url, '/');
- while (!ctx.repo && cmd) {
- cmd[0] = '\0';
- ctx.repo = cgit_get_repoinfo(url);
- if (ctx.repo == NULL) {
- cmd[0] = '/';
- cmd = strchr(cmd + 1, '/');
- continue;
+ cmd = NULL;
+ c = strchr(url, '/');
+ while (c) {
+ c[0] = '\0';
+ repo = cgit_get_repoinfo(url);
+ if (repo) {
+ ctx.repo = repo;
+ cmd = c;
+ c[0] = '/';
+ c = strchr(c + 1, '/');
+ }
ctx.qry.repo = ctx.repo->url;
p = strchr(cmd + 1, '/');
if (p) {
ctx.qry.repo = ctx.repo->url;
p = strchr(cmd + 1, '/');
if (p) {