Skip to content

Commit

Permalink
Restore support for tig log --graph
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
koutcher committed Oct 4, 2021
1 parent d54c448 commit e7a35d5
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down
44 changes: 44 additions & 0 deletions test/log/log-graph-test
Original file line number Diff line number Diff line change
@@ -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' <<EOF
* commit e59a941c4e7d51cd172ee2767a031f5f3fd25d05
|\ Merge: 110e090 940efaf
| | Author: Jonas Fonseca <[email protected]>
| | 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 <[email protected]>
| 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 <[email protected]>
| 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

0 comments on commit e7a35d5

Please sign in to comment.