[PATCH] Return "404 Not found" if a repo doesn't exist (any more).

Jason A. Donenfeld Jason at zx2c4.com
Fri Feb 1 12:58:25 CET 2013


On Sat, Dec 1, 2012 at 11:02 PM, Adam Sjøgren <asjo at koldfront.dk> wrote:
> @@ -247,6 +247,17 @@ void cgit_print_repolist()
>         if (ctx.cfg.enable_index_links)
>                 columns++;
>
> +       for (i=0; i<cgit_repolist.count; i++) {
> +               if (!(is_match(&cgit_repolist.repos[i]) && is_in_url(&cgit_repolist.repos[i])))
> +                       continue;
> +               hits++;
> +        }
> +
> +       if (!hits) {
> +                ctx.page.status = 404;
> +                ctx.page.statusmsg = "Not found";
> +        }
> +

I like the idea of this, but I hate to duplicate the loop logic like that.

But in fact we do need to know whether there are any hits before
sending headers.

Tricky. I'll see if I can refactor things to be a bit nicer.




More information about the CGit mailing list