{"thread":{"id":"36390","subject":"[tig] [PATCH 0/3] log: colour the diffstat.","startedAt":"2014-04-11T12:20:02Z","lastAt":"2014-04-17T01:04:54Z","messageCount":11,"participants":["Kumar Appaiah","Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"238686","messageId":"1397218805-2560-1-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":null,"subject":"[tig] [PATCH 0/3] log: colour the diffstat.","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-11T12:20:02Z","receivedAt":"2014-04-11T12:20:02Z","isPatch":true,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"These patches add colourization to the log view. They reuse the diff\nstat drawing functions from the diff module directly.\n\nKumar Appaiah (3):\n  diff: Move diff stat addition to a common function\n  diff: Move diff stat drawing to a common function\n  log: Colour the diff stat\n\n include/tig/diff.h |  2 ++\n src/diff.c         | 57 +++++++++++++++++++++++++++++++------------------\n src/log.c          | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 3 files changed, 98 insertions(+), 23 deletions(-)\n\n-- \n1.9.1\n"},{"id":"238687","messageId":"1397218805-2560-2-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397218805-2560-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCH 1/3] diff: Move diff stat addition to a common function","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-11T12:20:03Z","receivedAt":"2014-04-11T12:20:03Z","isPatch":true,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"Signed-off-by: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>\n---\n include/tig/diff.h |  1 +\n src/diff.c         | 27 ++++++++++++++++++---------\n 2 files changed, 19 insertions(+), 9 deletions(-)\n\ndiff --git a/include/tig/diff.h b/include/tig/diff.h\nindex be325c4..ba40386 100644\n--- a/include/tig/diff.h\n+++ b/include/tig/diff.h\n@@ -27,6 +27,7 @@ enum request diff_common_edit(struct view *view, enum request request, struct li\n bool diff_common_read(struct view *view, const char *data, struct diff_state *state);\n bool diff_common_draw(struct view *view, struct line *line, unsigned int lineno);\n enum request diff_common_enter(struct view *view, enum request request, struct line *line);\n+bool diff_common_add_diff_stat(struct view *view, const char *data);\n \n unsigned int diff_get_lineno(struct view *view, struct line *line);\n const char *diff_get_pathname(struct view *view, struct line *line);\ndiff --git a/src/diff.c b/src/diff.c\nindex 4b30068..1daf8fa 100644\n--- a/src/diff.c\n+++ b/src/diff.c\n@@ -38,6 +38,21 @@ diff_open(struct view *view, enum open_flags flags)\n }\n \n bool\n+diff_common_add_diff_stat(struct view *view, const char *data)\n+{\n+\tsize_t len = strlen(data);\n+\tchar *pipe = strchr(data, '|');\n+\tbool has_histogram = data[len - 1] == '-' || data[len - 1] == '+';\n+\tbool has_bin_diff = pipe && strstr(pipe, \"Bin\") && strstr(pipe, \"->\");\n+\tbool has_rename = data[len - 1] == '0' && (strstr(data, \"=>\") || !strncmp(data, \" ...\", 4));\n+\tbool has_no_change = pipe && strstr(pipe, \" 0\");\n+\n+\tif (pipe && (has_histogram || has_bin_diff || has_rename || has_no_change))\n+\t\treturn add_line_text(view, data, LINE_DIFF_STAT) != NULL;\n+\treturn FALSE;\n+}\n+\n+bool\n diff_common_read(struct view *view, const char *data, struct diff_state *state)\n {\n \tenum line_type type = get_line_type(data);\n@@ -49,15 +64,9 @@ diff_common_read(struct view *view, const char *data, struct diff_state *state)\n \t\tstate->reading_diff_stat = TRUE;\n \n \tif (state->reading_diff_stat) {\n-\t\tsize_t len = strlen(data);\n-\t\tchar *pipe = strchr(data, '|');\n-\t\tbool has_histogram = data[len - 1] == '-' || data[len - 1] == '+';\n-\t\tbool has_bin_diff = pipe && strstr(pipe, \"Bin\") && strstr(pipe, \"->\");\n-\t\tbool has_rename = data[len - 1] == '0' && (strstr(data, \"=>\") || !strncmp(data, \" ...\", 4));\n-\t\tbool has_no_change = pipe && strstr(pipe, \" 0\");\n-\n-\t\tif (pipe && (has_histogram || has_bin_diff || has_rename || has_no_change)) {\n-\t\t\treturn add_line_text(view, data, LINE_DIFF_STAT) != NULL;\n+\t\tbool ret = diff_common_add_diff_stat(view, data);\n+\t\tif (ret) {\n+\t\t\treturn TRUE;\n \t\t} else {\n \t\t\tstate->reading_diff_stat = FALSE;\n \t\t}\n-- \n1.9.1\n"},{"id":"238689","messageId":"1397218805-2560-3-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397218805-2560-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCH 2/3] diff: Move diff stat drawing to a common function","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-11T12:20:04Z","receivedAt":"2014-04-11T12:20:04Z","isPatch":true,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"Signed-off-by: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>\n---\n include/tig/diff.h |  1 +\n src/diff.c         | 30 ++++++++++++++++++------------\n 2 files changed, 19 insertions(+), 12 deletions(-)\n\ndiff --git a/include/tig/diff.h b/include/tig/diff.h\nindex ba40386..16299fe 100644\n--- a/include/tig/diff.h\n+++ b/include/tig/diff.h\n@@ -28,6 +28,7 @@ bool diff_common_read(struct view *view, const char *data, struct diff_state *st\n bool diff_common_draw(struct view *view, struct line *line, unsigned int lineno);\n enum request diff_common_enter(struct view *view, enum request request, struct line *line);\n bool diff_common_add_diff_stat(struct view *view, const char *data);\n+void diff_common_draw_diff_stat(struct view *view, enum line_type *type, char **text);\n \n unsigned int diff_get_lineno(struct view *view, struct line *line);\n const char *diff_get_pathname(struct view *view, struct line *line);\ndiff --git a/src/diff.c b/src/diff.c\nindex 1daf8fa..b204bab 100644\n--- a/src/diff.c\n+++ b/src/diff.c\n@@ -167,6 +167,23 @@ diff_common_draw_part(struct view *view, enum line_type *type, char **text, char\n \treturn sep != NULL;\n }\n \n+void\n+diff_common_draw_diff_stat(struct view *view, enum line_type *type, char **text)\n+{\n+\t\tdiff_common_draw_part(view, type, text, '|', LINE_DEFAULT);\n+\t\tif (diff_common_draw_part(view, type, text, 'B', LINE_DEFAULT)) {\n+\t\t\t/* Handle binary diffstat: Bin <deleted> -> <added> bytes */\n+\t\t\tdiff_common_draw_part(view, type, text, ' ', LINE_DIFF_DEL);\n+\t\t\tdiff_common_draw_part(view, type, text, '-', LINE_DEFAULT);\n+\t\t\tdiff_common_draw_part(view, type, text, ' ', LINE_DIFF_ADD);\n+\t\t\tdiff_common_draw_part(view, type, text, 'b', LINE_DEFAULT);\n+\n+\t\t} else {\n+\t\t\tdiff_common_draw_part(view, type, text, '+', LINE_DIFF_ADD);\n+\t\t\tdiff_common_draw_part(view, type, text, '-', LINE_DIFF_DEL);\n+\t\t}\n+}\n+\n bool\n diff_common_draw(struct view *view, struct line *line, unsigned int lineno)\n {\n@@ -180,18 +197,7 @@ diff_common_draw(struct view *view, struct line *line, unsigned int lineno)\n \t\treturn TRUE;\n \n \tif (type == LINE_DIFF_STAT) {\n-\t\tdiff_common_draw_part(view, &type, &text, '|', LINE_DEFAULT);\n-\t\tif (diff_common_draw_part(view, &type, &text, 'B', LINE_DEFAULT)) {\n-\t\t\t/* Handle binary diffstat: Bin <deleted> -> <added> bytes */\n-\t\t\tdiff_common_draw_part(view, &type, &text, ' ', LINE_DIFF_DEL);\n-\t\t\tdiff_common_draw_part(view, &type, &text, '-', LINE_DEFAULT);\n-\t\t\tdiff_common_draw_part(view, &type, &text, ' ', LINE_DIFF_ADD);\n-\t\t\tdiff_common_draw_part(view, &type, &text, 'b', LINE_DEFAULT);\n-\n-\t\t} else {\n-\t\t\tdiff_common_draw_part(view, &type, &text, '+', LINE_DIFF_ADD);\n-\t\t\tdiff_common_draw_part(view, &type, &text, '-', LINE_DIFF_DEL);\n-\t\t}\n+\t\tdiff_common_draw_diff_stat(view, &type, &text);\n \t}\n \n \tif (line->user_flags & DIFF_LINE_COMMIT_TITLE)\n-- \n1.9.1\n"},{"id":"238688","messageId":"1397218805-2560-4-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397218805-2560-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCH 3/3] log: Colour the diff stat","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-11T12:20:05Z","receivedAt":"2014-04-11T12:20:05Z","isPatch":true,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"This commit adds custom log_read and log_draw functions that utilize\nthe diff stat drawing functions from the diff module. The absence of\nthe triple hyphen separator prevents direct usage of the diff drawing\nfunctions directly.\n\nSigned-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>\n---\n src/log.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 60 insertions(+), 2 deletions(-)\n\ndiff --git a/src/log.c b/src/log.c\nindex eef61dc..e6f2a82 100644\n--- a/src/log.c\n+++ b/src/log.c\n@@ -23,6 +23,9 @@ struct log_state {\n \t * up/down in the log view. */\n \tint last_lineno;\n \tenum line_type last_type;\n+\tbool commit_title_read;\n+\tbool after_commit_header;\n+\tbool reading_diff_stat;\n };\n \n static void\n@@ -76,14 +79,69 @@ log_request(struct view *view, enum request request, struct line *line)\n \t}\n }\n \n+static bool\n+log_read(struct view *view, char *data)\n+{\n+\tenum line_type type;\n+\tstruct log_state *state = view->private;\n+\tsize_t len;\n+\n+\tif (!data)\n+\t\treturn TRUE;\n+\n+\ttype = get_line_type(data);\n+\n+\tlen = strlen(data);\n+\n+\tif (type == LINE_COMMIT)\n+\t\tstate->commit_title_read = TRUE;\n+\telse if (state->commit_title_read && len < 1) {\n+\t\tstate->commit_title_read = FALSE;\n+\t\tstate->after_commit_header = TRUE;\n+\t} else if (state->after_commit_header && len < 1) {\n+\t\tstate->after_commit_header = FALSE;\n+\t\tstate->reading_diff_stat = TRUE;\n+\t} else if (state->reading_diff_stat) {\n+\t\tbool ret = diff_common_add_diff_stat(view, data);\n+\t\tif (ret) {\n+\t\t\treturn TRUE;\n+\t\t} else {\n+\t\t\tstate->reading_diff_stat = FALSE;\n+\t\t}\n+\t}\n+\n+\treturn pager_common_read(view, data, type);\n+}\n+\n+static bool\n+log_draw(struct view *view, struct line *line, unsigned int lineno)\n+{\n+\tchar *text = line->data;\n+\tenum line_type type = line->type;\n+\n+\tif (draw_lineno(view, lineno))\n+\t\treturn TRUE;\n+\n+\tif (line->wrapped && draw_text(view, LINE_DELIMITER, \"+\"))\n+\t\treturn TRUE;\n+\n+\tif (type == LINE_DIFF_STAT) {\n+\t\tdiff_common_draw_diff_stat(view, &type, &text);\n+\t\tdraw_text(view, type, text);\n+\t\treturn TRUE;\n+\t}\n+\n+\treturn pager_draw(view, line, lineno);\n+}\n+\n static struct view_ops log_ops = {\n \t\"line\",\n \targv_env.head,\n \tVIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER | VIEW_LOG_LIKE | VIEW_REFRESH,\n \tsizeof(struct log_state),\n \tlog_open,\n-\tpager_read,\n-\tpager_draw,\n+\tlog_read,\n+\tlog_draw,\n \tlog_request,\n \tpager_grep,\n \tlog_select,\n-- \n1.9.1\n"},{"id":"238816","messageId":"1397426068-17439-1-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397218805-2560-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCHv2 0/3] log: colour the diffstat","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-13T21:54:25Z","receivedAt":"2014-04-13T21:54:25Z","isPatch":false,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"These patches add colourization to the log view. They reuse the diff\nstat drawing functions from the diff module directly.\n\nThis version just includes some code reformatting and minor\nfixes. Please comment on what other fixes could help.\n\nThanks.\n\nKumar Appaiah (3):\n  diff: Move diff stat addition to a common function\n  diff: Move diff stat drawing to a common function\n  log: Colour the diff stat\n\n include/tig/diff.h |  2 ++\n src/diff.c         | 57 ++++++++++++++++++++++++++++++++++--------------------\n src/log.c          | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++--\n 3 files changed, 91 insertions(+), 23 deletions(-)\n\n-- \n1.9.1\n"},{"id":"238814","messageId":"1397426068-17439-2-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397426068-17439-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCHv2 1/3] diff: Move diff stat addition to a common function","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-13T21:54:26Z","receivedAt":"2014-04-13T21:54:26Z","isPatch":false,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"Signed-off-by: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>\n---\n include/tig/diff.h |  1 +\n src/diff.c         | 27 ++++++++++++++++++---------\n 2 files changed, 19 insertions(+), 9 deletions(-)\n\ndiff --git a/include/tig/diff.h b/include/tig/diff.h\nindex be325c4..ba40386 100644\n--- a/include/tig/diff.h\n+++ b/include/tig/diff.h\n@@ -27,6 +27,7 @@ enum request diff_common_edit(struct view *view, enum request request, struct li\n bool diff_common_read(struct view *view, const char *data, struct diff_state *state);\n bool diff_common_draw(struct view *view, struct line *line, unsigned int lineno);\n enum request diff_common_enter(struct view *view, enum request request, struct line *line);\n+bool diff_common_add_diff_stat(struct view *view, const char *data);\n \n unsigned int diff_get_lineno(struct view *view, struct line *line);\n const char *diff_get_pathname(struct view *view, struct line *line);\ndiff --git a/src/diff.c b/src/diff.c\nindex 4b30068..1daf8fa 100644\n--- a/src/diff.c\n+++ b/src/diff.c\n@@ -38,6 +38,21 @@ diff_open(struct view *view, enum open_flags flags)\n }\n \n bool\n+diff_common_add_diff_stat(struct view *view, const char *data)\n+{\n+\tsize_t len = strlen(data);\n+\tchar *pipe = strchr(data, '|');\n+\tbool has_histogram = data[len - 1] == '-' || data[len - 1] == '+';\n+\tbool has_bin_diff = pipe && strstr(pipe, \"Bin\") && strstr(pipe, \"->\");\n+\tbool has_rename = data[len - 1] == '0' && (strstr(data, \"=>\") || !strncmp(data, \" ...\", 4));\n+\tbool has_no_change = pipe && strstr(pipe, \" 0\");\n+\n+\tif (pipe && (has_histogram || has_bin_diff || has_rename || has_no_change))\n+\t\treturn add_line_text(view, data, LINE_DIFF_STAT) != NULL;\n+\treturn FALSE;\n+}\n+\n+bool\n diff_common_read(struct view *view, const char *data, struct diff_state *state)\n {\n \tenum line_type type = get_line_type(data);\n@@ -49,15 +64,9 @@ diff_common_read(struct view *view, const char *data, struct diff_state *state)\n \t\tstate->reading_diff_stat = TRUE;\n \n \tif (state->reading_diff_stat) {\n-\t\tsize_t len = strlen(data);\n-\t\tchar *pipe = strchr(data, '|');\n-\t\tbool has_histogram = data[len - 1] == '-' || data[len - 1] == '+';\n-\t\tbool has_bin_diff = pipe && strstr(pipe, \"Bin\") && strstr(pipe, \"->\");\n-\t\tbool has_rename = data[len - 1] == '0' && (strstr(data, \"=>\") || !strncmp(data, \" ...\", 4));\n-\t\tbool has_no_change = pipe && strstr(pipe, \" 0\");\n-\n-\t\tif (pipe && (has_histogram || has_bin_diff || has_rename || has_no_change)) {\n-\t\t\treturn add_line_text(view, data, LINE_DIFF_STAT) != NULL;\n+\t\tbool ret = diff_common_add_diff_stat(view, data);\n+\t\tif (ret) {\n+\t\t\treturn TRUE;\n \t\t} else {\n \t\t\tstate->reading_diff_stat = FALSE;\n \t\t}\n-- \n1.9.1\n"},{"id":"238815","messageId":"1397426068-17439-3-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397426068-17439-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCHv2 2/3] diff: Move diff stat drawing to a common function","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-13T21:54:27Z","receivedAt":"2014-04-13T21:54:27Z","isPatch":false,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"Signed-off-by: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>\n---\n include/tig/diff.h |  1 +\n src/diff.c         | 30 ++++++++++++++++++------------\n 2 files changed, 19 insertions(+), 12 deletions(-)\n\ndiff --git a/include/tig/diff.h b/include/tig/diff.h\nindex ba40386..16299fe 100644\n--- a/include/tig/diff.h\n+++ b/include/tig/diff.h\n@@ -28,6 +28,7 @@ bool diff_common_read(struct view *view, const char *data, struct diff_state *st\n bool diff_common_draw(struct view *view, struct line *line, unsigned int lineno);\n enum request diff_common_enter(struct view *view, enum request request, struct line *line);\n bool diff_common_add_diff_stat(struct view *view, const char *data);\n+void diff_common_draw_diff_stat(struct view *view, enum line_type *type, char **text);\n \n unsigned int diff_get_lineno(struct view *view, struct line *line);\n const char *diff_get_pathname(struct view *view, struct line *line);\ndiff --git a/src/diff.c b/src/diff.c\nindex 1daf8fa..b204bab 100644\n--- a/src/diff.c\n+++ b/src/diff.c\n@@ -167,6 +167,23 @@ diff_common_draw_part(struct view *view, enum line_type *type, char **text, char\n \treturn sep != NULL;\n }\n \n+void\n+diff_common_draw_diff_stat(struct view *view, enum line_type *type, char **text)\n+{\n+\t\tdiff_common_draw_part(view, type, text, '|', LINE_DEFAULT);\n+\t\tif (diff_common_draw_part(view, type, text, 'B', LINE_DEFAULT)) {\n+\t\t\t/* Handle binary diffstat: Bin <deleted> -> <added> bytes */\n+\t\t\tdiff_common_draw_part(view, type, text, ' ', LINE_DIFF_DEL);\n+\t\t\tdiff_common_draw_part(view, type, text, '-', LINE_DEFAULT);\n+\t\t\tdiff_common_draw_part(view, type, text, ' ', LINE_DIFF_ADD);\n+\t\t\tdiff_common_draw_part(view, type, text, 'b', LINE_DEFAULT);\n+\n+\t\t} else {\n+\t\t\tdiff_common_draw_part(view, type, text, '+', LINE_DIFF_ADD);\n+\t\t\tdiff_common_draw_part(view, type, text, '-', LINE_DIFF_DEL);\n+\t\t}\n+}\n+\n bool\n diff_common_draw(struct view *view, struct line *line, unsigned int lineno)\n {\n@@ -180,18 +197,7 @@ diff_common_draw(struct view *view, struct line *line, unsigned int lineno)\n \t\treturn TRUE;\n \n \tif (type == LINE_DIFF_STAT) {\n-\t\tdiff_common_draw_part(view, &type, &text, '|', LINE_DEFAULT);\n-\t\tif (diff_common_draw_part(view, &type, &text, 'B', LINE_DEFAULT)) {\n-\t\t\t/* Handle binary diffstat: Bin <deleted> -> <added> bytes */\n-\t\t\tdiff_common_draw_part(view, &type, &text, ' ', LINE_DIFF_DEL);\n-\t\t\tdiff_common_draw_part(view, &type, &text, '-', LINE_DEFAULT);\n-\t\t\tdiff_common_draw_part(view, &type, &text, ' ', LINE_DIFF_ADD);\n-\t\t\tdiff_common_draw_part(view, &type, &text, 'b', LINE_DEFAULT);\n-\n-\t\t} else {\n-\t\t\tdiff_common_draw_part(view, &type, &text, '+', LINE_DIFF_ADD);\n-\t\t\tdiff_common_draw_part(view, &type, &text, '-', LINE_DIFF_DEL);\n-\t\t}\n+\t\tdiff_common_draw_diff_stat(view, &type, &text);\n \t}\n \n \tif (line->user_flags & DIFF_LINE_COMMIT_TITLE)\n-- \n1.9.1\n"},{"id":"238817","messageId":"1397426068-17439-4-git-send-email-a.kumar@alumni.iitm.ac.in","threadId":"36390","inReplyTo":"1397426068-17439-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"[tig] [PATCHv2 3/3] log: Colour the diff stat","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-13T21:54:28Z","receivedAt":"2014-04-13T21:54:28Z","isPatch":false,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"This commit adds custom log_read and log_draw functions that utilize\nthe diff stat drawing functions from the diff module. The absence of\nthe triple hyphen separator prevents direct usage of the diff drawing\nfunctions directly.\n\nSigned-Off-By: Kumar Appaiah <a.kumar@alumni.iitm.ac.in>\n---\n src/log.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 53 insertions(+), 2 deletions(-)\n\ndiff --git a/src/log.c b/src/log.c\nindex 40c9a21..468f7c3 100644\n--- a/src/log.c\n+++ b/src/log.c\n@@ -23,6 +23,9 @@ struct log_state {\n \t * up/down in the log view. */\n \tint last_lineno;\n \tenum line_type last_type;\n+\tbool commit_title_read;\n+\tbool after_commit_header;\n+\tbool reading_diff_stat;\n };\n \n static void\n@@ -78,14 +81,62 @@ log_request(struct view *view, enum request request, struct line *line)\n \t}\n }\n \n+static bool\n+log_read(struct view *view, char *data)\n+{\n+\tenum line_type type;\n+\tstruct log_state *state = view->private;\n+\tsize_t len;\n+\n+\tif (!data)\n+\t\treturn TRUE;\n+\n+\ttype = get_line_type(data);\n+\tlen = strlen(data);\n+\n+\tif (type == LINE_COMMIT)\n+\t\tstate->commit_title_read = TRUE;\n+\telse if (state->commit_title_read && len < 1) {\n+\t\tstate->commit_title_read = FALSE;\n+\t\tstate->after_commit_header = TRUE;\n+\t} else if (state->after_commit_header && len < 1) {\n+\t\tstate->after_commit_header = FALSE;\n+\t\tstate->reading_diff_stat = TRUE;\n+\t} else if (state->reading_diff_stat) {\n+\t\tbool ret = diff_common_add_diff_stat(view, data);\n+\t\tif (ret) {\n+\t\t\treturn TRUE;\n+\t\t} else {\n+\t\t\tstate->reading_diff_stat = FALSE;\n+\t\t}\n+\t}\n+\n+\treturn pager_common_read(view, data, type);\n+}\n+\n+static bool\n+log_draw(struct view *view, struct line *line, unsigned int lineno)\n+{\n+\tchar *text = line->data;\n+\tenum line_type type = line->type;\n+\n+\tif (type == LINE_DIFF_STAT) {\n+\t\tdiff_common_draw_diff_stat(view, &type, &text);\n+\t\tdraw_text(view, type, text);\n+\t\treturn TRUE;\n+\t}\n+\n+\treturn pager_draw(view, line, lineno);\n+}\n+\n static struct view_ops log_ops = {\n \t\"line\",\n \targv_env.head,\n \tVIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER | VIEW_LOG_LIKE | VIEW_REFRESH,\n \tsizeof(struct log_state),\n \tlog_open,\n-\tpager_read,\n-\tpager_draw,\n+\tlog_read,\n+\tlog_draw,\n \tlog_request,\n \tpager_grep,\n \tlog_select,\n-- \n1.9.1\n"},{"id":"238994","messageId":"CAFuPQ1JbpNcun3hGps=hwaM14wOjF+iU9bsm9+ZmJvJV_Fea4Q@mail.gmail.com","threadId":"36390","inReplyTo":"1397426068-17439-4-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"Re: [tig] [PATCHv2 3/3] log: Colour the diff stat","fromName":"Jonas Fonseca","fromEmail":"jonas.fonseca@gmail.com","sentAt":"2014-04-17T00:44:41Z","receivedAt":"2014-04-17T00:44:41Z","isPatch":false,"sender":{"key":"jonas.fonseca@gmail.com","avatar":"https://gravatar.com/avatar/9b7fa23cce50269e5d164312b6ac5ae818a180f837b38f28f3bdf689dd7f96cd?d=mp&s=160"},"body":"On Sun, Apr 13, 2014 at 5:54 PM, Kumar Appaiah\n<a.kumar@alumni.iitm.ac.in> wrote:\n>\n> This commit adds custom log_read and log_draw functions that utilize\n> the diff stat drawing functions from the diff module. The absence of\n> the triple hyphen separator prevents direct usage of the diff drawing\n> functions directly.\n\nSee my comments below.\n\n> ---\n>  src/log.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++--\n>  1 file changed, 53 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/log.c b/src/log.c\n> index 40c9a21..468f7c3 100644\n> --- a/src/log.c\n> +++ b/src/log.c\n> @@ -23,6 +23,9 @@ struct log_state {\n>          * up/down in the log view. */\n>         int last_lineno;\n>         enum line_type last_type;\n> +       bool commit_title_read;\n> +       bool after_commit_header;\n> +       bool reading_diff_stat;\n>  };\n>\n>  static void\n> @@ -78,14 +81,62 @@ log_request(struct view *view, enum request request, struct line *line)\n>         }\n>  }\n>\n> +static bool\n> +log_read(struct view *view, char *data)\n> +{\n> +       enum line_type type;\n> +       struct log_state *state = view->private;\n> +       size_t len;\n> +\n> +       if (!data)\n> +               return TRUE;\n> +\n> +       type = get_line_type(data);\n> +       len = strlen(data);\n> +\n> +       if (type == LINE_COMMIT)\n> +               state->commit_title_read = TRUE;\n> +       else if (state->commit_title_read && len < 1) {\n> +               state->commit_title_read = FALSE;\n> +               state->after_commit_header = TRUE;\n> +       } else if (state->after_commit_header && len < 1) {\n> +               state->after_commit_header = FALSE;\n> +               state->reading_diff_stat = TRUE;\n> +       } else if (state->reading_diff_stat) {\n> +               bool ret = diff_common_add_diff_stat(view, data);\n> +               if (ret) {\n> +                       return TRUE;\n> +               } else {\n> +                       state->reading_diff_stat = FALSE;\n> +               }\n> +       }\n> +\n> +       return pager_common_read(view, data, type);\n> +}\n> +\n> +static bool\n> +log_draw(struct view *view, struct line *line, unsigned int lineno)\n> +{\n> +       char *text = line->data;\n> +       enum line_type type = line->type;\n> +\n\nThis is missing a call to draw_lineno(...)\n\n> +       if (type == LINE_DIFF_STAT) {\n> +               diff_common_draw_diff_stat(view, &type, &text);\n> +               draw_text(view, type, text);\n\nI had to #include \"tig/draw.h\" for this to compile.\n\n> +               return TRUE;\n> +       }\n> +\n> +       return pager_draw(view, line, lineno);\n> +}\n> +\n>  static struct view_ops log_ops = {\n>         \"line\",\n>         argv_env.head,\n>         VIEW_ADD_PAGER_REFS | VIEW_OPEN_DIFF | VIEW_SEND_CHILD_ENTER | VIEW_LOG_LIKE | VIEW_REFRESH,\n>         sizeof(struct log_state),\n>         log_open,\n> -       pager_read,\n> -       pager_draw,\n> +       log_read,\n> +       log_draw,\n>         log_request,\n>         pager_grep,\n>         log_select,\n> --\n> 1.9.1\n>\n\n\n\n-- \nJonas Fonseca\n"},{"id":"238995","messageId":"CAFuPQ1L=iW+kWXZ41BDKXzyMH0Ci87_qi79FCm14juiK=Qfh=A@mail.gmail.com","threadId":"36390","inReplyTo":"1397426068-17439-1-git-send-email-a.kumar@alumni.iitm.ac.in","subject":"Re: [tig] [PATCHv2 0/3] log: colour the diffstat","fromName":"Jonas Fonseca","fromEmail":"jonas.fonseca@gmail.com","sentAt":"2014-04-17T00:52:47Z","receivedAt":"2014-04-17T00:52:47Z","isPatch":false,"sender":{"key":"jonas.fonseca@gmail.com","avatar":"https://gravatar.com/avatar/9b7fa23cce50269e5d164312b6ac5ae818a180f837b38f28f3bdf689dd7f96cd?d=mp&s=160"},"body":"Hi Kumar,\n\nOn Sun, Apr 13, 2014 at 5:54 PM, Kumar Appaiah\n<a.kumar@alumni.iitm.ac.in> wrote:\n>\n> These patches add colourization to the log view. They reuse the diff\n> stat drawing functions from the diff module directly.\n\nThis is a great idea. I wonder though if it would make sense to put\nthis into the pager backend instead so all pager based views can\nbenefit unless of course the \"state machine\" would end up becoming too\ncomplicated.\n\n> This version just includes some code reformatting and minor\n> fixes. Please comment on what other fixes could help.\n\nSee my other email regarding fixes. Since I am currently refactoring\nhow views are drawn I'd prefer to postpone merging this patchset until\nthe dust has settled. I'll try to rebase the patches once I get there\nbefore reaching out to you.\n\n-- \nJonas Fonseca\n"},{"id":"238996","messageId":"20140417010454.GA27665@odessa","threadId":"36390","inReplyTo":"CAFuPQ1JbpNcun3hGps=hwaM14wOjF+iU9bsm9+ZmJvJV_Fea4Q@mail.gmail.com","subject":"Re: [tig] [PATCHv2 3/3] log: Colour the diff stat","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2014-04-17T01:04:54Z","receivedAt":"2014-04-17T01:04:54Z","isPatch":false,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"\nOn Wed, Apr 16, 2014 at 08:44:41PM -0400, Jonas Fonseca wrote:\n> On Sun, Apr 13, 2014 at 5:54 PM, Kumar Appaiah\n> <a.kumar@alumni.iitm.ac.in> wrote:\n> >\n> > This commit adds custom log_read and log_draw functions that utilize\n> > the diff stat drawing functions from the diff module. The absence of\n> > the triple hyphen separator prevents direct usage of the diff drawing\n> > functions directly.\n> \n> See my comments below.\n\nHi Jonas.\n\n> > +static bool\n> > +log_draw(struct view *view, struct line *line, unsigned int lineno)\n> > +{\n> > +       char *text = line->data;\n> > +       enum line_type type = line->type;\n> > +\n> \n> This is missing a call to draw_lineno(...)\n\nNoted.\n\n> > +       if (type == LINE_DIFF_STAT) {\n> > +               diff_common_draw_diff_stat(view, &type, &text);\n> > +               draw_text(view, type, text);\n> \n> I had to #include \"tig/draw.h\" for this to compile.\n\nI'll take care of this.\n\nI'll send you a pull request eventually. You can handle it after your\nrefactor is complete.\n\nThanks!\n\nKumar\n-- \nKumar Appaiah\n"}]}