{"thread":{"id":"62592","subject":"[RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline","startedAt":"2024-12-03T17:29:51Z","lastAt":"2024-12-03T23:32:21Z","messageCount":2,"participants":["Josh Brunton","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"508547","messageId":"FNUesYPDfyA16MXr4g9q7vW9OQ6bfbUK1umvVjONQNgEsQJZV5sIvRX9MlHfRILe4-hhINNy59uNjywL4abyJT43JVYjXU0ofUGWKQo0lFA=@proton.me","threadId":"62592","inReplyTo":null,"subject":"[RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline","fromName":"Josh Brunton","fromEmail":"josh.brunton@proton.me","sentAt":"2024-12-03T17:29:46Z","receivedAt":"2024-12-03T17:29:51Z","isPatch":false,"sender":{"key":"josh.brunton@proton.me","avatar":null},"body":"Though a relatively rare occurrence, I sometimes find myself working withrepositories that contain 2 un-merged, unrelated histories. In doing so, I've often found\nmyself confused or mistaken due to the way \"git-log --oneline --graph\" handles\nunrelated histories: by presenting them as if they were one continuous string of\ncommits.\n\nTo create an example of how git-log --oneline --graph presents unmerged\nunrelated histories, let us use the following minimal reproducible example.\n\nIn ~/repos/git-history-1:\n* dec7d4c (HEAD -> main, origin/main) History 1 - Add README.md\n* 3f25318 History 1 - Add gitignore\n\nIn ~/repos/git-history-2:\n* (HEAD -> main2, origin/main2) e5698bf History 2 - Add SECURITY.md\n* 7260dff History 2 - Add .gitattributes\n\nIf both are pushed to ~/git-history-origin, that repo's log (git-log --graph)\nlooks like:\n[...]\n|     Add SECURITY.md\n|\n* commit 7260dff47ffb6233b5f7ccfd62a1be29047d813d\n  Author: Josh Brunton <josh.brunton@proton.me>\n  Date:   Tue Dec 3 09:57:43 2024 +0000\n\n      Add .gitattributes\n\n* commit dec7d4cab044e37dd340b487a4d1d8b8b0cac867 (HEAD -> main)\n| Author: Josh Brunton <josh.brunton@proton.me>\n| Date:   Tue Dec 3 09:55:50 2024 +0000\n[...]\n\nThere is a clear disconnect between commits dec7d4c 7260dff, showing that\nthey represent 2 unrelated histories. However, passing --oneline as well produces\nthe following output:\n* e5698bf (main2) History 2 - Add SECURITY.md\n* 7260dff History 2 - Add .gitattributes\n* dec7d4c (HEAD -> main) History 1 - Add README.md\n* 3f25318 History 1 - Add gitignore\n\nWith this graph, one might be forgiven for the assumption that dec7d4c is the\nparent of 7260dff, as it would be visually indistinguishable if that were the case\nand is far more likely than having 2 unmerged, unrelated histories. This can lead\nto some confusion and/or bad assumptions about the history.\n\nIt is not until we merge the 2 histories that git log --oneline --graph shows\nany indication at all that those histories were unrelated:\n*   15177d2 (HEAD -> main) Merge branch 'main2'\n|\\\n| * e5698bf (main2) History 2 - Add SECURITY.md\n| * 7260dff History 2 - Add .gitattributes\n* dec7d4c History 1 - Add README.md\n* 3f25318 History 1 - Add gitignore\n\nI therefore suggest that a separator line (perhaps a blank line) might be\nadded between unrelated histories which would otherwise seem related in --oneline\n--graph. In other words, the separator should appear between any 2 consecutive lines\nwhere * appears in the same column, where the above line's commit has no parent(s).\nI believe unrelated histories are clearly represented in other cases.\n\nI have considered that doing so may require that each commit in the log would\nhave to undergo an additional check to see if it has any ancestors. Though I am\nnot knowledgeable on how resource-heavy this operation would be, I am wary that\nit may pose a significant performance impact. Thus, I suggest that this feature\nmight be opt-in via a config setting named along the lines of\nlog.delimitUnrelatedHistories.\n\nIn implementing this proposal, the above unrelated histories would become:\n* e5698bf (main2) History 2 - Add SECURITY.md\n* 7260dff History 2 - Add .gitattributes\n\n* dec7d4c (HEAD -> main) History 1 - Add README.md\n* 3f25318 History 1 - Add gitignore\n\nWhile if some other factor were to create the same effect of clarifying that\nthe histories are unrelated, the output would remain unchanged:\n* e5698bf (main2) History 2 - Add SECURITY.md\n| * 3c3cade (branch3) Add CODEOWNERS\n* | 7260dff History 2 - Add .gitattributes\n  |\n* / dec7d4c (HEAD -> main) History 1 - Add README.md\n|/\n* 3f25318 History 1 - Add gitignore\n\nDepending on approval here, I am prepared to attempt to implement this\nfeature myself, though would appreciate input from those more knowledgeable about the\ngit codebase and experienced with contributing."},{"id":"508583","messageId":"xmqqfrn49wcd.fsf@gitster.g","threadId":"62592","inReplyTo":"FNUesYPDfyA16MXr4g9q7vW9OQ6bfbUK1umvVjONQNgEsQJZV5sIvRX9MlHfRILe4-hhINNy59uNjywL4abyJT43JVYjXU0ofUGWKQo0lFA=@proton.me","subject":"Re: [RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-12-03T23:32:18Z","receivedAt":"2024-12-03T23:32:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josh Brunton <josh.brunton@proton.me> writes:\n\n> There is a clear disconnect between commits dec7d4c 7260dff, showing that\n> they represent 2 unrelated histories. However, passing --oneline as well produces\n> the following output:\n> * e5698bf (main2) History 2 - Add SECURITY.md\n> * 7260dff History 2 - Add .gitattributes\n> * dec7d4c (HEAD -> main) History 1 - Add README.md\n> * 3f25318 History 1 - Add gitignore\n> ...\n> I therefore suggest that a separator line (perhaps a blank line) might be\n> added between unrelated histories which would otherwise seem related in --oneline\n> --graph.\n\nPlease do not do this.\n\nIf you find this a good way to separate two lines of histories:\n\n> *   15177d2 (HEAD -> main) Merge branch 'main2'\n> |\\\n> | * e5698bf (main2) History 2 - Add SECURITY.md\n> | * 7260dff History 2 - Add .gitattributes\n> * dec7d4c History 1 - Add README.md\n> * 3f25318 History 1 - Add gitignore\n\nthen something like\n\n  | * e5698bf (main2) History 2 - Add SECURITY.md\n  | * 7260dff History 2 - Add .gitattributes\n  * dec7d4c History 1 - Add README.md\n  * 3f25318 History 1 - Add gitignore\n\nwould be much better than\n\n  * e5698bf (main2) History 2 - Add SECURITY.md\n  * 7260dff History 2 - Add .gitattributes\n\n  * dec7d4c History 1 - Add README.md\n  * 3f25318 History 1 - Add gitignore\n\nthat wastes valuable vertical screen estate.\n\nI do not deeply care if the '|' part gets blanked out until two\nhistories are merged, iow, \n\n    * e5698bf (main2) History 2 - Add SECURITY.md\n    * 7260dff History 2 - Add .gitattributes\n  * dec7d4c History 1 - Add README.md\n  * 3f25318 History 1 - Add gitignore\n\nis fine as well.\n"}]}