Code

Merged branch 'jessie'.
[pkg-tig.git] / debian / patches / bts757692-topo-order
1 Description: Force --topo-order when graph is enabled and no commit order is set
2  This is what `git log --graph` does to ensure that parent commits comes
3  before child commits.
4 Author: Jonas Fonseca <jonas.fonseca@gmail.com>
5 Origin: upstream
6 Bug: https://github.com/jonas/tig/issues/238
7 Applied-Upstream: https://github.com/jonas/tig/commit/adb362b
8 --- a/doc/tigrc.5.adoc
9 +++ b/doc/tigrc.5.adoc
10 @@ -234,6 +234,8 @@
11         Commit ordering using the default (chronological reverse) order,
12         topological order, date order or reverse order. The default order is
13         used when the option is set to false, and topo order when set to true.
14 +       Note that topological order is automatically used in the main view when
15 +       the commit graph is enabled and the commit order is set to the default.
16  
17  'ignore-case' (bool)::
18  
19 --- a/include/tig/options.h
20 +++ b/include/tig/options.h
21 @@ -167,6 +167,7 @@
22  
23  const char *ignore_space_arg();
24  const char *commit_order_arg();
25 +const char *commit_order_arg_with_graph(bool with_graph);
26  const char *diff_context_arg();
27  const char *show_notes_arg();
28  
29 --- a/src/main.c
30 +++ b/src/main.c
31 @@ -181,33 +181,43 @@
32         return with_reflog;
33  }
34  
35 +main_with_graph(struct view *view, enum open_flags flags)
36 +{
37 +       struct view_column *column = get_view_column(view, VIEW_COLUMN_COMMIT_TITLE);
38 +
39 +       if (open_in_pager_mode(flags))
40 +               return FALSE;
41 +
42 +       return column && column->opt.commit_title.graph &&
43 +              opt_commit_order != COMMIT_ORDER_REVERSE;
44 +}
45 +
46  static bool
47  main_open(struct view *view, enum open_flags flags)
48  {
49 +       bool with_graph = main_with_graph(view, flags);
50         const char *pretty_custom_argv[] = {
51 -               GIT_MAIN_LOG_CUSTOM(encoding_arg, commit_order_arg(), "%(cmdlineargs)", "%(revargs)", "%(fileargs)")
52 +               GIT_MAIN_LOG_CUSTOM(encoding_arg, commit_order_arg_with_graph(with_graph),
53 +                       "%(cmdlineargs)", "%(revargs)", "%(fileargs)")
54         };
55         const char *pretty_raw_argv[] = {
56 -               GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg(), "%(cmdlineargs)", "%(revargs)", "%(fileargs)")
57 +               GIT_MAIN_LOG_RAW(encoding_arg, commit_order_arg_with_graph(with_graph),
58 +                       "%(cmdlineargs)", "%(revargs)", "%(fileargs)")
59         };
60         struct main_state *state = view->private;
61         const char **main_argv = pretty_custom_argv;
62 -       struct view_column *column;
63         enum watch_trigger changes_triggers = WATCH_NONE;
64  
65         if (opt_show_changes && repo.is_inside_work_tree)
66                 changes_triggers |= WATCH_INDEX;
67  
68 -       column = get_view_column(view, VIEW_COLUMN_COMMIT_TITLE);
69 -       state->with_graph = column && column->opt.commit_title.graph &&
70 -                           opt_commit_order != COMMIT_ORDER_REVERSE;
71 +       state->with_graph = with_graph;
72  
73         if (opt_rev_argv && main_check_argv(view, opt_rev_argv))
74                 main_argv = pretty_raw_argv;
75  
76         if (open_in_pager_mode(flags)) {
77                 changes_triggers = WATCH_NONE;
78 -               state->with_graph = FALSE;
79         }
80  
81         /* This calls reset_view() so must be before adding changes commits. */
82 --- a/src/options.c
83 +++ b/src/options.c
84 @@ -128,6 +128,20 @@
85         return commit_order_arg_map[opt_commit_order].name;
86  }
87  
88 +const char *
89 +commit_order_arg_with_graph(bool with_graph)
90 +{
91 +       enum commit_order commit_order = opt_commit_order;
92 +
93 +       if (with_graph &&
94 +           commit_order != COMMIT_ORDER_TOPO &&
95 +           commit_order != COMMIT_ORDER_DATE &&
96 +           commit_order != COMMIT_ORDER_AUTHOR_DATE)
97 +               commit_order = COMMIT_ORDER_TOPO;
98 +
99 +       return commit_order_arg_map[commit_order].name;
100 +}
102  /* Use --show-notes to support Git >= 1.7.6 */
103  #define NOTES_ARG      "--show-notes"
104  #define NOTES_EQ_ARG   NOTES_ARG "="