diff --git a/GitUI/BranchTreePanel/RepoObjectsTree.BaseBranchNode.cs b/GitUI/BranchTreePanel/RepoObjectsTree.BaseBranchNode.cs index 03ae67b6f06..26c770b7ccd 100644 --- a/GitUI/BranchTreePanel/RepoObjectsTree.BaseBranchNode.cs +++ b/GitUI/BranchTreePanel/RepoObjectsTree.BaseBranchNode.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using GitCommands; using GitExtUtils.GitUI.Theming; using GitUI.Properties; @@ -33,6 +34,8 @@ protected BaseBranchNode(Tree tree, string fullPath, bool visible) protected string? AheadBehind { get; set; } + protected string? RelatedBranch { get; set; } + /// /// Short name of the branch/branch path. "issue1344". /// @@ -68,9 +71,10 @@ public override bool Equals(object obj) && Visible == other.Visible; } - public void UpdateAheadBehind(string aheadBehindData) + public void UpdateAheadBehind(string aheadBehindData, string relatedBranch) { AheadBehind = aheadBehindData; + RelatedBranch = relatedBranch; } public bool Rebase() @@ -118,7 +122,9 @@ protected void SelectRevision() { TreeViewNode.TreeView?.BeginInvoke(new Action(() => { - UICommands.BrowseGoToRef(FullPath, showNoRevisionMsg: true, toggleSelection: ModifierKeys.HasFlag(Keys.Control)); + string branch = RelatedBranch is null || !ModifierKeys.HasFlag(Keys.Alt) + ? FullPath : RelatedBranch.Substring(GitRefName.RefsRemotesPrefix.Length); + UICommands.BrowseGoToRef(branch, showNoRevisionMsg: true, toggleSelection: ModifierKeys.HasFlag(Keys.Control)); TreeViewNode.TreeView?.Focus(); })); } diff --git a/GitUI/BranchTreePanel/RepoObjectsTree.BranchTree.cs b/GitUI/BranchTreePanel/RepoObjectsTree.BranchTree.cs index 0766df4c833..069601f05d2 100644 --- a/GitUI/BranchTreePanel/RepoObjectsTree.BranchTree.cs +++ b/GitUI/BranchTreePanel/RepoObjectsTree.BranchTree.cs @@ -113,9 +113,12 @@ private Nodes FillBranchTree(IReadOnlyList branches, CancellationToken bool isVisible = !IsFiltering.Value || _refsSource.Contains(branch.ObjectId); LocalBranchNode localBranchNode = new(this, branch.ObjectId, branch.Name, branch.Name == currentBranch, isVisible); - if (aheadBehindData is not null && aheadBehindData.ContainsKey(localBranchNode.FullPath)) + if (aheadBehindData is not null) { - localBranchNode.UpdateAheadBehind(aheadBehindData[localBranchNode.FullPath].ToDisplay()); + if (aheadBehindData.TryGetValue(localBranchNode.FullPath, out AheadBehindData aheadBehind)) + { + localBranchNode.UpdateAheadBehind(aheadBehind.ToDisplay(), aheadBehind.RemoteRef); + } } var parent = localBranchNode.CreateRootNode(pathToNode, (tree, parentPath) => new BranchPathNode(tree, parentPath));