git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Commit graph not using minimal number of columns

From
Derrick Stolee <derrickstolee@github.com>
Date
Apr 26, 2023, 10:45 UTC
Message-ID
<86188f31-f492-d195-d4d5-b0582906621a@github.com>
In-Reply-To
<xmqq8refy114.fsf@gitster.g>
On 4/25/2023 7:50 PM, Junio C Hamano wrote:
> Javier Mora <cousteaulecommandant@gmail.com> writes:
> 
>> git log --all --decorate --oneline --graph
>> # ^ displays a complete mess that doesn't resemble two tracks
That mess is this:
*   ac6812d (HEAD -> fork) Merge branch 'main' (early part) into fork
|\  
* \   92dbe19 Merge branch 'main' into fork
|\ \  
* \ \   c372f7b Merge branch 'main' into fork
|\ \ \  
* \ \ \   48cae29 Merge branch 'main' into fork
|\ \ \ \  
* \ \ \ \   1bd2ff0 Merge branch 'main' into fork
|\ \ \ \ \  
* \ \ \ \ \   a5ab648 Merge branch 'main' into fork
|\ \ \ \ \ \  
* | | | | | | 362d201 Introduced feature Z
| | | | | | | * d46dfcc (main) Add H
| | | | | | |/  
| | | | | | * ac40305 Add G
| | | | | |/  
| | | | | * 867e17a Add F
| | | | |/  
| | | | * 23b1d2b Add E
| | | |/  
| | | * 8c36fda Add D
| | |/  
| | * cae1373 Add C
| |/  
| * 808c738 Add B
|/  
* 20b84d5 First commit

This width is necessary to avoid crossing lines _given the order of the commits_, which is picked independently of the graph rendering.

> "git log --all --oneline --graph --date-order"?

Here is that output, breaking topological ties with the commit date order:

*   ac6812d (HEAD -> fork) Merge branch 'main' (early part) into fork
|\  
| | * d46dfcc (main) Add H
| |/  
| * ac40305 Add G
* | 92dbe19 Merge branch 'main' into fork
|\| 
* |   c372f7b Merge branch 'main' into fork
|\ \  
| | * 867e17a Add F
| |/  
* |   48cae29 Merge branch 'main' into fork
|\ \  
| | * 23b1d2b Add E
| |/  
* |   1bd2ff0 Merge branch 'main' into fork
|\ \  
| | * 8c36fda Add D
| |/  
* |   a5ab648 Merge branch 'main' into fork
|\ \  
| | * cae1373 Add C
| |/  
* | 362d201 Introduced feature Z
| * 808c738 Add B
|/  
* 20b84d5 First commit

But really, the key issue is that both branches are being used as tips. This means that in --topo-order (implied by --graph), every commit reachable from 'fork' but not 'main' must be shown before the first commit of 'main'.

If we only use 'fork' as a starting point, then the --topo-order is the best of all the options:

*   ac6812d (HEAD -> fork) Merge branch 'main' (early part) into fork
|\  
| * ac40305 Add G
* | 92dbe19 Merge branch 'main' into fork
|\| 
| * 867e17a Add F
* | c372f7b Merge branch 'main' into fork
|\| 
| * 23b1d2b Add E
* | 48cae29 Merge branch 'main' into fork
|\| 
| * 8c36fda Add D
* | 1bd2ff0 Merge branch 'main' into fork
|\| 
| * cae1373 Add C
* | a5ab648 Merge branch 'main' into fork
|\| 
| * 808c738 Add B
* | 362d201 Introduced feature Z
|/  
* 20b84d5 First commit

I don't think there is anything actionable to do here, as these commit-ordering options are well-defined and should not be altered. If there was an algorithm to modify the commit order in such a way that minimized the graph output, that would be interesting, but the cases it minimizes are probably too rare to be worth the effort.

Thanks, -Stolee

Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 8 in “Commit graph not using minimal number of columns”
  1. Javier MoraApr 25, 2023
  2. Junio C HamanoApr 25, 2023
  3. Derrick StoleeApr 26, 2023
  4. Junio C HamanoApr 26, 2023
  5. Derrick StoleeApr 26, 2023
  6. Junio C HamanoApr 26, 2023
  7. Derrick StoleeApr 27, 2023
  8. Junio C HamanoApr 27, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.