From: Pablo Sabater <pabloosabaterr@gmail.com>
To: git@vger.kernel.org
Cc: pabloosabaterr@gmail.com, ayu.chandekar@gmail.com,
chandrapratap3519@gmail.com, christian.couder@gmail.com,
gitster@pobox.com, jltobler@gmail.com, karthik.188@gmail.com,
krka@spotify.com, mroik@delayed.space, peff@peff.net,
phillip.wood@dunelm.org.uk, siddharthasthana31@gmail.com
Subject: [PATCH v10 7/7] graph: add --[no-]graph-indent and log.graphIndent
Date: Mon, 13 Jul 2026 12:44:42 +0200 [thread overview]
Message-ID: <20260713-ps-pre-commit-indent-v10-7-82ddab26bc96@gmail.com> (raw)
In-Reply-To: <20260713-ps-pre-commit-indent-v10-0-82ddab26bc96@gmail.com>
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>
---
Documentation/config/log.adoc | 4 +++
Documentation/rev-list-options.adoc | 8 ++++++
graph.c | 10 +++++--
revision.c | 9 +++++++
revision.h | 2 ++
t/t4218-log-graph-indentation.sh | 52 +++++++++++++++++++++++++++++++++++++
6 files changed, 83 insertions(+), 2 deletions(-)
diff --git a/Documentation/config/log.adoc b/Documentation/config/log.adoc
index 757a7be196..f7dfce69b5 100644
--- a/Documentation/config/log.adoc
+++ b/Documentation/config/log.adoc
@@ -59,6 +59,10 @@ This is the same as the `--decorate` option of the `git log`.
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.
diff --git a/Documentation/rev-list-options.adoc b/Documentation/rev-list-options.adoc
index eaee6ee839..af74f10bb4 100644
--- a/Documentation/rev-list-options.adoc
+++ b/Documentation/rev-list-options.adoc
@@ -1269,6 +1269,14 @@ This implies the `--topo-order` option by default, but the
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 `graph.indent` to set a deafault
+ preference.
+
ifdef::git-rev-list[]
`--count`::
Print a number stating how many commits would have been
diff --git a/graph.c b/graph.c
index c14be934a0..28bef1b88f 100644
--- a/graph.c
+++ b/graph.c
@@ -419,6 +419,8 @@ void graph_setup_line_prefix(struct diff_options *diffopt)
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)) {
@@ -435,6 +437,9 @@ static void graph_read_config(struct rev_info *revs)
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)
@@ -999,7 +1004,8 @@ static void graph_peek_next_visible(struct git_graph *graph,
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)
@@ -1344,7 +1350,7 @@ static void graph_output_commit_line(struct git_graph *graph, struct graph_line
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.
diff --git a/revision.c b/revision.c
index 258c3cf782..215cf11071 100644
--- a/revision.c
+++ b/revision.c
@@ -2627,6 +2627,12 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
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")) {
@@ -3201,6 +3207,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
if (revs->graph_max_lanes > 0 && !revs->graph)
die(_("the option '%s' requires '%s'"), "--graph-lane-limit", "--graph");
+ if (revs->graph_indent_set > 0 && !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");
diff --git a/revision.h b/revision.h
index 569b3fa1cb..49e1380b80 100644
--- a/revision.h
+++ b/revision.h
@@ -314,6 +314,8 @@ struct rev_info {
/* Display history graph */
struct git_graph *graph;
int graph_max_lanes;
+ int no_graph_indent;
+ unsigned int graph_indent_set;
/* special limits */
int skip_count;
diff --git a/t/t4218-log-graph-indentation.sh b/t/t4218-log-graph-indentation.sh
index d4c850c0d4..b69730e7ba 100755
--- a/t/t4218-log-graph-indentation.sh
+++ b/t/t4218-log-graph-indentation.sh
@@ -540,4 +540,56 @@ test_expect_success 'visual root cascading gets wrapped after 4 columns' '
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
+'
+
+# graph.indent true and no --option is the default state.
+
test_done
--
2.54.0
next prev parent reply other threads:[~2026-07-13 10:45 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 21:17 [GSoC RFC PATCH 0/1] graph: add indentation for commits preceded by a root Pablo Sabater
2026-04-02 21:17 ` [GSoC RFC PATCH 1/1] " Pablo Sabater
2026-04-03 17:55 ` Junio C Hamano
2026-04-03 18:07 ` Pablo
2026-04-03 5:04 ` [GSoC RFC PATCH 0/1] " Junio C Hamano
2026-04-03 8:25 ` Pablo
2026-04-04 9:24 ` [GSoC RFC PATCH v2 0/1] graph: add indentation for commits preceded by a parentless commit Pablo Sabater
2026-04-04 9:24 ` [GSoC RFC PATCH v2 1/1] " Pablo Sabater
2026-04-10 16:25 ` [GSoC RFC PATCH v2 0/1] " Pablo
2026-04-10 16:54 ` Junio C Hamano
2026-04-27 10:28 ` [GSoC PATCH v3 " Pablo Sabater
2026-04-27 10:28 ` [GSoC PATCH v3 1/1] " Pablo Sabater
2026-05-13 23:02 ` Jeff King
2026-05-14 10:19 ` Pablo Sabater
2026-04-27 10:35 ` [GSoC PATCH v3 0/1] " Pablo
2026-06-12 13:48 ` [PATCH v4 0/2] graph: indent visual roots in graph Pablo Sabater
2026-06-12 13:48 ` [PATCH v4 1/2] lib-log-graph: move check_graph function Pablo Sabater
2026-06-12 13:48 ` [PATCH v4 2/2] graph: indent visual root in graph Pablo Sabater
2026-06-13 3:01 ` [PATCH v4 0/2] graph: indent visual roots " Junio C Hamano
2026-06-13 19:09 ` [PATCH v5 " Pablo Sabater
2026-06-13 19:09 ` [PATCH v5 1/2] lib-log-graph: move check_graph function Pablo Sabater
2026-06-13 19:09 ` [PATCH v5 2/2] graph: indent visual root in graph Pablo Sabater
2026-06-14 4:05 ` Junio C Hamano
2026-06-14 5:28 ` Pablo Sabater
2026-06-15 15:42 ` Junio C Hamano
2026-06-16 13:06 ` Pablo Sabater
2026-06-16 16:36 ` Junio C Hamano
2026-06-17 20:27 ` Jeff King
2026-06-18 12:42 ` Pablo Sabater
2026-06-18 13:31 ` Junio C Hamano
2026-06-18 16:05 ` Jeff King
2026-06-18 16:07 ` Jeff King
2026-06-19 7:34 ` Kristofer Karlsson
2026-06-21 18:05 ` Jeff King
2026-06-22 8:29 ` Kristofer Karlsson
2026-06-17 10:33 ` [PATCH v5 0/2] graph: indent visual roots " Chandra Pratap
2026-06-20 10:11 ` [PATCH v6 0/3] " Pablo Sabater
2026-06-20 10:11 ` [PATCH v6 1/3] lib-log-graph: move check_graph function Pablo Sabater
2026-06-20 10:11 ` [PATCH v6 2/3] revision: add peek functions for lookahead Pablo Sabater
2026-06-20 10:18 ` Pablo Sabater
2026-06-20 14:56 ` Junio C Hamano
2026-06-20 15:15 ` Junio C Hamano
2026-06-21 1:48 ` Junio C Hamano
2026-06-21 6:42 ` Chandra Pratap
2026-06-22 8:28 ` Kristofer Karlsson
2026-06-29 21:56 ` Junio C Hamano
2026-06-29 23:29 ` Pablo Sabater
2026-06-20 10:11 ` [PATCH v6 3/3] graph: indent visual root in graph Pablo Sabater
2026-07-04 8:52 ` [PATCH v7 0/3] graph: indent visual roots " Pablo Sabater
2026-07-04 8:52 ` [PATCH v7 1/3] lib-log-graph: move check_graph function Pablo Sabater
2026-07-04 8:52 ` [PATCH v7 2/3] graph: add a 2 commit buffer for lookahead Pablo Sabater
2026-07-06 9:49 ` Chandra Pratap
2026-07-06 13:44 ` Kristofer Karlsson
2026-07-06 15:33 ` Chandra Pratap
2026-07-07 6:31 ` Pablo Sabater
2026-07-07 18:12 ` Pablo Sabater
2026-07-04 8:52 ` [PATCH v7 3/3] graph: indent visual root in graph Pablo Sabater
2026-07-10 10:37 ` [PATCH v8 0/4] graph: indent visual roots " Pablo Sabater
2026-07-10 10:37 ` [PATCH v8 1/4] lib-log-graph: move check_graph function Pablo Sabater
2026-07-10 10:37 ` [PATCH v8 2/4] revision: add next_commit_to_show() Pablo Sabater
2026-07-10 10:37 ` [PATCH v8 3/4] graph: add a 2 commit buffer for lookahead Pablo Sabater
2026-07-10 10:37 ` [PATCH v8 4/4] graph: indent visual root in graph Pablo Sabater
2026-07-10 18:07 ` Mirko Faina
2026-07-10 20:29 ` Pablo Sabater
2026-07-11 13:37 ` [PATCH v9 0/4] graph: indent visual roots " Pablo Sabater
2026-07-11 13:37 ` [PATCH v9 1/4] lib-log-graph: move check_graph function Pablo Sabater
2026-07-11 13:37 ` [PATCH v9 2/4] revision: add next_commit_to_show() Pablo Sabater
2026-07-11 13:37 ` [PATCH v9 3/4] graph: add a 2 commit buffer for lookahead Pablo Sabater
2026-07-11 13:37 ` [PATCH v9 4/4] graph: indent visual root in graph Pablo Sabater
2026-07-11 14:15 ` [PATCH v9 0/4] graph: indent visual roots " Mirko Faina
2026-07-11 15:41 ` Pablo Sabater
2026-07-11 16:25 ` Mirko Faina
2026-07-12 5:56 ` Chandra Pratap
2026-07-12 13:10 ` Mirko Faina
2026-07-12 13:12 ` Mirko Faina
2026-07-12 16:59 ` Pablo Sabater
2026-07-12 19:33 ` Mirko Faina
2026-07-13 7:41 ` Chandra Pratap
2026-07-13 10:44 ` [PATCH v10 0/7] " Pablo Sabater
2026-07-13 10:44 ` [PATCH v10 1/7] lib-log-graph: move check_graph function Pablo Sabater
2026-07-13 10:44 ` [PATCH v10 2/7] revision: add next_commit_to_show() Pablo Sabater
2026-07-13 10:44 ` [PATCH v10 3/7] graph: add a 2 commit buffer for lookahead Pablo Sabater
2026-07-13 10:44 ` [PATCH v10 4/7] graph: indent visual root in graph Pablo Sabater
2026-07-13 10:44 ` [PATCH v10 5/7] graph: wrap cascading commits after 4 columns Pablo Sabater
2026-07-13 10:44 ` [PATCH v10 6/7] graph: move config reading into graph_read_config() Pablo Sabater
2026-07-13 10:44 ` Pablo Sabater [this message]
2026-07-13 14:06 ` [PATCH v10 7/7] graph: add --[no-]graph-indent and log.graphIndent Mirko Faina
2026-07-13 16:16 ` Pablo Sabater
2026-07-13 16:43 ` [PATCH v11 0/7] graph: indent visual roots in graph Pablo Sabater
2026-07-13 16:43 ` [PATCH v11 1/7] lib-log-graph: move check_graph function Pablo Sabater
2026-07-13 16:43 ` [PATCH v11 2/7] revision: add next_commit_to_show() Pablo Sabater
2026-07-13 16:44 ` [PATCH v11 3/7] graph: add a 2 commit buffer for lookahead Pablo Sabater
2026-07-13 16:44 ` [PATCH v11 4/7] graph: indent visual root in graph Pablo Sabater
2026-07-13 16:44 ` [PATCH v11 5/7] graph: wrap cascading commits after 4 columns Pablo Sabater
2026-07-13 16:44 ` [PATCH v11 6/7] graph: move config reading into graph_read_config() Pablo Sabater
2026-07-13 16:44 ` [PATCH v11 7/7] graph: add --[no-]graph-indent and log.graphIndent Pablo Sabater
2026-07-14 10:19 ` Chandra Pratap
2026-07-14 11:47 ` Pablo Sabater
2026-07-13 20:28 ` [PATCH v11 0/7] graph: indent visual roots in graph Junio C Hamano
2026-07-13 20:51 ` Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 " Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 1/7] lib-log-graph: move check_graph function Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 2/7] revision: add next_commit_to_show() Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 3/7] graph: add a 2 commit buffer for lookahead Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 4/7] graph: indent visual root in graph Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 5/7] graph: wrap cascading commits after 4 columns Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 6/7] graph: move config reading into graph_read_config() Pablo Sabater
2026-07-14 12:09 ` [PATCH v12 7/7] graph: add --[no-]graph-indent and log.graphIndent Pablo Sabater
2026-05-14 15:15 ` [GSoC RFC PATCH 0/1] graph: add indentation for commits preceded by a root Phillip Wood
2026-05-14 17:45 ` Pablo Sabater
2026-05-15 9:33 ` Phillip Wood
2026-05-17 6:31 ` Chandra Pratap
2026-05-18 13:26 ` Pablo Sabater
2026-05-19 0:03 ` Junio C Hamano
2026-05-19 5:59 ` Pablo Sabater
2026-06-10 15:21 ` Junio C Hamano
2026-06-10 15:28 ` Pablo Sabater
2026-05-19 10:39 ` Chandra Pratap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260713-ps-pre-commit-indent-v10-7-82ddab26bc96@gmail.com \
--to=pabloosabaterr@gmail.com \
--cc=ayu.chandekar@gmail.com \
--cc=chandrapratap3519@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=krka@spotify.com \
--cc=mroik@delayed.space \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
--cc=siddharthasthana31@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox