+ char *fullpath;
+
+ fullpath = buildpath(base, baselen, path);
+ if (!S_ISDIR(mode) && !S_ISGITLINK(mode))
+ fullpath[strlen(fullpath) - 1] = 0;
+ html(" <li>");
+ 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("</li>\n");
+ free(fullpath);
+}
+
+static void print_dir_tail(void)
+{
+ html(" </ul>\n</body></html>\n");
+}
+
+static int walk_tree(const unsigned char *sha1, struct strbuf *base,
+ const char *pathname, unsigned mode, int stage, void *cbdata)
+{
+ struct walk_tree_context *walk_tree_ctx = cbdata;
+
+ if (base->len == walk_tree_ctx->match_baselen) {
+ if (S_ISREG(mode) || S_ISLNK(mode)) {
+ if (print_object(sha1, pathname))
+ walk_tree_ctx->match = 1;
+ } else if (S_ISDIR(mode)) {
+ print_dir(sha1, base->buf, base->len, pathname);
+ walk_tree_ctx->match = 2;
+ return READ_TREE_RECURSIVE;
+ }
+ } else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) {
+ print_dir_entry(sha1, base->buf, base->len, pathname, mode);
+ walk_tree_ctx->match = 2;
+ } else if (S_ISDIR(mode)) {