🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
9 messages
9 total messages Started by "herr.kaste" Tue, 13 Oct 2026 19:00
log --graph draws an orphaned branch with parents
#413
Author: "herr.kaste"
Date: Tue, 13 Oct 2026 19:00
67 lines
10357 bytes
Hi!  I have the following:

Checkout https://github.com/packagecontrol/thecrawl.git then draw the graph

$ git log --graph --all --oneline

a few pages down, (I don't have a more minimal reproduction, --all is required)
I see

What happened? (Actual behavior)

* | | 03b117815 Changed metadata of `Modelines`
* | | 30f679f1f Bulk edit
 \ | |
  * | | 5a2cecdd9 Initial revision
 / /
| | * 6062ecf4f (origin/feat/compare-registries) Add script to compare
two registries
| |/
| * 8f034813a Clarify fatal crawl skip logs

5a2cecdd9 is actually the birth of an orphaned branch, gitk also shows
it like that.

What did you expect to happen? (Expected behavior)

E.g. something like this:

● | | 03b117815 Changed metadata of `Modelines`
● | | 30f679f1f Bulk edit
● | | 5a2cecdd9 Initial revision
 / /
| | ● 6062ecf4f (origin/feat/compare-registries) ...
| |/
| ● 8f034813a Clarify fatal crawl skip logs

What's different between what you expected and what actually happened?
An obvious drawing error, 5a2cecdd9 is drawn as if it had parents, and
the rightmost lane goes to nirvana.

[System Info]
git version:
git version 2.56.0.windows.2
cpu: x86_64
built from commit: cc4dbf752a05efdc0e04e71fd3e8110d11bdd35c
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
rust: disabled
feature: fsmonitor--daemon
gettext: enabled
libcurl: 8.22.0
OpenSSL: OpenSSL 3.5.9 29 Sep 2026
zlib: 1.3.2
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
default-ref-format: files
default-hash: sha1
uname: Windows 10.0 26200
compiler info: gnuc: 16.2
libc info: no libc information available
$SHELL (typically, interactive shell): C:\Dev\Git\usr\bin\bash.exe

Regards
Caspar Duregger
Re: log --graph draws an orphaned branch with parents
#2265
Author: "herr.kaste"
Date: Tue, 03 Nov 2026 19:25
110 lines
14404 bytes
Finally had time for a repro (tested with git 2.56.0.windows.3):

sh
git init -q -b main repro && cd repro
export GIT_COMMITTER_DATE="@1700000000 +0000"
GIT_AUTHOR_DATE="@1700000000 +0000"
git commit -q --allow-empty -m B
git switch -q -c topic
git commit -q --allow-empty -m T
git switch -q --orphan orphan
git commit -q --allow-empty -m R
git merge -q --allow-unrelated-histories --no-ff -m M main
git log --graph --oneline --all

Actual output:

*   40a81a9 M
|\
 \ |
  * | 1d9120a R
 /
| * 5a29a85 T
|/
* f1cd12c B

With --no-graph-indent:

*   40a81a9 M
|\
* | 1d9120a R
 /
| * 5a29a85 T
|/
* f1cd12c B

Regards
Caspar


Am Di., 13. Okt. 2026 um 21:00 Uhr schrieb herr.kaste <herr.kaste@gmail.com>:
>
> Hi!  I have the following:
>
> Checkout https://github.com/packagecontrol/thecrawl.git then draw the graph
>
> $ git log --graph --all --oneline
>
> a few pages down, (I don't have a more minimal reproduction, --all is required)
> I see
>
> What happened? (Actual behavior)
>
> * | | 03b117815 Changed metadata of `Modelines`
> * | | 30f679f1f Bulk edit
>  \ | |
>   * | | 5a2cecdd9 Initial revision
>  / /
> | | * 6062ecf4f (origin/feat/compare-registries) Add script to compare
> two registries
> | |/
> | * 8f034813a Clarify fatal crawl skip logs
>
> 5a2cecdd9 is actually the birth of an orphaned branch, gitk also shows
> it like that.
>
> What did you expect to happen? (Expected behavior)
>
> E.g. something like this:
>
> ● | | 03b117815 Changed metadata of `Modelines`
> ● | | 30f679f1f Bulk edit
> ● | | 5a2cecdd9 Initial revision
>  / /
> | | ● 6062ecf4f (origin/feat/compare-registries) ...
> | |/
> | ● 8f034813a Clarify fatal crawl skip logs
>
> What's different between what you expected and what actually happened?
> An obvious drawing error, 5a2cecdd9 is drawn as if it had parents, and
> the rightmost lane goes to nirvana.
>
> [System Info]
> git version:
> git version 2.56.0.windows.2
> cpu: x86_64
> built from commit: cc4dbf752a05efdc0e04e71fd3e8110d11bdd35c
> sizeof-long: 4
> sizeof-size_t: 8
> shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
> rust: disabled
> feature: fsmonitor--daemon
> gettext: enabled
> libcurl: 8.22.0
> OpenSSL: OpenSSL 3.5.9 29 Sep 2026
> zlib: 1.3.2
> SHA-1: SHA1_DC
> SHA-256: SHA256_BLK
> default-ref-format: files
> default-hash: sha1
> uname: Windows 10.0 26200
> compiler info: gnuc: 16.2
> libc info: no libc information available
> $SHELL (typically, interactive shell): C:\Dev\Git\usr\bin\bash.exe
>
> Regards
> Caspar Duregger
Re: log --graph draws an orphaned branch with parents
#2282
Author: "Pablo Sabater"
Date: Tue, 03 Nov 2026 21:27
62 lines
12388 bytes
On Tue Nov 3, 2026 at 7:25 PM WET, herr.kaste wrote:
> Finally had time for a repro (tested with git 2.56.0.windows.3):
>
> sh
> git init -q -b main repro && cd repro
> export GIT_COMMITTER_DATE="@1700000000 +0000"
> GIT_AUTHOR_DATE="@1700000000 +0000"
> git commit -q --allow-empty -m B
> git switch -q -c topic
> git commit -q --allow-empty -m T
> git switch -q --orphan orphan
> git commit -q --allow-empty -m R
> git merge -q --allow-unrelated-histories --no-ff -m M main
> git log --graph --oneline --all

Hi!

Thanks for the repro and the bug report.

>
> Actual output:

The bug is because the indentation state GRAPH_PRE_ROOT is being
triggered, due to "R" being a root. What this state does is add a new
row to connect the indentation:

>
> *   40a81a9 M
> |\
>  \ |
^^^
This one

>   * | 1d9120a R

Then it pushes everything to the right.

>  /
> | * 5a29a85 T
> |/
> * f1cd12c B
>
> With --no-graph-indent:
>
> *   40a81a9 M
> |\
> * | 1d9120a R
>  /
> | * 5a29a85 T
> |/
> * f1cd12c B

The fix should be that the rendering of the graph is the same with the
indentation or without it, as there is nothing ambiguous in this case
that needs it.

I think I may be able to see how to fix it tomorrow, but I'm quite busy
until next week.

Regards,
Pablo
Re: log --graph draws an orphaned branch with parents
#2283
Author: "Pablo Sabater"
Date: Tue, 03 Nov 2026 21:29
10 lines
11263 bytes
On Tue Nov 3, 2026 at 9:27 PM WET, Pablo Sabater wrote:
>
> I think I may be able to see how to fix it tomorrow, but I'm quite busy
> until next week.

I forgot to ask if you want to try to fix it yourself, I'm happy to
review it :).

Pablo.
Re: log --graph draws an orphaned branch with parents
#2286
Author: "herr.kaste"
Date: Tue, 03 Nov 2026 21:51
125 lines
13920 bytes
From 48bbcf965dc630251cc32f38d7efca5e6fb77c5e Mon Sep 17 00:00:00 2001
From: Caspar Duregger <caspar.duregger@gmail.com>
Date: Tue, 3 Nov 2026 22:38:22 +0100
Subject: [PATCH] graph: do not indent visual roots with columns to their right

Since a34c00d96 (graph: indent visual root in graph, 2026-07-14), a
visual root that has a child is drawn indented, connected to its child
by an extra GRAPH_PRE_ROOT line.  When there are columns to the right
of the root, this breaks the graph:

*   M
|\
\ |
 * | R
/
| * T
|/
* B

graph_output_pre_root_line() writes the extra " " for the root column
without shifting the columns to its right, so they are drawn between
two columns.  graph_output_commit_line() then pushes them one column
to the right, but the following GRAPH_COLLAPSING line is computed from
the mapping, which knows nothing about that offset.  The column next
to R does not continue into the next line, and with more columns to
the right of R one of them goes nowhere.

But in this situation the indentation is not needed in the first
place.  The columns to the right of the root collapse into its column
once it is rendered, so the collapsing line always leaves a blank
right below the root, and the next commit cannot end up vertically
adjacent to it.

Do not consider a commit a visual root when there are columns to its
right, which gives:

*   M
|\
* | R
/
| * T
|/
* B

Signed-off-by: Caspar Duregger <caspar.duregger@gmail.com>
---
 graph.c                          | 12 ++++++++++++
 t/t4218-log-graph-indentation.sh | 18 ++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/graph.c b/graph.c
index 28bef1b88..95eef3a95 100644
--- a/graph.c
+++ b/graph.c
@@ -969,10 +969,22 @@ static int graph_is_visual_root(struct git_graph *graph,
  * already a column, so it will not be rendered below, the
  * current commit has to act as the last commit and omit
  * indentation.
+ *
+ * If there are columns to the right of the commit, they collapse
+ * into its column once it is rendered, so nothing can be rendered
+ * right below it and there is no need to indent it.
+ *
+ *   * | <- visual root with a column to its right
+ *    /
+ *   | *
+ *
+ * Indenting it would also push these columns to the right, but
+ * the collapsing code does not know about that offset.
  */
  return graph_is_visual_root_candidate(graph->commit, graph) &&
        !(graph->commit_in_columns &&
  graph->columns[graph->commit_index].is_merge_parent) &&
+       graph->commit_index + 1 >= graph->num_columns &&
        flags->is_next_visible &&
        (!flags->next_has_column || graph->visual_root_depth > 0);
 }
diff --git a/t/t4218-log-graph-indentation.sh b/t/t4218-log-graph-indentation.sh
index 24dc9b497..b3b9f7c14 100755
--- a/t/t4218-log-graph-indentation.sh
+++ b/t/t4218-log-graph-indentation.sh
@@ -449,6 +449,24 @@ test_expect_success 'two unrelated merges' '
  EOF
 '

+test_expect_success 'visual root with columns to its right is not indented' '
+ create_orphan _70 && test_commit 70_A &&
+ git checkout -b _71 && test_commit 71_A &&
+ create_orphan _72 && test_commit 72_A &&
+ TREE=$(git write-tree) &&
+ MERGE=$(git commit-tree $TREE -p _72 -p _70 -m 72_merge) &&
+ git reset --hard $MERGE &&
+ lib_test_check_graph _72 _71 <<-\EOF
+ *   72_merge
+ |\
+ * | 72_A
+ /
+ | * 71_A
+ |/
+ * 70_A
+ EOF
+'
+
 test_expect_success '--max-count treats the last visible commit as
the last commit' '
  lib_test_check_graph --max-count=2 _8 _9 _10 <<-\EOF
   * 10_A
-- 
2.56.0.350.g48bbcf965


Am Di., 3. Nov. 2026 um 22:29 Uhr schrieb Pablo Sabater
<pabloosabaterr@gmail.com>:
>
> On Tue Nov 3, 2026 at 9:27 PM WET, Pablo Sabater wrote:
> >
> > I think I may be able to see how to fix it tomorrow, but I'm quite busy
> > until next week.
>
> I forgot to ask if you want to try to fix it yourself, I'm happy to
> review it :).
>
> Pablo.
>
Re: log --graph draws an orphaned branch with parents
#2291
Author: "Pablo Sabater"
Date: Tue, 03 Nov 2026 22:40
13 lines
11489 bytes
On Tue Nov 3, 2026 at 9:51 PM WET, herr.kaste wrote:
> From 48bbcf965dc630251cc32f38d7efca5e6fb77c5e Mon Sep 17 00:00:00 2001
> From: Caspar Duregger <caspar.duregger@gmail.com>
> Date: Tue, 3 Nov 2026 22:38:22 +0100
> Subject: [PATCH] graph: do not indent visual roots with columns to their right

Thanks for the patch, but it's wrongly formatted so b4 shazam can't find
it to apply it, could you sned it with git send-email?

Regards,
Pablo
[PATCH] graph: do not indent visual roots with columns to their right
#2293
Author: Caspar Duregger
Date: Tue, 03 Nov 2026 23:11
104 lines
14150 bytes
Since a34c00d96 (graph: indent visual root in graph, 2026-07-14), a
visual root that has a child is drawn indented, connected to its child
by an extra GRAPH_PRE_ROOT line.  When there are columns to the right
of the root, this breaks the graph:

	*   M
	|\
	 \ |
	  * | R
	 /
	| * T
	|/
	* B

graph_output_pre_root_line() writes the extra " " for the root column
without shifting the columns to its right, so they are drawn between
two columns.  graph_output_commit_line() then pushes them one column
to the right, but the following GRAPH_COLLAPSING line is computed from
the mapping, which knows nothing about that offset.  The column next
to R does not continue into the next line, and with more columns to
the right of R one of them goes nowhere.

But in this situation the indentation is not needed in the first
place.  The columns to the right of the root collapse into its column
once it is rendered, so the collapsing line always leaves a blank
right below the root, and the next commit cannot end up vertically
adjacent to it.

Do not consider a commit a visual root when there are columns to its
right, which gives:

	*   M
	|\
	* | R
	 /
	| * T
	|/
	* B

Signed-off-by: Caspar Duregger <caspar.duregger@gmail.com>
---
 graph.c                          | 12 ++++++++++++
 t/t4218-log-graph-indentation.sh | 18 ++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/graph.c b/graph.c
index 28bef1b88..95eef3a95 100644
--- a/graph.c
+++ b/graph.c
@@ -969,10 +969,22 @@ static int graph_is_visual_root(struct git_graph *graph,
 	 * already a column, so it will not be rendered below, the
 	 * current commit has to act as the last commit and omit
 	 * indentation.
+	 *
+	 * If there are columns to the right of the commit, they collapse
+	 * into its column once it is rendered, so nothing can be rendered
+	 * right below it and there is no need to indent it.
+	 *
+	 *   * | <- visual root with a column to its right
+	 *    /
+	 *   | *
+	 *
+	 * Indenting it would also push these columns to the right, but
+	 * the collapsing code does not know about that offset.
 	 */
 	return graph_is_visual_root_candidate(graph->commit, graph) &&
 	       !(graph->commit_in_columns &&
 		 graph->columns[graph->commit_index].is_merge_parent) &&
+	       graph->commit_index + 1 >= graph->num_columns &&
 	       flags->is_next_visible &&
 	       (!flags->next_has_column || graph->visual_root_depth > 0);
 }
diff --git a/t/t4218-log-graph-indentation.sh b/t/t4218-log-graph-indentation.sh
index 24dc9b497..b3b9f7c14 100755
--- a/t/t4218-log-graph-indentation.sh
+++ b/t/t4218-log-graph-indentation.sh
@@ -449,6 +449,24 @@ test_expect_success 'two unrelated merges' '
 	EOF
 '
 
+test_expect_success 'visual root with columns to its right is not indented' '
+	create_orphan _70 && test_commit 70_A &&
+	git checkout -b _71 && test_commit 71_A &&
+	create_orphan _72 && test_commit 72_A &&
+	TREE=$(git write-tree) &&
+	MERGE=$(git commit-tree $TREE -p _72 -p _70 -m 72_merge) &&
+	git reset --hard $MERGE &&
+	lib_test_check_graph _72 _71 <<-\EOF
+	*   72_merge
+	|\
+	* | 72_A
+	 /
+	| * 71_A
+	|/
+	* 70_A
+	EOF
+'
+
 test_expect_success '--max-count treats the last visible commit as the last commit' '
 	lib_test_check_graph --max-count=2 _8 _9 _10 <<-\EOF
 	  * 10_A
-- 
2.56.0.windows.3
Re: [PATCH] graph: do not indent visual roots with columns to their right
#2294
Author: "Pablo Sabater"
Date: Tue, 03 Nov 2026 23:39
11 lines
11426 bytes
On Tue Nov 3, 2026 at 11:11 PM WET, Caspar Duregger wrote:
> Since a34c00d96 (graph: indent visual root in graph, 2026-07-14), a
> visual root that has a child is drawn indented, connected to its child
> by an extra GRAPH_PRE_ROOT line.  When there are columns to the right
> of the root, this breaks the graph:

The patch looks good to me!

Regards,
Pablo
Re: [PATCH] graph: do not indent visual roots with columns to their right
#2346
Author: Junio C Hamano
Date: Wed, 04 Nov 2026 18:00
15 lines
13117 bytes
"Pablo Sabater" <pabloosabaterr@gmail.com> writes:

> On Tue Nov 3, 2026 at 11:11 PM WET, Caspar Duregger wrote:
>> Since a34c00d96 (graph: indent visual root in graph, 2026-07-14), a
>> visual root that has a child is drawn indented, connected to its child
>> by an extra GRAPH_PRE_ROOT line.  When there are columns to the right
>> of the root, this breaks the graph:
>
> The patch looks good to me!
>
> Regards,
> Pablo

Thanks, both.  Queued.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads