libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Question/Feature request: Rebase branch using a Tag as upstream

Open george-pancescu opened this issue 2 years ago • 0 comments

This is potentially a feature request, if there is no way of accomplishing this using the current version of LibGit2Sharp

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);

Is this achievable via LibGit2Sharp?

george-pancescu avatar Aug 29 '23 11:08 george-pancescu