namespace LibGit2Sharp { /// /// Tracking information for a /// public class BranchTrackingDetails { private readonly HistoryDivergence historyDivergence; /// /// Needed for mocking purposes. /// protected BranchTrackingDetails() { } internal BranchTrackingDetails(Repository repo, Branch branch) { if (!branch.IsTracking || branch.Tip == null || branch.TrackedBranch.Tip == null) { historyDivergence = new NullHistoryDivergence(); return; } historyDivergence = repo.ObjectDatabase.CalculateHistoryDivergence(branch.Tip, branch.TrackedBranch.Tip); } /// /// Gets the number of commits that exist in this local branch but don't exist in the tracked one. /// /// This property will return null if this local branch has no upstream configuration /// or if the upstream branch does not exist /// /// public virtual int? AheadBy { get { return historyDivergence.AheadBy; } } /// /// Gets the number of commits that exist in the tracked branch but don't exist in this local one. /// /// This property will return null if this local branch has no upstream configuration /// or if the upstream branch does not exist /// /// public virtual int? BehindBy { get { return historyDivergence.BehindBy; } } /// /// Gets the common ancestor of the local branch and its tracked remote branch. /// /// This property will return null if this local branch has no upstream configuration, /// the upstream branch does not exist, or either branch is an orphan. /// /// public virtual Commit CommonAncestor { get { return historyDivergence.CommonAncestor; } } } }