git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug: "orphaned" trees indistinguishable in git log --graph output
@ 2019-02-26 17:26 Stefan Tauner
  2019-02-26 21:09 ` Rafael Ascensão
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Tauner @ 2019-02-26 17:26 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug: "orphaned" trees indistinguishable in git log --graph output
  2019-02-26 17:26 Bug: "orphaned" trees indistinguishable in git log --graph output Stefan Tauner
@ 2019-02-26 21:09 ` Rafael Ascensão
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael Ascensão @ 2019-02-26 21:09 UTC (permalink / raw)
  To: Stefan Tauner; +Cc: Git Mailing List

This issue was mentioned previously here in the mailing list.
Here it is for reference:
https://public-inbox.org/git/3305f7dc-0044-41fe-8aab-ee800535d6e9@kde.org/

Cheers,
Rafael Ascensão

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-26 21:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-26 17:26 Bug: "orphaned" trees indistinguishable in git log --graph output Stefan Tauner
2019-02-26 21:09 ` Rafael Ascensão

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).