Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach newly created branch to commit in gitgraph #5279

Open
NicolasCwy opened this issue Feb 10, 2024 · 3 comments
Open

Attach newly created branch to commit in gitgraph #5279

NicolasCwy opened this issue Feb 10, 2024 · 3 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request

Comments

@NicolasCwy
Copy link
Contributor

NicolasCwy commented Feb 10, 2024

Proposal

Currently branching a commit on gitgraph which has no commits on it does not render it. This can be confusing as branches with pointers at different commits cannot be differentiated. Would be nice to have some indicator such as a tag of some sort.

In this example, feat-1 should be currently pointing to the commit "initial commit" while feat-2 is at "working on DB"

Example

gitGraph
commit id:"initial commit"
branch feat-1
checkout main
commit id: "working on DB"
branch feat-2

Screenshots

image

@NicolasCwy NicolasCwy added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Feb 10, 2024
@nirname
Copy link
Contributor

nirname commented Jun 19, 2024

I think this will change the rendering, although this is a nice feature. My thoughts that there are plenty of git visualization tools (gitg, gitk) and we can re-implement the whole rendering. But this is not really quick. Could you elaborate more on how then the graph should look like? Branches names are currently aligned, where should we put them and how to distinguish them from commit messages?

@drbr
Copy link

drbr commented Aug 15, 2024

I came here seeking a similar capability, so I'm now also thinking about how it could/should look like.

I think the problem is that even though we often think about branches as parallel tracks onto which commits can be made (and it's definitely useful in many applications to visualize them as such); Git has no concept of these "tracks" — a branch is just a pointer to a specific commit. Sometimes (as in the OP's case, or if we merge two branches into each other), multiple branches will be pointing to the same commit.

One idea to solve this without breaking the existing visuals is to offer an alternative way of showing the branch names. The showBranches config flag could be extended to have three options:

  • false Existing behavior: show no branch names

  • "tracks" (or, true for backcompat) Existing behavior: name the tracks on the left

  • "pointers" Still render each branch name on its own track, but put the branch labels on the right, with arrows pointing to the rightmost commit on that track (or, pointing up to the source commit if there are none on the track). As a bonus, we could optionally show HEAD using similar visuals.

    Screenshot 2024-08-14 at 22 35 35
    Screenshot 2024-08-14 at 22 33 05
    Screenshot 2024-08-14 at 22 43 39

I would argue that "pointers" could be a sensible default because it's closer to what Git is actually doing, but I understand the value in the "tracks" model for people doing release management graphs and the like.

@drbr
Copy link

drbr commented Aug 15, 2024

Visually, I think it could suffice for branch pointers to look similar to the tag pointers, but with a differently styled box. I would personally be okay with setting showBranches to false and adding the branch pointers manually via a branchPointer attribute on the commit node. But, the renderer would need the ability to display multiple tags per commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants