[RFC/PATCH 4/5] ui-tree: split out buffer printing
John Keeping
john at keeping.me.uk
Sat Sep 3 20:29:35 CEST 2016
This is a preliminary refactoring for the next commit.
Signed-off-by: John Keeping <john at keeping.me.uk>
---
ui-tree.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/ui-tree.c b/ui-tree.c
index 120066c..5c715a1 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -115,7 +115,22 @@ static void set_title_from_path(const char *path)
ctx.page.title = new_title;
}
-static void print_object(const unsigned char *sha1, char *path, const char *basename, const char *rev)
+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;
char *buf;
@@ -143,16 +158,7 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
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);
+ print_buffer(basename, buf, size);
}
--
2.10.0.rc0.142.g1e9f63b
More information about the CGit
mailing list