From b27346c6a2d1db4a315f0f821855fe1d773f8ea3 Mon Sep 17 00:00:00 2001 From: Ilija Q <79657913+IlijaQ@users.noreply.github.com> Date: Tue, 25 Jul 2023 00:47:24 +0200 Subject: [PATCH] Disabled hotkeys for creating new branches, tags and rebasing in scenarios where they were not intended(#11108) --- GitUI/CommandsDialogs/FormBrowse.cs | 26 ++++---------------------- GitUI/GitUICommands.cs | 10 ++++++++++ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/GitUI/CommandsDialogs/FormBrowse.cs b/GitUI/CommandsDialogs/FormBrowse.cs index 7d8b04e8931..57f2ab662d7 100644 --- a/GitUI/CommandsDialogs/FormBrowse.cs +++ b/GitUI/CommandsDialogs/FormBrowse.cs @@ -1525,7 +1525,7 @@ private void RebaseToolStripMenuItemClick(object sender, EventArgs e) { var revisions = RevisionGrid.GetSelectedRevisions(); - if (revisions.Count == 0) + if (revisions.Count == 0 || revisions[0].IsArtificial) { return; } @@ -2069,28 +2069,10 @@ protected override CommandStatus ExecuteCommand(int cmd) case Command.GoToParent: RestoreFileStatusListFocus(() => RevisionGrid?.ExecuteCommand(RevisionGridControl.Command.GoToParent)); break; case Command.PullOrFetch: DoPull(pullAction: AppSettings.FormPullAction, isSilent: false); break; case Command.Push: UICommands.StartPushDialog(this, pushOnShow: ModifierKeys.HasFlag(Keys.Shift)); break; - case Command.CreateBranch: - if (!Module.IsBareRepository() && RevisionGrid.GetSelectedRevisions().Count == 1 && !RevisionGrid.GetSelectedRevisions()[0].IsArtificial) - { - UICommands.StartCreateBranchDialog(this, RevisionGrid.LatestSelectedRevision?.ObjectId); - } - - break; + case Command.CreateBranch: UICommands.StartCreateBranchDialog(this, RevisionGrid.LatestSelectedRevision?.ObjectId); break; case Command.MergeBranches: UICommands.StartMergeBranchDialog(this, null); break; - case Command.CreateTag: - if (RevisionGrid.GetSelectedRevisions().Count == 1 && !RevisionGrid.GetSelectedRevisions()[0].IsArtificial) - { - UICommands.StartCreateTagDialog(this, RevisionGrid.LatestSelectedRevision); - } - - break; - case Command.Rebase: - if (!RevisionGrid.GetSelectedRevisions()[0].IsArtificial) - { - rebaseToolStripMenuItem.PerformClick(); - } - - break; + case Command.CreateTag: UICommands.StartCreateTagDialog(this, RevisionGrid.LatestSelectedRevision); break; + case Command.Rebase: rebaseToolStripMenuItem.PerformClick(); break; default: return base.ExecuteCommand(cmd); } diff --git a/GitUI/GitUICommands.cs b/GitUI/GitUICommands.cs index 1d0eaa1157a..af34fe1d9b7 100644 --- a/GitUI/GitUICommands.cs +++ b/GitUI/GitUICommands.cs @@ -440,6 +440,11 @@ public bool StartCreateBranchDialog(IWin32Window? owner, string? branch) public bool StartCreateBranchDialog(IWin32Window? owner = null, ObjectId? objectId = null, string? newBranchNamePrefix = null) { + if (Module.IsBareRepository() || (objectId is not null && objectId.IsArtificial)) + { + return false; + } + bool Action() { using FormCreateBranch form = new(this, objectId, newBranchNamePrefix); @@ -853,6 +858,11 @@ bool Action() public bool StartCreateTagDialog(IWin32Window? owner = null, GitRevision? revision = null) { + if (revision is not null && revision.IsArtificial) + { + return false; + } + bool Action() { using FormCreateTag form = new(this, revision?.ObjectId);