Signed-off-by: Kumar Appaiah <a.ku...@alumni.iitm.ac.in>
---
 include/tig/diff.h |  1 +
 src/diff.c         | 27 ++++++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/include/tig/diff.h b/include/tig/diff.h
index be325c4..ba40386 100644
--- a/include/tig/diff.h
+++ b/include/tig/diff.h
@@ -27,6 +27,7 @@ enum request diff_common_edit(struct view *view, enum request 
request, struct li
 bool diff_common_read(struct view *view, const char *data, struct diff_state 
*state);
 bool diff_common_draw(struct view *view, struct line *line, unsigned int 
lineno);
 enum request diff_common_enter(struct view *view, enum request request, struct 
line *line);
+bool diff_common_add_diff_stat(struct view *view, const char *data);
 
 unsigned int diff_get_lineno(struct view *view, struct line *line);
 const char *diff_get_pathname(struct view *view, struct line *line);
diff --git a/src/diff.c b/src/diff.c
index 4b30068..1daf8fa 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -38,6 +38,21 @@ diff_open(struct view *view, enum open_flags flags)
 }
 
 bool
+diff_common_add_diff_stat(struct view *view, const char *data)
+{
+       size_t len = strlen(data);
+       char *pipe = strchr(data, '|');
+       bool has_histogram = data[len - 1] == '-' || data[len - 1] == '+';
+       bool has_bin_diff = pipe && strstr(pipe, "Bin") && strstr(pipe, "->");
+       bool has_rename = data[len - 1] == '0' && (strstr(data, "=>") || 
!strncmp(data, " ...", 4));
+       bool has_no_change = pipe && strstr(pipe, " 0");
+
+       if (pipe && (has_histogram || has_bin_diff || has_rename || 
has_no_change))
+               return add_line_text(view, data, LINE_DIFF_STAT) != NULL;
+       return FALSE;
+}
+
+bool
 diff_common_read(struct view *view, const char *data, struct diff_state *state)
 {
        enum line_type type = get_line_type(data);
@@ -49,15 +64,9 @@ diff_common_read(struct view *view, const char *data, struct 
diff_state *state)
                state->reading_diff_stat = TRUE;
 
        if (state->reading_diff_stat) {
-               size_t len = strlen(data);
-               char *pipe = strchr(data, '|');
-               bool has_histogram = data[len - 1] == '-' || data[len - 1] == 
'+';
-               bool has_bin_diff = pipe && strstr(pipe, "Bin") && strstr(pipe, 
"->");
-               bool has_rename = data[len - 1] == '0' && (strstr(data, "=>") 
|| !strncmp(data, " ...", 4));
-               bool has_no_change = pipe && strstr(pipe, " 0");
-
-               if (pipe && (has_histogram || has_bin_diff || has_rename || 
has_no_change)) {
-                       return add_line_text(view, data, LINE_DIFF_STAT) != 
NULL;
+               bool ret = diff_common_add_diff_stat(view, data);
+               if (ret) {
+                       return TRUE;
                } else {
                        state->reading_diff_stat = FALSE;
                }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to