public BranchWrapper(Repository repo, Branch branch)
 {
     this.repo = repo;
     this.branch = branch;
     IsRemote = branch.IsRemote;
     if (branch.TrackedBranch != null)
     {
         TrackedBranch = new BranchWrapper(repo, branch.TrackedBranch);
     }
     IsTracking = branch.IsTracking;
     TrackingDetails = (Func<object, Task<object>>)(async (j) => { return branch.TrackingDetails; });
     IsCurrentRepositoryHead = (Func<object, Task<object>>)(async (j) => { return branch.IsCurrentRepositoryHead; });
     Tip = async (j) => { return new CommitWrapper(branch.Tip); };
     UpstreamBranchCanonicalName = (Func<object, Task<object>>)(async (j) => { return branch.UpstreamBranchCanonicalName; });
     Remote = branch.Remote;
     CanonicalName = branch.CanonicalName;
     Commits = (Func<object, Task<object>>)(async (j) => {
         if (j != null)
         {
             Commit after = repo.Lookup<Commit>((string)j);
             Commit until = branch.Tip;
             Commit ancestor = repo.Commits.FindMergeBase(after, until) ?? after;
             return CommitsAfter(after, until, ancestor).Distinct().Select(c => new CommitWrapper(c));
         }
         else
         {
             return branch.Commits.Select(c => new CommitWrapper(c));
         }
     });
     Name = branch.Name;
 }
 public BranchWrapper(Repository repo, Branch branch)
 {
     this.repo   = repo;
     this.branch = branch;
     IsRemote    = branch.IsRemote;
     if (branch.TrackedBranch != null)
     {
         TrackedBranch = new BranchWrapper(repo, branch.TrackedBranch);
     }
     IsTracking              = branch.IsTracking;
     TrackingDetails         = (Func <object, Task <object> >)(async(j) => { return(branch.TrackingDetails); });
     IsCurrentRepositoryHead = (Func <object, Task <object> >)(async(j) => { return(branch.IsCurrentRepositoryHead); });
     Tip = async(j) => { return(new CommitWrapper(branch.Tip)); };
     UpstreamBranchCanonicalName = (Func <object, Task <object> >)(async(j) => { return(branch.UpstreamBranchCanonicalName); });
     Remote        = branch.Remote;
     CanonicalName = branch.CanonicalName;
     Commits       = (Func <object, Task <object> >)(async(j) => {
         if (j != null)
         {
             Commit after    = repo.Lookup <Commit>((string)j);
             Commit until    = branch.Tip;
             Commit ancestor = repo.Commits.FindMergeBase(after, until) ?? after;
             return(CommitsAfter(after, until, ancestor).Distinct().Select(c => new CommitWrapper(c)));
         }
         else
         {
             return(branch.Commits.Select(c => new CommitWrapper(c)));
         }
     });
     Name = branch.Name;
 }