This is a preliminary refactoring for the next commit.

Signed-off-by: John Keeping <[email protected]>
---
 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

_______________________________________________
CGit mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to