1

I am writing an application that automates the re-building of a branch based on a new head. It uses cherry-picking to get the job done, but many times the app runs into merge commits that have 2 parents. When I do:

_ngit.CherryPick().Include(commit).Call();

...it throws an exception, Cannot cherry-pick commit '{commit_id}' because it has 2 parents, only commits with exactly one parent are supported.

I need the ability to cherry-pick these merge commits, selecting the first parent as the base. Seems like there would be something like:

_ngit.CherryPick().Include(commit).WithBase(0).Call(); (where 0 is the index of the first parent that I want to use as a base)

I've seen various hints on the web where people trying to get this ability added to jgit, but I've never seen any documentation or anything in the API that suggests it's available. Some such "hints" are:

If this is possible with jgit, please tell me how. If there's another way to get these merge commits added into my new branch, I'm all ears.

Byron Sommardahl
  • 12,743
  • 15
  • 74
  • 131
  • Are you sure you want to include merge commits? See [this answer](http://stackoverflow.com/a/9229393/305973) for why this is not such a good idea. If you are cherry-picking all commits of a branch that are not yet in another branch, the merge commits do not have to be cherry-picked, only the commits that were merged. Apart from that, it sounds like what you are trying to do is a rebase? – robinst Aug 18 '13 at 16:28
  • @robinst I can certainly ignore all merge commits, but that results in me having to re-resolve any merge conflicts when cherry-picking. If cherry-picking the merge commits is a bad idea, I think I'll need to look into rerere cache sharing so that multiple developers can resolve conflicts and have them remembered. Thanks for the info! – Byron Sommardahl Aug 18 '13 at 17:32
  • If you really want to pick merge commits, you will have to also only pick the commits of one parent of a merge commit, otherwise you will also have conflicts. By the way, I have picked up the patch in [bug 379007](https://bugs.eclipse.org/bugs/show_bug.cgi?id=379007) and implemented the missing pieces, currently waiting for legal clearing from the original author. – robinst Aug 19 '13 at 13:06

0 Answers0