summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2018-06-13 10:01:50 +0800
committerChristian Hesse <mail@eworm.de>2018-06-13 10:32:44 +0200
commitc8b8ac20643f64cc4db29907dbb9804561c3316c (patch)
treee64821c131a94e8246ecf3fdb7cab19f02dec2d3
parent76d5db9b21e1666e46c0fe9ad2842059025cd493 (diff)
downloadcgit-c8b8ac20643f64cc4db29907dbb9804561c3316c.tar.gz
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 67fd1bc..009e201 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 unsigned char *sha1, char *path, const char *basename, const char *rev)
{
enum object_type type;
@@ -117,16 +131,7 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
}
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);
}
struct single_tree_ctx {