From d3b19ca4812677d06507cb70de40ed0de3cbe41b Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 21 Mar 2008 17:53:46 +0100 Subject: [PATCH] Use rewritten parent info from --parents to simplify the revgraph --- TODO | 3 +-- tig.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 464e122..437f0d4 100644 --- a/TODO +++ b/TODO @@ -24,8 +24,7 @@ Features that should be explored. - Split sources of tig.c into multiple files. - - Rewrite revgraph handling to use --parents, which should help to - cleanup this messy part of the code. + - Rewrite revgraph handling. - Color the revgraph to make it easier to follow branches. Idea by Dominik Vogt diff --git a/tig.c b/tig.c index 36f03c2..4a50268 100644 --- a/tig.c +++ b/tig.c @@ -116,7 +116,7 @@ static size_t utf8_length(const char *string, size_t max_width, int *trimmed, bo "git log --no-color --cc --stat -n100 %s 2>/dev/null" #define TIG_MAIN_CMD \ - "git log --no-color --topo-order --boundary --pretty=raw %s 2>/dev/null" + "git log --no-color --topo-order --parents --boundary --pretty=raw %s 2>/dev/null" #define TIG_TREE_CMD \ "git ls-tree %s %s" @@ -584,7 +584,7 @@ parse_options(int argc, char *argv[]) if (opt_request == REQ_VIEW_MAIN) /* XXX: This is vulnerable to the user overriding * options required for the main view parser. */ - string_copy(opt_cmd, "git log --no-color --pretty=raw --boundary"); + string_copy(opt_cmd, "git log --no-color --pretty=raw --boundary --parents"); else string_copy(opt_cmd, "git"); buf_size = strlen(opt_cmd); @@ -4016,6 +4016,7 @@ struct commit { struct ref **refs; /* Repository references. */ chtype graph[SIZEOF_REVGRAPH]; /* Ancestry chain graphics. */ size_t graph_size; /* The width of the graph array. */ + bool has_parents; /* Rewritten --parents seen. */ }; /* Size of rev graph with no "padding" columns */ @@ -4368,6 +4369,12 @@ main_read(struct view *view, char *line) commit->refs = get_refs(commit->id); graph->commit = commit; add_line_data(view, commit, LINE_MAIN_COMMIT); + + while ((line = strchr(line, ' '))) { + line++; + push_rev_graph(graph->parents, line); + commit->has_parents = TRUE; + } return TRUE; } @@ -4377,6 +4384,8 @@ main_read(struct view *view, char *line) switch (type) { case LINE_PARENT: + if (commit->has_parents) + break; push_rev_graph(graph->parents, line + STRING_SIZE("parent ")); break; -- 2.11.0