Skip to content

Commit

Permalink
Disabled hotkeys for creating new branches, tags and rebasing in scen…
Browse files Browse the repository at this point in the history
…arios where they were not intended(#11108)
  • Loading branch information
IlijaQ committed Jul 24, 2023
1 parent 49edcd2 commit 26a0308
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
26 changes: 4 additions & 22 deletions GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions GitUI/GitUICommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 true;
}

bool Action()
{
using FormCreateBranch form = new(this, objectId, newBranchNamePrefix);
Expand Down Expand Up @@ -853,6 +858,11 @@ bool Action()

public bool StartCreateTagDialog(IWin32Window? owner = null, GitRevision? revision = null)
{
if (revision is not null && revision.IsArtificial)
{
return true;
}

bool Action()
{
using FormCreateTag form = new(this, revision?.ObjectId);
Expand Down

0 comments on commit 26a0308

Please sign in to comment.