From: Dominik Maier <dmnk@google.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Pablo Sabater <pabloosabaterr@gmail.com>,
Caspar Duregger <caspar.duregger@gmail.com>,
dmnk+artist@google.com, Dominik Maier <dmnk@google.com>
Subject: [PATCH] graph: do not fuse merge parents into left columns
Date: Thu, 19 Nov 2026 20:22:47 +0100 [thread overview]
Message-ID: <20261119192247.2671852-1-dmnk@google.com> (raw)
In graph_insert_into_new_columns(), the branch that coalesces a column
into graph->mapping[graph->width - 2] and resets graph->edges_added = -1
is intended for existing columns to the right of a merge commit
(idx < 0) so that two adjacent edges can join immediately as "|\|".
When a merge commit itself is skewed left (merge_layout == 0), its first
parent does not advance graph->width, leaving graph->width - 2 pointing
at the column immediately to the left of the merge commit. If the second
parent of a 4+-parent octopus merge matches that column while idx >= 0,
it overwrites graph->mapping[graph->width - 2] without advancing
graph->width and resets graph->edges_added = -1. Subsequent parents are
placed one slot too far left, leaving the last dashed-parent slot in
graph->mapping[] at -1 and indexing graph->new_columns[-1] in
graph_draw_octopus_merge().
Restrict the right-neighbor edge fusion to existing non-merge columns
(idx < 0) and guard against negative mapping indices in
graph_draw_octopus_merge().
Signed-off-by: Dominik Maier <dmnk@google.com>
---
graph.c | 5 ++++-
t/t4215-log-skewed-merges.sh | 31 +++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/graph.c b/graph.c
index 95eef3a95e..a40834a639 100644
--- a/graph.c
+++ b/graph.c
@@ -685,7 +685,8 @@ static void graph_insert_into_new_columns(struct git_graph *graph,
mapping_idx = graph->width + (graph->merge_layout - 1) * shift;
graph->width += 2 * graph->merge_layout;
- } else if (graph->edges_added > 0 && i == graph->mapping[graph->width - 2]) {
+ } else if (idx < 0 && graph->edges_added > 0 &&
+ i == graph->mapping[graph->width - 2]) {
/*
* If some columns have been added by a merge, but this commit
* was found in the last existing column, then adjust the
@@ -1317,6 +1318,8 @@ static void graph_draw_octopus_merge(struct git_graph *graph, struct graph_line
for (i = 0; i < dashed_parents; i++) {
j = graph->mapping[(graph->commit_index + i + 2) * 2];
+ if (j < 0)
+ BUG("octopus merge mapping uninitialized");
col = &graph->new_columns[j];
graph_line_write_column(line, col, '-');
diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh
index eebab71039..632c7d2c97 100755
--- a/t/t4215-log-skewed-merges.sh
+++ b/t/t4215-log-skewed-merges.sh
@@ -509,4 +509,35 @@ test_expect_success 'log --graph --graph-lane-limit=7 check if it shows all 3 pa
EOF
'
+test_expect_success 'log --graph left-skewed 4-parent octopus merge joining adjacent left column' '
+ git checkout --orphan 8_p &&
+ test_commit 8_root &&
+ git checkout -b 8_pA 8_p && test_commit 8_A &&
+ git checkout -b 8_pB 8_p && test_commit 8_B &&
+ git checkout -b 8_pC 8_p && test_commit 8_C &&
+ git checkout -b 8_pD 8_p && test_commit 8_D &&
+ git checkout -b 8_M 8_pA &&
+ git merge --no-ff 8_pB 8_pC 8_pD -m 8_M &&
+ git checkout 8_pB && test_commit 8_B2 &&
+ git checkout -b 8_TOP 8_pA &&
+ git merge --no-ff 8_pB 8_M -m 8_TOP &&
+
+ lib_test_check_graph --date-order 8_TOP <<-\EOF
+ *-. 8_TOP
+ |\ \
+ | * | 8_B2
+ | | *-. 8_M
+ | |/|\ \
+ |/|/ / /
+ | | | * 8_D
+ | | * | 8_C
+ | | |/
+ | * / 8_B
+ | |/
+ * / 8_A
+ |/
+ * 8_root
+ EOF
+'
+
test_done
--
2.56.1.750.gf70dc682cf-goog
next reply other threads:[~2026-11-19 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:22 Dominik Maier [this message]
2026-11-20 10:50 ` [PATCH] graph: do not fuse merge parents into left columns Caspar Duregger
2026-11-24 18:05 ` [PATCH v2] graph: do not fuse merge parents with the column to their left Dominik Maier
2026-11-25 9:37 ` Caspar Duregger
2026-11-26 7:17 ` Junio C Hamano
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=20261119192247.2671852-1-dmnk@google.com \
--to=dmnk@google.com \
--cc=caspar.duregger@gmail.com \
--cc=dmnk+artist@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pabloosabaterr@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.