question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

One commit can't serve as a parent to multiple merge commits (> 2)

See original GitHub issue

This example is very close to what I would like to diagram-

      {(gitgraph) => {
        const develop = gitgraph.branch("develop").commit();
        const fix = gitgraph.branch("feature");
        const release = gitgraph.branch("release");
        fix.commit("Bug fixed.");
        release.merge(fix);
        develop.merge(release, "Bugfixes are always merged back to develop.");
      }}
screenshot-1

However, with a little bit of mspaint-

screenshot-1

This seems to be impossible to build in gitgraph. I would expect the following code to work, but it breaks horribly.

      {(gitgraph) => {
        const develop = gitgraph.branch("develop").commit();
        const fix = gitgraph.branch("feature");
        const release = gitgraph.branch("release");
        fix.commit("Bug fixed.");
        release.merge(fix);
        develop.merge(fix, "Bugfixes are always merged back to develop.");
      }}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
briangordoncommented, Apr 16, 2019

@nicoespeon Actually, it seems like this issue might not be completely resolved. The case of two child merges does indeed work, but the case of three child merges does not.

Here’s the 2 case working fine:

screenshot
      {(gitgraph) => {
        const develop = gitgraph.branch("develop").commit();
        const fix = gitgraph.branch("feature1");
        const release1 = gitgraph.branch("release1");
        fix.commit();
        release1.merge(fix);
        develop.merge(fix);
      }}

And here’s the 3 case looking slightly off:

screenshot-1
      {(gitgraph) => {
        const develop = gitgraph.branch("develop").commit();
        const fix = gitgraph.branch("feature1");
        const release1 = gitgraph.branch("release1");
        const release2 = gitgraph.branch("release2");
        fix.commit();
        release1.merge(fix);
        release2.merge(fix);
        develop.merge(fix);
      }}

Notice that in the 3 case, the green-to-grey merge is rendered as coming from the orange merge commit for some reason.

0reactions
nicoespeoncommented, Apr 16, 2019

Indeed, that’s interesting. Thanks for adding more details, we’ll look into this 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can a git commit have more than 2 parents?
A merge of more than one branch (i.e. a commit with more than two parents) is colloquially known as an "octopus merge". That's...
Read more >
git - Merge commit first and second parents - Stack Overflow
A commit can have more than 2 parents, which is the result of merging 2 or more branches to one branch at the...
Read more >
How to Revert a Merge Commit Already Pushed to ... - W3docs
On this page, you will find a short tutorial on how to revert a merge commit that is already pushed to the remote...
Read more >
Cherry-pick changes - GitLab Docs
In Git, cherry-picking is taking a single commit from one branch and adding it as the latest commit on another branch. The rest...
Read more >
Does a merge commit really need two parents? - Quora
Merge uses the difference between the head commits of the branches being merged. Rebase, on the other hand, has to replay every commit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found