X-Git-Url: https://git.distorted.org.uk/~mdw/tig/blobdiff_plain/4ef1bf121de1697c9d54e10addcd34a4d19d3526..b6607e7e796f5b58d64211c022d3e1af6159bdaa:/tig.c diff --git a/tig.c b/tig.c index 446453d..c44409e 100644 --- a/tig.c +++ b/tig.c @@ -72,6 +72,7 @@ static size_t utf8_length(const char *string, size_t max_width, int *coloffset, #define REVGRAPH_MERGE 'M' #define REVGRAPH_BRANCH '+' #define REVGRAPH_COMMIT '*' +#define REVGRAPH_BOUND '^' #define REVGRAPH_LINE '|' #define SIZEOF_REVGRAPH 19 /* Size of revision ancestry graphics. */ @@ -111,7 +112,7 @@ static size_t utf8_length(const char *string, size_t max_width, int *coloffset, "git log --no-color --cc --stat -n100 %s 2>/dev/null" #define TIG_MAIN_CMD \ - "git log --no-color --topo-order --pretty=raw %s 2>/dev/null" + "git log --no-color --topo-order --boundary --pretty=raw %s 2>/dev/null" #define TIG_TREE_CMD \ "git ls-tree %s %s" @@ -559,7 +560,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"); + string_copy(opt_cmd, "git log --no-color --pretty=raw --boundary"); else string_copy(opt_cmd, "git"); buf_size = strlen(opt_cmd); @@ -696,15 +697,15 @@ get_line_info(char *name, int namelen) static void init_colors(void) { - int default_bg = COLOR_BLACK; - int default_fg = COLOR_WHITE; + int default_bg = line_info[LINE_DEFAULT].bg; + int default_fg = line_info[LINE_DEFAULT].fg; enum line_type type; start_color(); - if (use_default_colors() != ERR) { - default_bg = -1; - default_fg = -1; + if (assume_default_colors(default_fg, default_bg) == ERR) { + default_bg = COLOR_BLACK; + default_fg = COLOR_WHITE; } for (type = 0; type < ARRAY_SIZE(line_info); type++) { @@ -1270,29 +1271,47 @@ read_option(char *opt, size_t optlen, char *value, size_t valuelen) return OK; } -static int -load_options(void) +static void +load_option_file(const char *path) { - char *home = getenv("HOME"); - char buf[SIZEOF_STR]; FILE *file; + /* It's ok that the file doesn't exist. */ + file = fopen(path, "r"); + if (!file) + return; + config_lineno = 0; config_errors = FALSE; - add_builtin_run_requests(); + if (read_properties(file, " \t", read_option) == ERR || + config_errors == TRUE) + fprintf(stderr, "Errors while loading %s.\n", path); +} - if (!home || !string_format(buf, "%s/.tigrc", home)) - return ERR; +static int +load_options(void) +{ + char *home = getenv("HOME"); + char *tigrc_user = getenv("TIGRC_USER"); + char *tigrc_system = getenv("TIGRC_SYSTEM"); + char buf[SIZEOF_STR]; - /* It's ok that the file doesn't exist. */ - file = fopen(buf, "r"); - if (!file) - return OK; + add_builtin_run_requests(); - if (read_properties(file, " \t", read_option) == ERR || - config_errors == TRUE) - fprintf(stderr, "Errors while loading %s.\n", buf); + if (!tigrc_system) { + if (!string_format(buf, "%s/tigrc", SYSCONFDIR)) + return ERR; + tigrc_system = buf; + } + load_option_file(tigrc_system); + + if (!tigrc_user) { + if (!home || !string_format(buf, "%s/.tigrc", home)) + return ERR; + tigrc_user = buf; + } + load_option_file(tigrc_user); return OK; } @@ -3860,6 +3879,7 @@ struct rev_graph { size_t size; struct commit *commit; size_t pos; + unsigned int boundary:1; }; /* Parents of the commit being visualized. */ @@ -3932,7 +3952,9 @@ get_rev_graph_symbol(struct rev_graph *graph) { chtype symbol; - if (graph->parents->size == 0) + if (graph->boundary) + symbol = REVGRAPH_BOUND; + else if (graph->parents->size == 0) symbol = REVGRAPH_INIT; else if (graph_parent_is_merge(graph)) symbol = REVGRAPH_MERGE; @@ -4014,7 +4036,7 @@ prepare_rev_graph(struct rev_graph *graph) } /* Interleave the new revision parent(s). */ - for (i = 0; i < graph->parents->size; i++) + for (i = 0; !graph->boundary && i < graph->parents->size; i++) push_rev_graph(graph->next, graph->parents->rev[i]); /* Lastly, put any remaining revisions. */ @@ -4174,7 +4196,13 @@ main_read(struct view *view, char *line) if (!commit) return FALSE; - string_copy_rev(commit->id, line + STRING_SIZE("commit ")); + line += STRING_SIZE("commit "); + if (*line == '-') { + graph->boundary = 1; + line++; + } + + string_copy_rev(commit->id, line); commit->refs = get_refs(commit->id); graph->commit = commit; add_line_data(view, commit, LINE_MAIN_COMMIT);