Some users may prefer to not have graph indentation.
Add "log.graphIndent" config variable to graph_read_config() to read the
default preference. By default is graph indentation is true.
Add --graph-indent and --no-graph-indent options to overwrite the
default preference.
Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
A list of colors, separated by commas, that can be used to draw
history lines in `git log --graph`.
+`log.graphIndent`::
+ If `true`, indent visual roots when rendering the graphs with `--graph`.
+ Set true by default. It can be overriden with `--[no-]graph-indent`.
+
`log.showRoot`::
If true, the initial commit will be shown as a big creation event.
This is equivalent to a diff against an empty tree.
By default it is set to 0 (no limit), zero and negative values
are ignored and treated as no limit.
+`--no-graph-indent`::
+`--graph-indent`::
+ When used with `--graph`, indent visual roots (commits with no parents
+ or whose parents are not shown) to differentiate them from commits that
+ are vertically adjacent but unrelated. Enabled by default. Use
+ `--no-graph-indent` to disable or set `log.graphIndent` to set a
+ default preference.
+
ifdef::git-rev-list[]
`--count`::
Print a number stating how many commits would have been
static void graph_read_config(struct rev_info *revs)
{
+ int val;
+
if (!column_colors) {
char *string;
if (repo_config_get_string(revs->repo, "log.graphcolors", &string)) {
custom_colors.nr - 1);
}
}
+
+ if (!repo_config_get_bool(revs->repo, "log.graphIndent", &val))
+ revs->no_graph_indent = !val;
}
struct git_graph *graph_init(struct rev_info *opt)
static int graph_needs_pre_root_line(struct git_graph *graph)
{
return graph->commit_in_columns && graph->is_visual_root &&
- graph->num_columns > 0 && !graph->visual_root_cascade;
+ graph->num_columns > 0 && !graph->visual_root_cascade &&
+ !graph->revs->no_graph_indent;
}
void graph_update(struct git_graph *graph, struct commit *commit)
if (col_commit == graph->commit) {
seen_this = 1;
- if (graph->is_visual_root) {
+ if (graph->is_visual_root && !graph->revs->no_graph_indent) {
int depth = graph->visual_root_depth;
/*
* Each visual column is 2 characters wide.
revs->graph = NULL;
} else if (skip_prefix(arg, "--graph-lane-limit=", &optarg)) {
revs->graph_max_lanes = parse_count(optarg);
+ } else if (!strcmp(arg, "--graph-indent")) {
+ revs->no_graph_indent = 0;
+ revs->graph_indent_set = 1;
+ } else if (!strcmp(arg, "--no-graph-indent")) {
+ revs->no_graph_indent = 1;
+ revs->graph_indent_set = 1;
} else if (!strcmp(arg, "--encode-email-headers")) {
revs->encode_email_headers = 1;
} else if (!strcmp(arg, "--no-encode-email-headers")) {
if (revs->graph_max_lanes > 0 && !revs->graph)
die(_("the option '%s' requires '%s'"), "--graph-lane-limit", "--graph");
+ if (revs->graph_indent_set && !revs->graph)
+ die(_("the option '%s' requires '%s'"), "--[no-]graph-indent", "--graph");
+
if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)
die(_("the option '%s' requires '%s'"), "--grep-reflog", "--walk-reflogs");
/* Display history graph */
struct git_graph *graph;
int graph_max_lanes;
+ unsigned int no_graph_indent:1;
+ unsigned int graph_indent_set:1;
/* special limits */
int skip_count;
EOF
'
+test_expect_success '--no-graph-indent disables indentation' '
+ lib_test_check_graph --no-graph-indent _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 <<-\EOF
+ * 67_A
+ * 66_A
+ * 65_A
+ * 64_A
+ * 63_A
+ * 62_A
+ * 61_A
+ * 60_A
+ * 59_A
+ * 58_B
+ * 58_A
+ EOF
+'
+
+test_expect_success 'log.graphIndent config disables indentation' '
+ test_config log.graphIndent false &&
+ lib_test_check_graph _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 <<-\EOF
+ * 67_A
+ * 66_A
+ * 65_A
+ * 64_A
+ * 63_A
+ * 62_A
+ * 61_A
+ * 60_A
+ * 59_A
+ * 58_B
+ * 58_A
+ EOF
+'
+
+test_expect_success '--graph-indent forces indentation when graph.indent is unset' '
+ test_config log.graphIndent false &&
+ lib_test_check_graph --graph-indent _58 _59 _60 _61 _62 _63 _64 _65 _66 _67 <<-\EOF
+ * 67_A
+ * 66_A
+ * 65_A
+ * 64_A
+ * 63_A
+ * 62_A
+ * 61_A
+ * 60_A
+ * 59_A
+ * 58_B
+ * 58_A
+ EOF
+'
+
+# log.graphIndent unset and no --option (which activates graph indentation) is
+# the default state.
+
test_done