From d4d11fae72afa4292a44cb5f159c3fc07912b4c5 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 6 Oct 2014 21:22:35 -0400 Subject: [PATCH] Add option to turn off automatic enabling of topo-order This permits to avoid any initial pause during startup due to git-log buffering commits for reordering. References #310 --- NEWS.adoc | 2 ++ doc/tigrc.5.adoc | 5 +++-- include/tig/options.h | 4 ++-- include/tig/types.h | 6 ++++++ src/main.c | 17 +++++++---------- src/options.c | 4 ++-- test/main/default-test | 1 + tigrc | 2 +- 8 files changed, 24 insertions(+), 17 deletions(-) diff --git a/NEWS.adoc b/NEWS.adoc index 678cea8..8adedca 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -8,6 +8,8 @@ Improvements: - Add move-half-page-up and move-half-page-down actions. (GH #323) - Preserve the cursor position when changing the diff context. + - Add option to turn off automatic enabling of `--topo-order` when the graph is + shown in the main view. (GH #310) Bug fixes: diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index 64b99b6..5dc5b86 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -369,8 +369,9 @@ author:: When set to zero, the width is automatically sized to fit the content. commit-title:: - - 'graph' (bool): Whether to show revision graph in the main view on - start-up. See also the 'line-graphics' options. + - 'graph' (mixed) [no|yes|no-topo]: Whether to show the revision graph + in the main view on start-up. If set to "no-topo" topo-order is not + automatically enabled. See also the 'line-graphics' options. - 'refs' (bool): Whether to show references (branches, tags, and remotes) in the main view. Can be toggled. - 'overflow' (bool or int): Whether to highlight text in commit titles diff --git a/include/tig/options.h b/include/tig/options.h index f4545b0..d3899f0 100644 --- a/include/tig/options.h +++ b/include/tig/options.h @@ -78,7 +78,7 @@ OPTION_INFO(DEFINE_OPTION_EXTERNS); #define COMMIT_TITLE_COLUMN_OPTIONS(_) \ _(display, bool, VIEW_NO_FLAGS) \ - _(graph, bool, VIEW_LOG_LIKE) \ + _(graph, enum graph_display, VIEW_LOG_LIKE) \ _(refs, bool, VIEW_NO_FLAGS) \ _(overflow, int, VIEW_NO_FLAGS) \ _(width, int, VIEW_NO_FLAGS) \ @@ -169,7 +169,7 @@ void update_options_from_argv(const char *argv[]); const char *ignore_space_arg(); const char *commit_order_arg(); -const char *commit_order_arg_with_graph(bool with_graph); +const char *commit_order_arg_with_graph(enum graph_display graph_display); const char *diff_context_arg(); const char *show_notes_arg(); diff --git a/include/tig/types.h b/include/tig/types.h index 98a6683..2028365 100644 --- a/include/tig/types.h +++ b/include/tig/types.h @@ -73,6 +73,11 @@ bool map_enum_do(const struct enum_map_entry *map, size_t map_size, int *value, _(GRAPHIC, DEFAULT), \ _(GRAPHIC, UTF_8) +#define GRAPH_DISPLAY_ENUM(_) \ + _(GRAPH_DISPLAY, NO), \ + _(GRAPH_DISPLAY, YES), \ + _(GRAPH_DISPLAY, NO_TOPO) + #define DATE_ENUM(_) \ _(DATE, NO), \ _(DATE, DEFAULT), \ @@ -151,6 +156,7 @@ bool map_enum_do(const struct enum_map_entry *map, size_t map_size, int *value, _(file_size, FILE_SIZE_ENUM) \ _(filename, FILENAME_ENUM) \ _(graphic, GRAPHIC_ENUM) \ + _(graph_display, GRAPH_DISPLAY_ENUM) \ _(ignore_space, IGNORE_SPACE_ENUM) \ _(vertical_split, VERTICAL_SPLIT_ENUM) \ _(view_column_type, VIEW_COLUMN_ENUM) \ diff --git a/src/main.c b/src/main.c index cc3d4d0..e4b6fd3 100644 --- a/src/main.c +++ b/src/main.c @@ -184,28 +184,25 @@ main_check_argv(struct view *view, const char *argv[]) return with_reflog; } -static bool +static enum graph_display main_with_graph(struct view *view, enum open_flags flags) { struct view_column *column = get_view_column(view, VIEW_COLUMN_COMMIT_TITLE); - if (open_in_pager_mode(flags)) - return FALSE; - - return column && column->opt.commit_title.graph && - opt_commit_order != COMMIT_ORDER_REVERSE; + return column && opt_commit_order != COMMIT_ORDER_REVERSE && !open_in_pager_mode(flags) + ? column->opt.commit_title.graph : GRAPH_DISPLAY_NO; } static bool main_open(struct view *view, enum open_flags flags) { - bool with_graph = main_with_graph(view, flags); + enum graph_display graph_display = main_with_graph(view, flags); const char *pretty_custom_argv[] = { - GIT_MAIN_LOG_CUSTOM(encoding_arg, commit_order_arg_with_graph(with_graph), + GIT_MAIN_LOG_CUSTOM(encoding_arg, commit_order_arg_with_graph(graph_display), "%(cmdlineargs)", "%(revargs)", "%(fileargs)") }; const char *pretty_raw_argv[] = { - GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg_with_graph(with_graph), + GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg_with_graph(graph_display), "%(cmdlineargs)", "%(revargs)", "%(fileargs)") }; struct main_state *state = view->private; @@ -215,7 +212,7 @@ main_open(struct view *view, enum open_flags flags) if (opt_show_changes && repo.is_inside_work_tree) changes_triggers |= WATCH_INDEX; - state->with_graph = with_graph; + state->with_graph = graph_display != GRAPH_DISPLAY_NO; if (opt_rev_args && main_check_argv(view, opt_rev_args)) main_argv = pretty_raw_argv; diff --git a/src/options.c b/src/options.c index a87a4a9..db4c5b5 100644 --- a/src/options.c +++ b/src/options.c @@ -129,11 +129,11 @@ commit_order_arg() } const char * -commit_order_arg_with_graph(bool with_graph) +commit_order_arg_with_graph(enum graph_display graph_display) { enum commit_order commit_order = opt_commit_order; - if (with_graph && + if (graph_display == GRAPH_DISPLAY_YES && commit_order != COMMIT_ORDER_TOPO && commit_order != COMMIT_ORDER_DATE && commit_order != COMMIT_ORDER_AUTHOR_DATE) diff --git a/test/main/default-test b/test/main/default-test index d8b9d4e..8de4e99 100755 --- a/test/main/default-test +++ b/test/main/default-test @@ -21,6 +21,7 @@ steps ' :toggle commit-title-refs :save-display main-no-refs.screen :toggle commit-title-graph + :toggle commit-title-graph :save-display main-no-graph.screen :957f2b368e6fa5c0757f36b1441e32729ee5e9c7 diff --git a/tigrc b/tigrc index 6d0749e..b9a5c09 100644 --- a/tigrc +++ b/tigrc @@ -16,7 +16,7 @@ # : Show author information? # commit-title # - display (bool) : Show the commit title? -# - graph (bool) : Show the commit revision graph? (main view only) +# - graph (enum) [no|yes|no-topo] : Show the commit graph? (main view only) # - refs (bool) : Show branches, tags and remotes? (main view only) # - overflow (boolint) : Highlight overflows? Default to 50 when enabled. # -- 2.11.4.GIT