* [RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline
@ 2024-12-03 17:29 Josh Brunton
2024-12-03 23:32 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Josh Brunton @ 2024-12-03 17:29 UTC (permalink / raw)
To: git@vger.kernel.org
[-- Attachment #1.1.1: Type: text/plain, Size: 3923 bytes --]
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
myself confused or mistaken due to the way "git-log --oneline --graph" handles
unrelated histories: by presenting them as if they were one continuous string of
commits.
To create an example of how git-log --oneline --graph presents unmerged
unrelated histories, let us use the following minimal reproducible example.
In ~/repos/git-history-1:
* dec7d4c (HEAD -> main, origin/main) History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
In ~/repos/git-history-2:
* (HEAD -> main2, origin/main2) e5698bf History 2 - Add SECURITY.md
* 7260dff History 2 - Add .gitattributes
If both are pushed to ~/git-history-origin, that repo's log (git-log --graph)
looks like:
[...]
| Add SECURITY.md
|
* commit 7260dff47ffb6233b5f7ccfd62a1be29047d813d
Author: Josh Brunton <josh.brunton@proton.me>
Date: Tue Dec 3 09:57:43 2024 +0000
Add .gitattributes
* commit dec7d4cab044e37dd340b487a4d1d8b8b0cac867 (HEAD -> main)
| Author: Josh Brunton <josh.brunton@proton.me>
| Date: Tue Dec 3 09:55:50 2024 +0000
[...]
There is a clear disconnect between commits dec7d4c 7260dff, showing that
they represent 2 unrelated histories. However, passing --oneline as well produces
the following output:
* e5698bf (main2) History 2 - Add SECURITY.md
* 7260dff History 2 - Add .gitattributes
* dec7d4c (HEAD -> main) History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
With this graph, one might be forgiven for the assumption that dec7d4c is the
parent of 7260dff, as it would be visually indistinguishable if that were the case
and is far more likely than having 2 unmerged, unrelated histories. This can lead
to some confusion and/or bad assumptions about the history.
It is not until we merge the 2 histories that git log --oneline --graph shows
any indication at all that those histories were unrelated:
* 15177d2 (HEAD -> main) Merge branch 'main2'
|\
| * e5698bf (main2) History 2 - Add SECURITY.md
| * 7260dff History 2 - Add .gitattributes
* dec7d4c History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
I therefore suggest that a separator line (perhaps a blank line) might be
added between unrelated histories which would otherwise seem related in --oneline
--graph. In other words, the separator should appear between any 2 consecutive lines
where * appears in the same column, where the above line's commit has no parent(s).
I believe unrelated histories are clearly represented in other cases.
I have considered that doing so may require that each commit in the log would
have to undergo an additional check to see if it has any ancestors. Though I am
not knowledgeable on how resource-heavy this operation would be, I am wary that
it may pose a significant performance impact. Thus, I suggest that this feature
might be opt-in via a config setting named along the lines of
log.delimitUnrelatedHistories.
In implementing this proposal, the above unrelated histories would become:
* e5698bf (main2) History 2 - Add SECURITY.md
* 7260dff History 2 - Add .gitattributes
* dec7d4c (HEAD -> main) History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
While if some other factor were to create the same effect of clarifying that
the histories are unrelated, the output would remain unchanged:
* e5698bf (main2) History 2 - Add SECURITY.md
| * 3c3cade (branch3) Add CODEOWNERS
* | 7260dff History 2 - Add .gitattributes
|
* / dec7d4c (HEAD -> main) History 1 - Add README.md
|/
* 3f25318 History 1 - Add gitignore
Depending on approval here, I am prepared to attempt to implement this
feature myself, though would appreciate input from those more knowledgeable about the
git codebase and experienced with contributing.
[-- Attachment #1.1.2.1: Type: text/html, Size: 6891 bytes --]
[-- Attachment #1.2: publickey - josh.brunton@proton.me - 0x4DBFDC41.asc --]
[-- Type: application/pgp-keys, Size: 3154 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 855 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline
2024-12-03 17:29 [RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline Josh Brunton
@ 2024-12-03 23:32 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2024-12-03 23:32 UTC (permalink / raw)
To: Josh Brunton; +Cc: git@vger.kernel.org
Josh Brunton <josh.brunton@proton.me> writes:
> There is a clear disconnect between commits dec7d4c 7260dff, showing that
> they represent 2 unrelated histories. However, passing --oneline as well produces
> the following output:
> * e5698bf (main2) History 2 - Add SECURITY.md
> * 7260dff History 2 - Add .gitattributes
> * dec7d4c (HEAD -> main) History 1 - Add README.md
> * 3f25318 History 1 - Add gitignore
> ...
> I therefore suggest that a separator line (perhaps a blank line) might be
> added between unrelated histories which would otherwise seem related in --oneline
> --graph.
Please do not do this.
If you find this a good way to separate two lines of histories:
> * 15177d2 (HEAD -> main) Merge branch 'main2'
> |\
> | * e5698bf (main2) History 2 - Add SECURITY.md
> | * 7260dff History 2 - Add .gitattributes
> * dec7d4c History 1 - Add README.md
> * 3f25318 History 1 - Add gitignore
then something like
| * e5698bf (main2) History 2 - Add SECURITY.md
| * 7260dff History 2 - Add .gitattributes
* dec7d4c History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
would be much better than
* e5698bf (main2) History 2 - Add SECURITY.md
* 7260dff History 2 - Add .gitattributes
* dec7d4c History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
that wastes valuable vertical screen estate.
I do not deeply care if the '|' part gets blanked out until two
histories are merged, iow,
* e5698bf (main2) History 2 - Add SECURITY.md
* 7260dff History 2 - Add .gitattributes
* dec7d4c History 1 - Add README.md
* 3f25318 History 1 - Add gitignore
is fine as well.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-03 23:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 17:29 [RFC] Proposal to add a delimiter between unrelated history in git-log --graph --oneline Josh Brunton
2024-12-03 23:32 ` Junio C Hamano
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 NNTP newsgroup(s).