TamaMcGlinn / git-forest

git-forest is a visual terminal tree viewer to replace `git log --graph`
3 stars 1 forks source link

Cascade rendered when using path #2

Closed TamaMcGlinn closed 2 years ago

TamaMcGlinn commented 2 years ago

When you use a path, for instance from a buffer, with this mapping standing for git log this file:

nnoremap <leader>glt :Flog -format=%ad\ [%h]\ {%an}%d\ (%S)\ %s -all -path=%<CR>

You should get something at least somewhat readable. Preferably, child-parent relationships should be drawn wherever there is a descendant-ancestor relationship, since the commits in between are being excluded on purpose. This would allow us to still understand what branches are based on what.

Currently, this is what you see:

TamaMcGlinn commented 2 years ago

(this bug was misfiled under vim-flog, but belongs here)

rbong commented 2 years ago

Some insight on why this might be happening.

Using the git repository for git itself.

Using git-forest --max-count=4 --pretty=format:%h df7375d772 README.md:

┌ df7375d772
│ ┌ 6081d3898f
│ ├ 9ae7dcb402
│ │ ┌ 46c67492aa

Using git log --graph --max-count=4 --format=%h df7375d772 README.md:

* df7375d772
* 6081d3898f
* 9ae7dcb402
* 46c67492aa

We can use the %p format specifier to show parent hashes.

$ git log --graph --max-count=4 --format="%h
parents: %p     
" df7375d772 README.md

* df7375d772
| parents: 6081d3898f     
| 
* 6081d3898f
| parents: 9ae7dcb402     
| 
* 9ae7dcb402
| parents: 46c67492aa     
| 
* 46c67492aa
| parents: 7926cee904     
| 

Note that in this output all of the parent hashes are connected to the next commit.

We can get different behaviour by removing --graph:

$ git log --max-count=4 --format="%h
parents: %p
" df7375d772 README.md

df7375d772
parents: 4a6e4b9602     

6081d3898f
parents: 9ae7dcb402     

9ae7dcb402
parents: 889cacb689     

46c67492aa
parents: 5fa0f5238b     

Note that in this output the parent hashes are not connected to the next commit, except for the two that are connected in the git-forest output.

rbong commented 2 years ago

I've got it, from the --graph option documentation:

This enables parent rewriting, see History Simplification above.

There is no option to directly enable parent rewriting, but --parents also enables this:

--parents Print also the parents of the commit (in the form "commit parent..."). Also enables parent rewriting, see History Simplification above.

With a custom format this has no impact on the output.

Fix incoming.

TamaMcGlinn commented 2 years ago

Fixed by #3