summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Fonseca <jonas.fonseca@gmail.com>2017-07-05 13:29:30 -0400
committerJonas Fonseca <jonas.fonseca@gmail.com>2017-07-05 13:29:30 -0400
commitdad0cf35418d12ce8c2cf33c1fa6d19ea160d8b8 (patch)
tree21f092e26ea36a2072ae86ddd4b4e480b4d5d031
parent76b8810f5fb5c5d32585659397eb79c5e1b077f2 (diff)
Fix reading from stdin for "tig show"
The regression was introduced in 39acb5ab03a6e3b02eaeca6c9387301615e1524e when load_view was called unconditionally for diff views causing reading from stdin to be stopped via a reload.
-rw-r--r--src/view.c6
-rwxr-xr-xtest/diff/diff-stdin-test84
2 files changed, 87 insertions, 3 deletions
diff --git a/src/view.c b/src/view.c
index 248df175..1104b5a7 100644
--- a/src/view.c
+++ b/src/view.c
@@ -726,10 +726,10 @@ maximize_view(struct view *view, bool redraw)
if (redraw) {
redraw_display(false);
report_clear();
- }
- if (view_has_flags(view, VIEW_FLEX_WIDTH))
- load_view(view, NULL, OPEN_RELOAD);
+ if (view_has_flags(view, VIEW_FLEX_WIDTH))
+ load_view(view, NULL, OPEN_RELOAD);
+ }
}
void
diff --git a/test/diff/diff-stdin-test b/test/diff/diff-stdin-test
new file mode 100755
index 00000000..782c278e
--- /dev/null
+++ b/test/diff/diff-stdin-test
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+. libtest.sh
+. libgit.sh
+
+steps '
+ :save-display diff.screen
+'
+
+git_init
+
+test_tig show <<EOF
+commit 1b4c64b595aeb4de1d317d669faacd3c1d82f0b0
+Author: Sven Wegener <sven.wegener@example.net>
+Date: Sun Jul 2 15:01:24 2017 +0200
+
+ graph: Optimize initial and merge calculation
+
+ The initial and merge flags do not depend on any column-specific
+ information, so calculate them only once.
+
+ Signed-off-by: Sven Wegener <sven.wegener@example.net>
+---
+ src/graph-v2.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/graph-v2.c b/src/graph-v2.c
+index 4cf3d9e..ced6838 100644
+--- a/src/graph-v2.c
++++ b/src/graph-v2.c
+@@ -683,6 +683,9 @@ graph_generate_symbols(struct graph_v2 *graph, struct graph_canvas *canvas)
+ struct graph_row *row = &graph->row;
+ struct graph_row *next_row = &graph->next_row;
+ struct graph_row *parents = &graph->parents;
++ int commits = commits_in_row(parents);
++ int initial = commits < 1;
++ int merge = commits > 1;
+ int pos;
+
+ for (pos = 0; pos < row->size; pos++) {
+@@ -692,8 +695,8 @@ graph_generate_symbols(struct graph_v2 *graph, struct graph_canvas *canvas)
+
+ symbol->commit = (pos == graph->position);
+ symbol->boundary = (pos == graph->position && next_row->columns[pos].symbol.boundary);
+- symbol->initial = (commits_in_row(parents) < 1);
+- symbol->merge = (commits_in_row(parents) > 1);
++ symbol->initial = initial;
++ symbol->merge = merge;
+
+ symbol->continued_down = continued_down(row, next_row, pos);
+ symbol->continued_up = continued_down(prev_row, row, pos);
+EOF
+
+assert_equals 'diff.screen' <<EOF
+commit 1b4c64b595aeb4de1d317d669faacd3c1d82f0b0
+Author: Sven Wegener <sven.wegener@example.net>
+Date: Sun Jul 2 15:01:24 2017 +0200
+
+ graph: Optimize initial and merge calculation
+
+ The initial and merge flags do not depend on any column-specific
+ information, so calculate them only once.
+
+ Signed-off-by: Sven Wegener <sven.wegener@example.net>
+---
+ src/graph-v2.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/src/graph-v2.c b/src/graph-v2.c
+index 4cf3d9e..ced6838 100644
+--- a/src/graph-v2.c
++++ b/src/graph-v2.c
+@@ -683,6 +683,9 @@ graph_generate_symbols(struct graph_v2 *graph, struct graph_
+ struct graph_row *row = &graph->row;
+ struct graph_row *next_row = &graph->next_row;
+ struct graph_row *parents = &graph->parents;
++ int commits = commits_in_row(parents);
++ int initial = commits < 1;
++ int merge = commits > 1;
+ int pos;
+
+ for (pos = 0; pos < row->size; pos++) {
+[diff] 1b4c64b595aeb4de1d317d669faacd3c1d82f0b0 - line 1 of 39 71%
+EOF