summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c18649)
raw | patch | inline | side by side (parent: 6c18649)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 12 Sep 2006 11:54:28 +0000 (13:54 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Tue, 12 Sep 2006 11:54:28 +0000 (13:54 +0200) |
tig.c | patch | blob | history |
index e707d688821cdd829035c246b84fb05e62f124c5..4e0900ac77f4052ce70dc099dbf583e6956752bb 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -2792,6 +2792,8 @@ main_draw(struct view *view, struct line *line, unsigned int lineno, bool select
struct rev_stack {
char rev[SIZEOF_REVITEMS][SIZEOF_REV];
size_t size;
+ struct commit *commit;
+ size_t pos;
};
/* The current stack of revisions on the graph. */
static size_t graph_last_rev;
+static inline void
+append_to_rev_graph(struct rev_stack *stack, chtype symbol)
+{
+ stack->commit->graph[stack->commit->graph_size++] = symbol;
+}
+
static void
push_rev_stack(struct rev_stack *stack, char *parent)
{
}
static void
-draw_rev_graph(struct commit *commit, size_t stackpos,
- struct rev_stack *stack, struct rev_stack *parents,
+draw_rev_graph(struct rev_stack *stack, struct rev_stack *parents,
struct rev_stack *prev_parents)
{
chtype symbol, separator, line;
symbol = REVGRAPH_INIT;
else if (parents->size > 1)
symbol = REVGRAPH_MERGE;
- else if (stackpos >= stack->size)
+ else if (stack->pos >= stack->size)
symbol = REVGRAPH_BRANCH;
else
symbol = REVGRAPH_COMMIT;
separator = ' ';
line = REVGRAPH_LINE;
- for (i = 0; i < stackpos; i++) {
- commit->graph[commit->graph_size++] = line;
+ for (i = 0; i < stack->pos; i++) {
+ append_to_rev_graph(stack, line);
if (prev_parents->size > 1 &&
i == graph_last_rev) {
separator = '`';
line = '.';
}
- commit->graph[commit->graph_size++] = separator;
+ append_to_rev_graph(stack, separator);
}
- commit->graph[commit->graph_size++] = symbol;
+ append_to_rev_graph(stack, symbol);
separator = ' ';
line = REVGRAPH_LINE;
i++;
for (; i < stack->size; i++) {
- commit->graph[commit->graph_size++] = separator;
- commit->graph[commit->graph_size++] = line;
+ append_to_rev_graph(stack, separator);
+ append_to_rev_graph(stack, line);
if (prev_parents->size > 1) {
if (i < graph_last_rev + prev_parents->size) {
separator = '`';
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;
+ stack->commit = commit;
+
/* 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))
+ for (stack->pos = 0; stack->pos < stack->size; stack->pos++) {
+ if (!strcmp(stack->rev[stack->pos], commit->id))
break;
- push_rev_stack(graph, stack->rev[stackpos]);
+ push_rev_stack(graph, stack->rev[stack->pos]);
}
assert(commit->graph_size < ARRAY_SIZE(commit->graph));
push_rev_stack(graph, parents->rev[i]);
/* FIXME: Moving branches left and right when collapsing a branch. */
- for (i = stackpos + 1; i < stack->size; i++)
+ for (i = stack->pos + 1; i < stack->size; i++)
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;
+ draw_rev_graph(stack, parents, prev_parents);
+
+ graph_last_rev = stack->pos;
+ memset(stack, 0, sizeof(*stack));
+ memset(prev_parents, 0, sizeof(*stack));
}
/* Reads git log --pretty=raw output and parses it into the commit struct. */