diff --git a/cmd.c b/cmd.c index 5a3d157..9a040a2 100644 --- a/cmd.c +++ b/cmd.c @@ -127,7 +127,10 @@ static void tag_fn(struct cgit_context *ctx) static void tree_fn(struct cgit_context *ctx) { - cgit_print_tree(ctx->qry.sha1, ctx->qry.path); + if (ctx->qry.grep) + cgit_grep(ctx->qry.sha1, ctx->qry.path, ctx->qry.grep); + else + cgit_print_tree(ctx->qry.sha1, ctx->qry.path); } #define def_cmd(name, want_repo, want_layout, want_vpath, is_clone) \ diff --git a/ui-shared.c b/ui-shared.c index 43166af..026c2cb 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -246,6 +246,61 @@ static char *repolink(const char *title, const char *class, const char *page, return fmt("%s", delim); } +static char *repolink2(const char *title, const char *class, const char *page, + const char *head, const char *path, int lineno) +{ + char *delim = "?"; + + html("url); + if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') + html("/"); + if (page) { + html_url_path(page); + html("/"); + if (path) + html_url_path(path); + } + } else { + html(ctx.cfg.script_name); + html("?url="); + html_url_arg(ctx.repo->url); + if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') + html("/"); + if (page) { + html_url_arg(page); + html("/"); + if (path) + html_url_arg(path); + } + delim = "&"; + } + if (head && strcmp(head, ctx.repo->defbranch)) { + html(delim); + html("h="); + html_url_arg(head); + delim = "&"; + } + if (lineno) + htmlf("#n%d", lineno); + return fmt("%s", delim); +} + static void reporevlink(const char *page, const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) @@ -263,6 +318,23 @@ static void reporevlink(const char *page, const char *name, const char *title, html(""); } +static void reporevlink2(const char *page, const char *name, const char *title, + const char *class, const char *head, const char *rev, + const char *path, int lineno) +{ + char *delim; + + delim = repolink2(title, class, page, head, path, lineno); + if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) { + html(delim); + html("id="); + html_url_arg(rev); + } + html("'>"); + html_txt(name); + html(""); +} + void cgit_summary_link(const char *name, const char *title, const char *class, const char *head) { @@ -281,6 +353,13 @@ void cgit_tree_link(const char *name, const char *title, const char *class, reporevlink("tree", name, title, class, head, rev, path); } +void cgit_tree_link2(const char *name, const char *title, const char *class, + const char *head, const char *rev, const char *path, + int lineno) +{ + reporevlink2("tree", name, title, class, head, rev, path, lineno); +} + void cgit_plain_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) { @@ -875,6 +954,9 @@ static void print_header(struct cgit_context *ctx) void cgit_print_pageheader(struct cgit_context *ctx) { + int tree; + char *page; + html("