+
+ buf = read_sha1_file(sha1, &type, &size);
+ if (!buf) {
+ cgit_print_error_page(500, "Internal server error",
+ "Error reading object %s", sha1_to_hex(sha1));
+ return;
+ }
+
+ cgit_print_layout_start();
+ htmlf("blob: %s (", sha1_to_hex(sha1));
+ cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
+ rev, path);
+ html(")\n");
+
+ if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) {
+ htmlf("<div class='error'>blob size (%ldKB) exceeds display size limit (%dKB).</div>",
+ size / 1024, ctx.cfg.max_blob_size);
+ return;
+ }
+
+ if (buffer_is_binary(buf, size))
+ print_binary_buffer(buf, size);
+ else
+ print_text_buffer(basename, buf, size);
+}
+
+
+static int ls_item(const unsigned char *sha1, struct strbuf *base,
+ const char *pathname, unsigned mode, int stage, void *cbdata)
+{
+ struct walk_tree_context *walk_tree_ctx = cbdata;
+ char *name;
+ struct strbuf fullpath = STRBUF_INIT;
+ struct strbuf class = STRBUF_INIT;
+ enum object_type type;
+ unsigned long size = 0;
+
+ name = xstrdup(pathname);
+ strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "",
+ ctx.qry.path ? "/" : "", name);
+
+ if (!S_ISGITLINK(mode)) {
+ type = sha1_object_info(sha1, &size);
+ if (type == OBJ_BAD) {
+ htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
+ name,
+ sha1_to_hex(sha1));
+ free(name);
+ return 0;
+ }
+ }
+
+ html("<tr><td class='ls-mode'>");
+ cgit_print_filemode(mode);