summaryrefslogtreecommitdiffabout
path: root/cgit.c
Unidiff
Diffstat (limited to 'cgit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index 9305d0a..2c3ad73 100644
--- a/cgit.c
+++ b/cgit.c
@@ -403,48 +403,54 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
403 cgit_print_pageheader(ctx); 403 cgit_print_pageheader(ctx);
404 cgit_print_error(fmt("Invalid branch: %s", tmp)); 404 cgit_print_error(fmt("Invalid branch: %s", tmp));
405 cgit_print_docend(); 405 cgit_print_docend();
406 return 1; 406 return 1;
407 } 407 }
408 return 0; 408 return 0;
409} 409}
410 410
411static void process_request(void *cbdata) 411static void process_request(void *cbdata)
412{ 412{
413 struct cgit_context *ctx = cbdata; 413 struct cgit_context *ctx = cbdata;
414 struct cgit_cmd *cmd; 414 struct cgit_cmd *cmd;
415 415
416 cmd = cgit_get_cmd(ctx); 416 cmd = cgit_get_cmd(ctx);
417 if (!cmd) { 417 if (!cmd) {
418 ctx->page.title = "cgit error"; 418 ctx->page.title = "cgit error";
419 cgit_print_http_headers(ctx); 419 cgit_print_http_headers(ctx);
420 cgit_print_docstart(ctx); 420 cgit_print_docstart(ctx);
421 cgit_print_pageheader(ctx); 421 cgit_print_pageheader(ctx);
422 cgit_print_error("Invalid request"); 422 cgit_print_error("Invalid request");
423 cgit_print_docend(); 423 cgit_print_docend();
424 return; 424 return;
425 } 425 }
426 426
427 /* If cmd->want_vpath is set, assume ctx->qry.path contains a "virtual"
428 * in-project path limit to be made available at ctx->qry.vpath.
429 * Otherwise, no path limit is in effect (ctx->qry.vpath = NULL).
430 */
431 ctx->qry.vpath = cmd->want_vpath ? ctx->qry.path : NULL;
432
427 if (cmd->want_repo && !ctx->repo) { 433 if (cmd->want_repo && !ctx->repo) {
428 cgit_print_http_headers(ctx); 434 cgit_print_http_headers(ctx);
429 cgit_print_docstart(ctx); 435 cgit_print_docstart(ctx);
430 cgit_print_pageheader(ctx); 436 cgit_print_pageheader(ctx);
431 cgit_print_error(fmt("No repository selected")); 437 cgit_print_error(fmt("No repository selected"));
432 cgit_print_docend(); 438 cgit_print_docend();
433 return; 439 return;
434 } 440 }
435 441
436 if (ctx->repo && prepare_repo_cmd(ctx)) 442 if (ctx->repo && prepare_repo_cmd(ctx))
437 return; 443 return;
438 444
439 if (cmd->want_layout) { 445 if (cmd->want_layout) {
440 cgit_print_http_headers(ctx); 446 cgit_print_http_headers(ctx);
441 cgit_print_docstart(ctx); 447 cgit_print_docstart(ctx);
442 cgit_print_pageheader(ctx); 448 cgit_print_pageheader(ctx);
443 } 449 }
444 450
445 cmd->fn(ctx); 451 cmd->fn(ctx);
446 452
447 if (cmd->want_layout) 453 if (cmd->want_layout)
448 cgit_print_docend(); 454 cgit_print_docend();
449} 455}
450 456