aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2018-06-18 14:22:24 +0800
committerAndy Green <andy@warmcat.com>2018-06-29 07:53:20 +0800
commit35a0829577dec45c8239535ebf27d3ffa69affae (patch)
tree3273c02ee4ef1d728704855fd7c42b70713d6134
parentParse render filters from the config (diff)
downloadcgit-35a0829577dec45c8239535ebf27d3ffa69affae.tar.xz
cgit-35a0829577dec45c8239535ebf27d3ffa69affae.zip
ui-tree: split out buffer printing
Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r--ui-tree.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/ui-tree.c b/ui-tree.c
index e6b3074..d26e35e 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -84,6 +84,20 @@ static void print_binary_buffer(char *buf, unsigned long size)
html("</table>\n");
}
+static void print_buffer(const char *basename, char *buf, unsigned long size)
+{
+ 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 void print_object(const struct object_id *oid, char *path, const char *basename, const char *rev)
{
enum object_type type;
@@ -117,16 +131,7 @@ static void print_object(const struct object_id *oid, char *path, const char *ba
}
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);
+ print_buffer(basename, buf, size);
free(buf);
}