X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/d01c600c179593a53162a9d4e3040ecfc5078fdc..c1633c6:/ui-plain.c diff --git a/ui-plain.c b/ui-plain.c index 7fecc32..c21d38f 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -147,11 +147,14 @@ static void print_dir_entry(const unsigned char *sha1, const char *base, char *fullpath; fullpath = buildpath(base, baselen, path); - if (!S_ISDIR(mode)) + if (!S_ISDIR(mode) && !S_ISGITLINK(mode)) fullpath[strlen(fullpath) - 1] = 0; html("
  • "); - cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, - fullpath); + if (S_ISGITLINK(mode)) { + cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1)); + } else + cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1, + fullpath); html("
  • \n"); match = 2; } @@ -194,7 +197,14 @@ void cgit_print_plain(struct cgit_context *ctx) const char *rev = ctx->qry.sha1; unsigned char sha1[20]; struct commit *commit; - const char *paths[] = {ctx->qry.path, NULL}; + struct pathspec_item path_items = { + .match = ctx->qry.path, + .len = ctx->qry.path ? strlen(ctx->qry.path) : 0 + }; + struct pathspec paths = { + .nr = 1, + .items = &path_items + }; if (!rev) rev = ctx->qry.head; @@ -208,14 +218,14 @@ void cgit_print_plain(struct cgit_context *ctx) html_status(404, "Not found", 0); return; } - if (!paths[0]) { - paths[0] = ""; + if (!path_items.match) { + path_items.match = ""; match_baselen = -1; print_dir(commit->tree->object.sha1, "", 0, ""); } else - match_baselen = basedir_len(paths[0]); - read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL); + match_baselen = basedir_len(path_items.match); + read_tree_recursive(commit->tree, "", 0, 0, &paths, walk_tree, NULL); if (!match) html_status(404, "Not found", 0); else if (match == 2)