From mboxrd@z Thu Jan 1 00:00:00 1970 From: andy at warmcat.com (Andy Green) Date: Tue, 19 Jun 2018 17:01:56 +0800 Subject: [PATCH v3 06/17] ui-tree: split out buffer printing In-Reply-To: <152939875224.4492.4288866616332837866.stgit@mail.warmcat.com> References: <152939875224.4492.4288866616332837866.stgit@mail.warmcat.com> Message-ID: <152939891694.4492.2768562247201963292.stgit@mail.warmcat.com> From: John Keeping Signed-off-by: John Keeping --- ui-tree.c | 25 +++++++++++++++---------- 1 file 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("\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("
blob size (%ldKB) exceeds display size limit (%dKB).
", + 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("
blob size (%ldKB) exceeds display size limit (%dKB).
", - 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); }