Code

Refector stuff into draw_rev_graph
authorJonas Fonseca <fonseca@diku.dk>
Tue, 12 Sep 2006 11:29:09 +0000 (13:29 +0200)
committerJonas Fonseca <fonseca@antimatter.localdomain>
Tue, 12 Sep 2006 11:29:09 +0000 (13:29 +0200)
tig.c

diff --git a/tig.c b/tig.c
index 663280a9c9973969963bf3f140b83497b0727e00..8973a7b28a29e25200626df29715641a80f2a066 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2818,33 +2818,14 @@ push_rev_stack(struct rev_stack *stack, char *parent)
        }
 }
 
-void
-update_rev_graph(struct commit *commit)
+static void
+draw_rev_graph(struct commit *commit, size_t stackpos,
+              struct rev_stack *stack, struct rev_stack *parents,
+              struct rev_stack *prev_parents)
 {
-       struct rev_stack *parents = &graph_parents[graph_stack_no & 1];
-       struct rev_stack *stack = &graph_stacks[graph_stack_no++ & 1];
-       struct rev_stack *prev_parents = &graph_parents[graph_stack_no & 1];
-       struct rev_stack *graph = &graph_stacks[graph_stack_no & 1];
        chtype symbol, separator, line;
-       size_t stackpos = 0;
        size_t i;
 
-       fprintf(stderr, "\n%p <%s> ", graph, commit->id);
-
-       /* First traverse all lines of revisions up to the active one. */
-       for (stackpos = 0; stackpos < stack->size; stackpos++) {
-               if (!strcmp(stack->rev[stackpos], commit->id)) {
-                       break;
-               }
-
-               push_rev_stack(graph, stack->rev[stackpos]);
-       }
-
-       assert(commit->graph_size < ARRAY_SIZE(commit->graph));
-
-       for (i = 0; i < parents->size; i++)
-               push_rev_stack(graph, parents->rev[i]);
-
        /* Place the symbol for this commit. */
        if (parents->size == 0)
                symbol = REVGRAPH_INIT;
@@ -2855,12 +2836,6 @@ update_rev_graph(struct commit *commit)
        else
                symbol = REVGRAPH_COMMIT;
 
-       i = stackpos + 1;
-
-       /* FIXME: Moving branches left and right when collapsing a branch. */
-       while (i < stack->size)
-               push_rev_stack(graph, stack->rev[i++]);
-
        separator = ' ';
        line = REVGRAPH_LINE;
 
@@ -2890,7 +2865,41 @@ update_rev_graph(struct commit *commit)
                        }
                }
        }
+}
+
+void
+update_rev_graph(struct commit *commit)
+{
+       struct rev_stack *parents = &graph_parents[graph_stack_no & 1];
+       struct rev_stack *stack = &graph_stacks[graph_stack_no++ & 1];
+       struct rev_stack *prev_parents = &graph_parents[graph_stack_no & 1];
+       struct rev_stack *graph = &graph_stacks[graph_stack_no & 1];
+       size_t stackpos = 0;
+       size_t i;
+
+       fprintf(stderr, "\n%p <%s> ", graph, commit->id);
+
+       /* First traverse all lines of revisions up to the active one. */
+       for (stackpos = 0; stackpos < stack->size; stackpos++) {
+               if (!strcmp(stack->rev[stackpos], commit->id)) {
+                       break;
+               }
+
+               push_rev_stack(graph, stack->rev[stackpos]);
+       }
+
+       assert(commit->graph_size < ARRAY_SIZE(commit->graph));
+
+       for (i = 0; i < parents->size; i++)
+               push_rev_stack(graph, parents->rev[i]);
+
+       i = stackpos + 1;
+
+       /* FIXME: Moving branches left and right when collapsing a branch. */
+       while (i < stack->size)
+               push_rev_stack(graph, stack->rev[i++]);
 
+       draw_rev_graph(commit, stackpos, stack, parents, prev_parents);
        graph_last_rev = stackpos;
        stack->size = prev_parents->size = 0;
 }