- fullpath = "/";
- ctx.page.etag = sha1_to_hex(sha1);
- cgit_print_http_headers(&ctx);
- htmlf("<html><head><title>%s</title></head>\n<body>\n"
- " <h2>%s</h2>\n <ul>\n", fullpath, fullpath);
- if (path[0] || base[0])
- html(" <li><a href=\"../\">../</a></li>\n");
- match = 2;
+ return fmtalloc("%.*s/", baselen, base);
+}
+
+static void print_dir(const struct object_id *oid, const char *base,
+ int baselen, const char *path)
+{
+ char *fullpath, *slash;
+ size_t len;
+
+ fullpath = buildpath(base, baselen, path);
+ slash = (fullpath[0] == '/' ? "" : "/");
+ ctx.page.etag = oid_to_hex(oid);
+ cgit_print_http_headers();
+ htmlf("<html><head><title>%s", slash);
+ html_txt(fullpath);
+ htmlf("</title></head>\n<body>\n<h2>%s", slash);
+ html_txt(fullpath);
+ html("</h2>\n<ul>\n");
+ len = strlen(fullpath);
+ if (len > 1) {
+ fullpath[len - 1] = 0;
+ slash = strrchr(fullpath, '/');
+ if (slash)
+ *(slash + 1) = 0;
+ else {
+ free(fullpath);
+ fullpath = NULL;
+ }
+ html("<li>");
+ cgit_plain_link("../", NULL, NULL, ctx.qry.head, ctx.qry.oid,
+ fullpath);
+ html("</li>\n");
+ }
+ free(fullpath);