Skip to content

GitGraph cannot handle merging master/main into another branch (to keep track) #7125

@Abrifq

Description

@Abrifq

Description

I was making a diagram to explain develop->stable branch relationship, but then I discovered if the branch was last updated by the last merged branch and tried to merge the same branch over again (to get the additional commits since the last commits), it fails.

Essentially simulating

# simulate mermaid's "commit" syntax:
alias makeCommit='echo "work" >> work.txt && git add work.txt && git commit -m "commit"'

git switch -C main
makeCommit 
git switch -c stable
git merge main --no-ff
git tag v1.0
git switch main
makeCommit
makeCommit
git switch stable
git merge main --no-ff
git tag v1.1
git switch main
makeCommit

You can check git log --graph --all after that to see what kind of a representation i expected.

Steps to reproduce

Checkout the code example.

Screenshots

No response

Code Sample

gitGraph
    commit
    branch stable
    checkout stable
    merge main

Setup

  • Mermaid version: Develop: v11.12.1+f28f3c2, main mermaid.live: v11.12.0
  • Browser and Version: Firefox 144.0.2

Suggested Solutions

Maybe check if the branches are at the same commit at

if (currentCommit && otherCommit && currentCommit.branch === otherBranch) {
throw new Error(`Cannot merge branch '${otherBranch}' into itself.`);
}

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions