[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgit
Subject:    [RFC/PATCH 4/5] ui-tree: split out buffer printing
From:       John Keeping <john () keeping ! me ! uk>
Date:       2016-09-03 18:29:35
Message-ID: 86191f815e39a8eaecdabc5b718c98b9a1a26a53.1472925431.git.john () keeping ! me ! uk
[Download RAW message or body]

This is a preliminary refactoring for the next commit.

Signed-off-by: John Keeping <john@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

_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic