From d54c448da196d9c9c3f64a5b5001a118f067b3a3 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Sat, 10 Jul 2021 15:05:05 +0200 Subject: [PATCH 1/3] Fix invalid read in log_read --- src/log.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/log.c b/src/log.c index cc8fbb7f5..e4f89c848 100644 --- a/src/log.c +++ b/src/log.c @@ -97,7 +97,7 @@ static bool log_read(struct view *view, struct buffer *buf, bool force_stop) { struct line *line = NULL; - enum line_type type; + enum line_type type = LINE_DEFAULT; struct log_state *state = view->private; size_t len; char *commit; @@ -111,8 +111,11 @@ log_read(struct view *view, struct buffer *buf, bool force_stop) if (commit && get_graph_indent(data) == commit - data) state->graph_indent = commit - data; - type = get_line_type(data + state->graph_indent); - len = strlen(data + state->graph_indent); + len = strlen(data); + if (len >= state->graph_indent) { + type = get_line_type(data + state->graph_indent); + len -= state->graph_indent; + } if (type == LINE_COMMIT) state->commit_title_read = true; From e7a35d57e9f90daaeb134e4a038763f9c5dd974a Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Sun, 11 Jul 2021 10:44:16 +0200 Subject: [PATCH 2/3] Restore support for tig log --graph Support for `tig log --graph` was added in 2.0 with fa2fcc9 but was later broken in 2.2 with 178c45c when the box structure was implemented. This makes it work again, though it would be cleaner to move the implementation from draw.c to log.c and pager.c, using the box structure. --- src/draw.c | 14 ++++++++++--- test/log/log-graph-test | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 test/log/log-graph-test diff --git a/src/draw.c b/src/draw.c index afab85f2b..1b6bed53a 100644 --- a/src/draw.c +++ b/src/draw.c @@ -543,12 +543,13 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno) { enum line_type type = line->type; const char *text = column_data.text; + size_t indent = 0; if (line->wrapped && draw_text(view, LINE_DELIMITER, "+")) return true; if (line->graph_indent) { - size_t indent = get_graph_indent(text); + indent = get_graph_indent(text); if (draw_text_expanded(view, LINE_DEFAULT, text, -1, indent, false)) return true; @@ -567,11 +568,18 @@ view_column_draw(struct view *view, struct line *line, unsigned int lineno) for (i = 0; i < box->cells; i++) { const struct box_cell *cell = &box->cell[i]; + int length = cell->length; - if (draw_textn(view, cell->type, text, cell->length)) + if (indent) { + text += indent; + length -= indent; + indent = 0; + } + + if (draw_textn(view, cell->type, text, length)) return true; - text += cell->length; + text += length; } } else if (draw_text(view, type, text)) { diff --git a/test/log/log-graph-test b/test/log/log-graph-test new file mode 100755 index 000000000..c7c7c1df2 --- /dev/null +++ b/test/log/log-graph-test @@ -0,0 +1,44 @@ +#!/bin/sh + +. libtest.sh +. libgit.sh + +steps ' + :save-display log-graph.screen +' + +in_work_dir create_repo_from_tgz "$base_dir/files/scala-js-benchmarks.tgz" + +test_tig log --graph e59a941 + +assert_equals 'log-graph.screen' < +| | Date: Thu Jan 16 07:47:58 2014 -0800 +| | +| | Merge pull request #4 from phaller/patch-1 +| | +| | Fix link to Dart benchmark harness +| | +| | README.md | 2 +- +| | 1 file changed, 1 insertion(+), 1 deletion(-) +| | +| * commit 940efafc379db7c6df99449d6c4da98c6a2b3d07 +|/ Author: Philipp Haller +| Date: Thu Jan 16 15:32:52 2014 +0100 +| +| Fix link to Dart benchmark harness +| +| README.md | 2 +- +| 1 file changed, 1 insertion(+), 1 deletion(-) +| +* commit 110e090f815f40d649f5432172584057b550a160 +| Author: Jonas Fonseca +| Date: Tue Dec 17 00:02:15 2013 +0100 +| +| Update links to reflect project name change +| +| scalajs-benchmarks -> scala-js-benchmarks +[log] e59a941c4e7d51cd172ee2767a031f5f3fd25d05 - line 1 of 559 5% +EOF From 9588352391519f0bf8aee86e08e0f3dd70490456 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Sun, 11 Jul 2021 21:54:33 +0200 Subject: [PATCH 3/3] Add auto-refresh to log view --- src/log.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/log.c b/src/log.c index e4f89c848..15a05029e 100644 --- a/src/log.c +++ b/src/log.c @@ -68,8 +68,15 @@ log_open(struct view *view, enum open_flags flags) "--stat", use_mailmap_arg(), "%(logargs)", "%(cmdlineargs)", "%(revargs)", "--no-color", "--", "%(fileargs)", NULL }; + enum status_code code; - return begin_update(view, NULL, log_argv, flags); + code = begin_update(view, NULL, log_argv, flags); + if (code != SUCCESS) + return code; + + watch_register(&view->watch, WATCH_HEAD | WATCH_REFS); + + return SUCCESS; } static enum request