gitgraph.js icon indicating copy to clipboard operation
gitgraph.js copied to clipboard

Orphan Branch

Open tfinelli opened this issue 5 years ago • 6 comments

It seems like the ability to create an orphanBranch was removed in v2. Could this be added back? See this previous issue regarding orphan branches from v1:
https://github.com/nicoespeon/gitgraph.js/issues/23

tfinelli avatar Jul 30 '19 15:07 tfinelli

Indeed, we forgot about this feature. Thanks for flagging @tfinelli 👍

nicoespeon avatar Jul 30 '19 18:07 nicoespeon

To simulate a orphan branch or a branch that "already" exist I use a workaround and delete the parentCommitHash and give the branch a special commit object.

I'm currently use the gitgraph-js.

const cutTimeline = {
  renderMessage: function() {
    return document.createElement('text');
  },
  renderDot: function() {
    return document.createElement('circle');
  },
};

const master = gitGraph.branch({
  ...branchTypeConfigs.master,
});

master.commit(cutTimeline);

const develop = master.branch({
  ...branchTypeConfigs.develop,
});
delete develop._branch.parentCommitHash;
develop.commit(cutTimeline);

NonPolynomial avatar Sep 26 '19 18:09 NonPolynomial

Thank you @NonPolynomial that gave me 90% of what I wanted.

I now have a diagram that looks like this: firefox_cdBHdfwJhs

Is there any way to extend the blue line (my develop branch) down so that it begins at the same place as the grey branch (my master branch)?

DSBloom avatar Jan 24 '20 21:01 DSBloom

@nadcraker

Is there any way to extend the blue line (my develop branch) down so that it begins at the same place as the grey branch (my master branch)?

tl;dr: nope, it depends on the order how and when your commits are added to the workflow

I think I tried everything, but never get to work that two branches start at the same "time" because the graph depends on "when" a commit was made (added to a branch).

to make your branch longer, you could make another commit, but it won't be as long as your master branch

NonPolynomial avatar Jan 25 '20 14:01 NonPolynomial

@NonPolynomial so two branches may not start from one commit? I just tried to import, and it's ok...

Does the problem only occur with orphan branches?

iliakan avatar Mar 04 '23 21:03 iliakan

@NonPolynomial so two branches may not start from one commit? I just tried to import, and it's ok...

Does the problem only occur with orphan branches?

The issue was just about orphan branches. but this issue is 3 yrs old. Don't exactly know if that still is the case in the latest version.

You should be able to create x branches from a previous commit. You just cant add orphan commits that appear at the same "time" in the graph

NonPolynomial avatar Mar 08 '23 10:03 NonPolynomial