diff options
Diffstat (limited to 'source/ui-tree.c')
| -rw-r--r-- | source/ui-tree.c | 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 33 insertions, 53 deletions
diff --git a/source/ui-tree.c b/source/ui-tree.c index 26a3fd1..aab448e 100644 --- a/source/ui-tree.c +++ b/source/ui-tree.c @@ -82,8 +82,7 @@ static void print_linenumbers(const char *buf, unsigned long size) strbuf_release(&numbers); } -static void print_text_buffer(const char *filename, char *buf, - unsigned long size) +static void print_text_buffer(const char *filename, char *buf, unsigned long size) { html("<table class='blob'>\n"); @@ -131,8 +130,7 @@ static void print_binary_buffer(char *buf, unsigned long size) html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>\n"); // A row goes out in one write rather than a write per byte. - for (offset = 0; offset < size; - offset += HEXDUMP_ROW_BYTES, buf += HEXDUMP_ROW_BYTES) { + for (offset = 0; offset < size; offset += HEXDUMP_ROW_BYTES, buf += HEXDUMP_ROW_BYTES) { strbuf_reset(&row); strbuf_addf(&row, "<tr><td class='right'>%04lx</td><td class='hex'>", offset); for (idx = 0; idx < HEXDUMP_ROW_BYTES && offset + idx < size; idx++) { @@ -159,7 +157,7 @@ static void print_binary_buffer(char *buf, unsigned long size) * may be added to it. */ static bool print_object(const struct object_id *oid, const char *path, - const char *filename, const char *rev) + const char *filename, const char *rev) { enum object_type type; char *buf; @@ -168,22 +166,21 @@ static bool print_object(const struct object_id *oid, const char *path, type = odb_read_object_info(the_repository->objects, oid, &size); if (type == OBJ_BAD) { - cgit_print_error_page(404, "Not Found", - "Bad object name: %s", oid_to_hex(oid)); + cgit_print_error_page(404, "Not Found", "Bad object name: %s", oid_to_hex(oid)); return false; } if (ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size) { - cgit_print_error_page(413, "Content Too Large", - "blob size (%luKB) exceeds display size limit (%dKB)", - size / 1024, ctx.cfg.max_blob_size); + cgit_print_error_page( + 413, "Content Too Large", "blob size (%luKB) exceeds display size limit (%dKB)", + size / 1024, ctx.cfg.max_blob_size + ); return false; } buf = odb_read_object(the_repository->objects, oid, &type, &size); if (!buf) { - cgit_print_error_page(500, "Internal Server Error", - "Error reading object %s", oid_to_hex(oid)); + cgit_print_error_page(500, "Internal Server Error", "Error reading object %s", oid_to_hex(oid)); return false; } // buffer_is_binary only sniffs the front of the blob, and a NUL past @@ -195,12 +192,10 @@ static bool print_object(const struct object_id *oid, const char *path, cgit_print_layout_start(); htmlf("blob: %s (", oid_to_hex(oid)); - cgit_plain_link("plain", NULL, NULL, ctx.qry.head, - rev, path); + cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); if (ctx.repo->enable_blame && !is_binary) { html(") ("); - cgit_blame_link("blame", NULL, NULL, ctx.qry.head, - rev, path); + cgit_blame_link("blame", NULL, NULL, ctx.qry.head, rev, path); } html(")\n"); @@ -214,7 +209,7 @@ static bool print_object(const struct object_id *oid, const char *path, } static int only_child_cb(const struct object_id *oid, struct strbuf *base, - const char *pathname, unsigned mode, void *data) + const char *pathname, unsigned mode, void *data) { struct only_child *child = data; @@ -232,8 +227,8 @@ static int only_child_cb(const struct object_id *oid, struct strbuf *base, return 0; } -static void print_dir_chain(const struct object_id *oid, char *name, - char *rev, struct strbuf *fullpath) +static void print_dir_chain(const struct object_id *oid, char *name, char *rev, + struct strbuf *fullpath) { size_t initial_length = fullpath->len; struct tree *tree; @@ -248,8 +243,7 @@ static void print_dir_chain(const struct object_id *oid, char *name, oidcpy(&child.oid, oid); while (child.count == 1) { - cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, - fullpath->buf); + cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, rev, fullpath->buf); tree = lookup_tree(the_repository, &child.oid); if (!tree) @@ -272,7 +266,7 @@ static void print_dir_chain(const struct object_id *oid, char *name, } static void print_ls_row(const struct object_id *oid, const char *pathname, - unsigned mode, struct walk_tree_context *walk) + unsigned mode, struct walk_tree_context *walk) { char *name; struct strbuf fullpath = STRBUF_INIT; @@ -283,8 +277,7 @@ static void print_ls_row(const struct object_id *oid, const char *pathname, char *buf; name = xstrdup(pathname); - strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "", - ctx.qry.path ? "/" : "", name); + strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "", ctx.qry.path ? "/" : "", name); if (!S_ISGITLINK(mode)) { type = odb_read_object_info(the_repository->objects, oid, &size); @@ -310,8 +303,7 @@ static void print_ls_row(const struct object_id *oid, const char *pathname, strbuf_addstr(&class, "ls-blob"); if (ext) strbuf_addf(&class, " %s", ext + 1); - cgit_tree_link(name, NULL, class.buf, ctx.qry.head, - walk->rev, fullpath.buf); + cgit_tree_link(name, NULL, class.buf, ctx.qry.head, walk->rev, fullpath.buf); } if (S_ISLNK(mode)) { html(" -> "); @@ -323,8 +315,7 @@ static void print_ls_row(const struct object_id *oid, const char *pathname, strbuf_addbuf(&linkpath, &fullpath); strbuf_addf(&linkpath, "/../%s", buf); strbuf_normalize_path(&linkpath); - cgit_tree_link(buf, NULL, class.buf, ctx.qry.head, - walk->rev, linkpath.buf); + cgit_tree_link(buf, NULL, class.buf, ctx.qry.head, walk->rev, linkpath.buf); free(buf); strbuf_release(&linkpath); } @@ -334,18 +325,14 @@ static void print_ls_row(const struct object_id *oid, const char *pathname, htmlf("</td><td class='ls-size'>%lu</td>", size); html("<td class='ls-links'>"); - cgit_log_link("log", NULL, "button", ctx.qry.head, - walk->rev, fullpath.buf, 0, NULL, NULL, - ctx.qry.showmsg, 0); + cgit_log_link("log", NULL, "button", ctx.qry.head, walk->rev, fullpath.buf, + 0, NULL, NULL, ctx.qry.showmsg, 0); if (ctx.repo->max_stats) - cgit_stats_link("stats", NULL, "button", ctx.qry.head, - fullpath.buf); + cgit_stats_link("stats", NULL, "button", ctx.qry.head, fullpath.buf); if (!S_ISGITLINK(mode)) - cgit_plain_link("plain", NULL, "button", ctx.qry.head, - walk->rev, fullpath.buf); + cgit_plain_link("plain", NULL, "button", ctx.qry.head, walk->rev, fullpath.buf); if (!S_ISDIR(mode) && !S_ISGITLINK(mode) && ctx.repo->enable_blame) - cgit_blame_link("blame", NULL, "button", ctx.qry.head, - walk->rev, fullpath.buf); + cgit_blame_link("blame", NULL, "button", ctx.qry.head, walk->rev, fullpath.buf); html("</td></tr>\n"); cleanup: @@ -355,7 +342,7 @@ cleanup: } static int ls_item(const struct object_id *oid, struct strbuf *base, - const char *pathname, unsigned mode, void *data) + const char *pathname, unsigned mode, void *data) { struct walk_tree_context *walk = data; @@ -364,8 +351,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, if (ctx.cfg.enable_tree_group_dirs) { struct ls_entry *entry; - ALLOC_GROW(walk->entries, walk->entries_nr + 1, - walk->entries_alloc); + ALLOC_GROW(walk->entries, walk->entries_nr + 1, walk->entries_alloc); entry = &walk->entries[walk->entries_nr++]; oidcpy(&entry->oid, oid); entry->name = xstrdup(pathname); @@ -419,8 +405,7 @@ static void ls_tail(void) cgit_print_layout_end(); } -static void ls_tree(const struct object_id *oid, - struct walk_tree_context *walk) +static void ls_tree(const struct object_id *oid, struct walk_tree_context *walk) { struct tree *tree; struct pathspec paths = { @@ -429,8 +414,7 @@ static void ls_tree(const struct object_id *oid, tree = parse_tree_indirect(oid); if (!tree) { - cgit_print_error_page(404, "Not Found", - "Not a tree object: %s", oid_to_hex(oid)); + cgit_print_error_page(404, "Not Found", "Not a tree object: %s", oid_to_hex(oid)); return; } @@ -441,7 +425,7 @@ static void ls_tree(const struct object_id *oid, } static int walk_tree(const struct object_id *oid, struct strbuf *base, - const char *pathname, unsigned mode, void *data) + const char *pathname, unsigned mode, void *data) { struct walk_tree_context *walk = data; @@ -460,8 +444,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, ls_head(); return READ_TREE_RECURSIVE; } else { - bool shown = print_object(oid, fullpath.buf, - pathname, walk->rev); + bool shown = print_object(oid, fullpath.buf, pathname, walk->rev); walk->state = shown ? WALK_BLOB_SHOWN : WALK_ERROR_SHOWN; strbuf_release(&fullpath); @@ -499,14 +482,12 @@ void cgit_print_tree(const char *rev, char *path) rev = ctx.qry.head; if (repo_get_oid(the_repository, rev, &oid)) { - cgit_print_error_page(404, "Not Found", - "Invalid revision name: %s", rev); + cgit_print_error_page(404, "Not Found", "Invalid revision name: %s", rev); return; } commit = lookup_commit_reference(the_repository, &oid); if (!commit || repo_parse_commit(the_repository, commit)) { - cgit_print_error_page(404, "Not Found", - "Invalid commit reference: %s", rev); + cgit_print_error_page(404, "Not Found", "Invalid commit reference: %s", rev); return; } @@ -517,8 +498,7 @@ void cgit_print_tree(const char *rev, char *path) goto cleanup; } - read_tree(the_repository, repo_get_commit_tree(the_repository, commit), - &paths, walk_tree, &walk); + read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk); if (walk.state == WALK_LISTING) { ls_flush(&walk); ls_tail(); |
