Rebase branch using a Tag as upstream

25 Views Asked by At

I am trying to use LibGit2Sharp to rebase a feature branch using a Tag as upstream. The initial graph looks like this:

          * -- * -- * (featureA)
         /          
        /
 *--*--*--*--*--*--*--*--*--*--*--*-- (master)
       |        |        |        |    
       tag1    tag2     tag3    tag4    

The idea is to rebase featureA branch on master, but not on the HEAD of master (last commit), but rather on the commit corresponding to tag2.

The end result would be something like this:

                   * -- * -- * (featureA)
                  /          
                 /
 *--*--*--*--*--*--*--*--*--*--*--*-- (master)
       |        |        |        |    
       tag1    tag2     tag3    tag4 

The git syntax for this would be (and it works perfectly):

git rebase ref/tags/tag2 featureA

However, LibGit2Sharp syntax only allows passing in a Branch as argument for the upstream param.

var rebaseOptions = new RebaseOptions {...};
var identity = new Identity(...);

Branch branch = repo.Head;
Tag upstreamTag = repo.Tags[ontoTag]; 

var rebaseResult = repo.Rebase.Start(
    branch, 
    upstream, // <-- this is where I am struggling to pass in this Tag as upstream
    null, 
    identity, 
    rebaseOptions);

Any idea on how I can achieve this result via LibGit2Sharp?

0

There are 0 best solutions below