Bug: "orphaned" trees indistinguishable in git log --graph output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I noticed a problem how git log --graph represents orphaned trees, i.e.
how it renders a forest (and not just a single tree). If a repository
is comprised of multiple unconnected trees it can easily happen that
their commits are intertwined in the output of git log --graph so that
the root of one tree seems to be (re)based on a commit of the other
tree and there is no indication that they are indeed separate.

This first example shows the problem in the first indention level:

mkdir git-log-decorate-forest1
cd git-log-decorate-forest1
git init
git commit --allow-empty -m"Tree 1 - branch 1 - commit 1"
git branch tree1_branch1
git checkout --orphan tree2_branch1
git commit --allow-empty -m"Tree 2 - branch 1 - commit 1"
git log --decorate --graph --oneline --all

The log call at the end leads to something like this:

* 73c925a (tree1_branch1, master) Tree 1 - branch 1 - commit 1
* e22a694 (HEAD -> tree2_branch1) Tree 2 - branch 1 - commit 1

Note the asterisks in the beginning that usually indicates that the
commit sits "on top" of the previous one (in contrast to "|" used for
distinct branches). There is no way to tell from the output that the
two commits reside on different trees.

The second example shows that the problem also happens at deeper
indention levels if multiple branches are involved.
NB: the sleep is important due to git log's sorting (I did not try to
understand the details though).

mkdir git-log-decorate-forest2
cd git-log-decorate-forest2
git init
git commit --allow-empty -m"Tree 1 - branch 1 - commit 1"
git commit --allow-empty -m"Tree 1 - branch 1 - commit 2"
git branch tree1_branch1
git checkout --orphan tree2_branch1
git commit --allow-empty -m"Tree 2 - branch 1 - commit 1"
git checkout master
git reset --hard tree1_branch1^
git commit --allow-empty -m"Tree 1 - branch 2 - commit 2"
git branch tree1_branch2
git checkout tree2_branch1 
sleep 1
git commit --amend --no-edit --allow-empty
git checkout master
git commit --allow-empty -m"Tree 1 - branch 2 - commit 3"
git log --decorate --graph --oneline --all

The git log output looks something like this:
* ae86680 (HEAD -> master) Tree 1 - branch 2 - commit 3
* 844c8c3 (tree1_branch2) Tree 1 - branch 2 - commit 2
| * 8e6ed1e (tree2_branch1) Tree 2 - branch 1 - commit 1
| * 3fc176d (tree1_branch1) Tree 1 - branch 1 - commit 2
|/  
* 88b8313 Tree 1 - branch 1 - commit 1

Note how 8e6ed1e looks as if it sits on top of 3fc176d? But it doesn't.
It's an orphaned commit and thus part of a completely separated tree!

In gitk one has to enable the display of all branches but then the two
trees are distinguishable. gitg works fine (for once) as well.
The output of git-cola's DAG viewer is even worse than git log's
output: there (the commit of) the second tree is embedded in the master
branch between tree1_branch2 and the initial commit of tree 1 (88b8313)!

Here are the (outdated) versions of the tools tested:
git version 2.11.0
gitg 3.23.0
cola version 2.10

If the test cases above no longer work I can try to reproduce the
problem with git's HEAD if need be. I really hope I have not overlooked
any related bug reports or even a fix... the issue is a bit hard to
search for ;)

As a fix I guess it would make sense to have additional indention for
the distinct trees... just like how branches are indented but of course
without the |/ split below.

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux