{"thread":{"id":"50597","subject":"Bug: \"orphaned\" trees indistinguishable in git log --graph output","startedAt":"2019-02-26T17:26:40Z","lastAt":"2019-02-26T21:10:13Z","messageCount":2,"participants":["Stefan Tauner","Rafael Ascensão"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"370253","messageId":"0Lfolq-1hNWbf1RUI-00pI54@mail.gmx.com","threadId":"50597","inReplyTo":null,"subject":"Bug: \"orphaned\" trees indistinguishable in git log --graph output","fromName":"Stefan Tauner","fromEmail":"stefan.tauner@gmx.at","sentAt":"2019-02-26T17:26:36Z","receivedAt":"2019-02-26T17:26:40Z","isPatch":false,"sender":{"key":"stefan.tauner@gmx.at","avatar":null},"body":"Hi,\n\nI noticed a problem how git log --graph represents orphaned trees, i.e.\nhow it renders a forest (and not just a single tree). If a repository\nis comprised of multiple unconnected trees it can easily happen that\ntheir commits are intertwined in the output of git log --graph so that\nthe root of one tree seems to be (re)based on a commit of the other\ntree and there is no indication that they are indeed separate.\n\nThis first example shows the problem in the first indention level:\n\nmkdir git-log-decorate-forest1\ncd git-log-decorate-forest1\ngit init\ngit commit --allow-empty -m\"Tree 1 - branch 1 - commit 1\"\ngit branch tree1_branch1\ngit checkout --orphan tree2_branch1\ngit commit --allow-empty -m\"Tree 2 - branch 1 - commit 1\"\ngit log --decorate --graph --oneline --all\n\nThe log call at the end leads to something like this:\n\n* 73c925a (tree1_branch1, master) Tree 1 - branch 1 - commit 1\n* e22a694 (HEAD -> tree2_branch1) Tree 2 - branch 1 - commit 1\n\nNote the asterisks in the beginning that usually indicates that the\ncommit sits \"on top\" of the previous one (in contrast to \"|\" used for\ndistinct branches). There is no way to tell from the output that the\ntwo commits reside on different trees.\n\nThe second example shows that the problem also happens at deeper\nindention levels if multiple branches are involved.\nNB: the sleep is important due to git log's sorting (I did not try to\nunderstand the details though).\n\nmkdir git-log-decorate-forest2\ncd git-log-decorate-forest2\ngit init\ngit commit --allow-empty -m\"Tree 1 - branch 1 - commit 1\"\ngit commit --allow-empty -m\"Tree 1 - branch 1 - commit 2\"\ngit branch tree1_branch1\ngit checkout --orphan tree2_branch1\ngit commit --allow-empty -m\"Tree 2 - branch 1 - commit 1\"\ngit checkout master\ngit reset --hard tree1_branch1^\ngit commit --allow-empty -m\"Tree 1 - branch 2 - commit 2\"\ngit branch tree1_branch2\ngit checkout tree2_branch1 \nsleep 1\ngit commit --amend --no-edit --allow-empty\ngit checkout master\ngit commit --allow-empty -m\"Tree 1 - branch 2 - commit 3\"\ngit log --decorate --graph --oneline --all\n\nThe git log output looks something like this:\n* ae86680 (HEAD -> master) Tree 1 - branch 2 - commit 3\n* 844c8c3 (tree1_branch2) Tree 1 - branch 2 - commit 2\n| * 8e6ed1e (tree2_branch1) Tree 2 - branch 1 - commit 1\n| * 3fc176d (tree1_branch1) Tree 1 - branch 1 - commit 2\n|/  \n* 88b8313 Tree 1 - branch 1 - commit 1\n\nNote how 8e6ed1e looks as if it sits on top of 3fc176d? But it doesn't.\nIt's an orphaned commit and thus part of a completely separated tree!\n\nIn gitk one has to enable the display of all branches but then the two\ntrees are distinguishable. gitg works fine (for once) as well.\nThe output of git-cola's DAG viewer is even worse than git log's\noutput: there (the commit of) the second tree is embedded in the master\nbranch between tree1_branch2 and the initial commit of tree 1 (88b8313)!\n\nHere are the (outdated) versions of the tools tested:\ngit version 2.11.0\ngitg 3.23.0\ncola version 2.10\n\nIf the test cases above no longer work I can try to reproduce the\nproblem with git's HEAD if need be. I really hope I have not overlooked\nany related bug reports or even a fix... the issue is a bit hard to\nsearch for ;)\n\nAs a fix I guess it would make sense to have additional indention for\nthe distinct trees... just like how branches are indented but of course\nwithout the |/ split below.\n\n-- \nKind regards/Mit freundlichen Grüßen, Stefan Tauner\n"},{"id":"370277","messageId":"CACUQV58Bh-m5Yati2A0hd+7dwJztc=+JkY5x-YAgABe+JP6xFA@mail.gmail.com","threadId":"50597","inReplyTo":"0Lfolq-1hNWbf1RUI-00pI54@mail.gmx.com","subject":"Re: Bug: \"orphaned\" trees indistinguishable in git log --graph output","fromName":"Rafael Ascensão","fromEmail":"rafa.almas@gmail.com","sentAt":"2019-02-26T21:09:34Z","receivedAt":"2019-02-26T21:10:13Z","isPatch":false,"sender":{"key":"rafa.almas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1923789?v=4"},"body":"This issue was mentioned previously here in the mailing list.\nHere it is for reference:\nhttps://public-inbox.org/git/3305f7dc-0044-41fe-8aab-ee800535d6e9@kde.org/\n\nCheers,\nRafael Ascensão\n"}]}