diff --git a/GitCommands/Git/GitModule.cs b/GitCommands/Git/GitModule.cs
index e274d63f2a6..763be9de9a1 100644
--- a/GitCommands/Git/GitModule.cs
+++ b/GitCommands/Git/GitModule.cs
@@ -158,7 +158,7 @@ static bool HasGitModulesFile(string path)
///
/// GitVersion for the default GitExecutable.
///
- public GitVersion GitVersion => GitVersion.CurrentVersion(_wslDistro);
+ public GitVersion GitVersion => GitVersion.CurrentVersion(GitExecutable, _wslDistro);
///
public IExecutable GitExecutable => _gitExecutable;
diff --git a/GitCommands/Git/GitVersion.cs b/GitCommands/Git/GitVersion.cs
index 6b45c3af193..4fea29e4cee 100644
--- a/GitCommands/Git/GitVersion.cs
+++ b/GitCommands/Git/GitVersion.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Windows.Forms;
using GitExtUtils;
+using GitUIPluginInterfaces;
namespace GitCommands
{
@@ -10,12 +11,13 @@ public class GitVersion : IComparable
{
private static readonly GitVersion v2_19_0 = new("2.19.0");
private static readonly GitVersion v2_20_0 = new("2.20.0");
+ private static readonly GitVersion v2_35_0 = new("2.35.0");
///
/// The recommonded Git version (normally latest official before a GE release).
/// This and later versions are green in the settings check.
///
- public static readonly GitVersion LastRecommendedVersion = new("2.33.0");
+ public static readonly GitVersion LastRecommendedVersion = new("2.35.0");
///
/// The oldest version with reasonable reliable support in GE.
@@ -40,11 +42,12 @@ public class GitVersion : IComparable
///
/// The unique identification of the Git executable
/// The GitVersion
- public static GitVersion CurrentVersion(string gitIdentifiable = "")
+ public static GitVersion CurrentVersion(IExecutable gitExec = null, string gitIdentifiable = "")
{
if (!_current.ContainsKey(gitIdentifiable) || _current[gitIdentifiable] is null || _current[gitIdentifiable].IsUnknown)
{
- string output = new Executable(AppSettings.GitCommand).GetOutput("--version");
+ gitExec ??= new Executable(AppSettings.GitCommand);
+ string output = gitExec.GetOutput("--version");
_current[gitIdentifiable] = new GitVersion(output);
if (_current[gitIdentifiable] < LastVersionWithoutKnownLimitations)
{
@@ -119,6 +122,7 @@ int Get(IReadOnlyList values, int index)
public bool SupportRebaseMerges => this >= v2_19_0;
public bool SupportGuiMergeTool => this >= v2_20_0;
public bool SupportRangeDiffTool => this >= v2_19_0;
+ public bool SupportStashStaged => this >= v2_35_0;
public bool IsUnknown => _a == 0 && _b == 0 && _c == 0 && _d == 0;
diff --git a/GitUI/CommandsDialogs/FormBrowse.Designer.cs b/GitUI/CommandsDialogs/FormBrowse.Designer.cs
index 62f10e5ec06..e541c090308 100644
--- a/GitUI/CommandsDialogs/FormBrowse.Designer.cs
+++ b/GitUI/CommandsDialogs/FormBrowse.Designer.cs
@@ -39,6 +39,7 @@ private void InitializeComponent()
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripSplitStash = new System.Windows.Forms.ToolStripSplitButton();
this.stashChangesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.stashStagedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.stashPopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.manageStashesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -389,6 +390,7 @@ private void InitializeComponent()
//
this.toolStripSplitStash.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.stashChangesToolStripMenuItem,
+ this.stashStagedToolStripMenuItem,
this.stashPopToolStripMenuItem,
this.toolStripSeparator9,
this.manageStashesToolStripMenuItem,
@@ -409,6 +411,14 @@ private void InitializeComponent()
this.stashChangesToolStripMenuItem.ToolTipText = "Stash changes";
this.stashChangesToolStripMenuItem.Click += new System.EventHandler(this.StashChangesToolStripMenuItemClick);
//
+ // stashStagedToolStripMenuItem
+ //
+ this.stashStagedToolStripMenuItem.Name = "stashStagedToolStripMenuItem";
+ this.stashStagedToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
+ this.stashStagedToolStripMenuItem.Text = "S&tash staged";
+ this.stashStagedToolStripMenuItem.ToolTipText = "Stash staged changes";
+ this.stashStagedToolStripMenuItem.Click += new System.EventHandler(this.StashStagedToolStripMenuItemClick);
+ //
// stashPopToolStripMenuItem
//
this.stashPopToolStripMenuItem.Name = "stashPopToolStripMenuItem";
@@ -1792,6 +1802,7 @@ private void InitializeComponent()
private ToolStripPushButton toolStripButtonPush;
private ToolStripSplitButton toolStripSplitStash;
private ToolStripMenuItem stashChangesToolStripMenuItem;
+ private ToolStripMenuItem stashStagedToolStripMenuItem;
private ToolStripMenuItem stashPopToolStripMenuItem;
private ToolStripSeparator toolStripSeparator9;
private ToolStripMenuItem manageStashesToolStripMenuItem;
diff --git a/GitUI/CommandsDialogs/FormBrowse.cs b/GitUI/CommandsDialogs/FormBrowse.cs
index d92d03e063d..7632fa98679 100644
--- a/GitUI/CommandsDialogs/FormBrowse.cs
+++ b/GitUI/CommandsDialogs/FormBrowse.cs
@@ -869,6 +869,7 @@ private void InternalInitialize()
}
stashChangesToolStripMenuItem.Enabled = !bareRepository;
+ stashStagedToolStripMenuItem.Visible = Module.GitVersion.SupportStashStaged;
gitGUIToolStripMenuItem.Enabled = !bareRepository;
SetShortcutKeyDisplayStringsFromHotkeySettings();
@@ -1592,6 +1593,12 @@ private void StashChangesToolStripMenuItemClick(object sender, EventArgs e)
UpdateStashCount();
}
+ private void StashStagedToolStripMenuItemClick(object sender, EventArgs e)
+ {
+ UICommands.StashStaged(this);
+ UpdateStashCount();
+ }
+
private void StashPopToolStripMenuItemClick(object sender, EventArgs e)
{
UICommands.StashPop(this);
diff --git a/GitUI/CommandsDialogs/FormCommit.Designer.cs b/GitUI/CommandsDialogs/FormCommit.Designer.cs
index 38e5dbca71a..cbdb7c1a95a 100644
--- a/GitUI/CommandsDialogs/FormCommit.Designer.cs
+++ b/GitUI/CommandsDialogs/FormCommit.Designer.cs
@@ -123,6 +123,7 @@ private void InitializeComponent()
this.CommitAndPush = new System.Windows.Forms.Button();
this.Amend = new System.Windows.Forms.CheckBox();
this.ResetAuthor = new System.Windows.Forms.CheckBox();
+ this.StashStaged = new System.Windows.Forms.Button();
this.Reset = new System.Windows.Forms.Button();
this.ResetUnStaged = new System.Windows.Forms.Button();
this.toolbarCommit = new GitUI.ToolStripEx();
@@ -1115,6 +1116,7 @@ private void InitializeComponent()
var resetAuthorPanel = new Panel{ AutoSize = false, Size = this.ResetAuthor.Size, Margin = new Padding(0) };
resetAuthorPanel.Controls.Add(this.ResetAuthor);
this.flowCommitButtons.Controls.Add(resetAuthorPanel);
+ this.flowCommitButtons.Controls.Add(this.StashStaged);
this.flowCommitButtons.Controls.Add(this.Reset);
this.flowCommitButtons.Controls.Add(this.ResetUnStaged);
this.flowCommitButtons.Dock = System.Windows.Forms.DockStyle.Fill;
@@ -1178,11 +1180,25 @@ private void InitializeComponent()
this.ResetAuthor.UseVisualStyleBackColor = true;
this.ResetAuthor.Visible = false;
//
+ // StashStaged
+ //
+ this.StashStaged.Image = global::GitUI.Properties.Images.Stash;
+ this.StashStaged.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ this.StashStaged.Location = new System.Drawing.Point(0, 110);
+ this.StashStaged.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
+ this.StashStaged.Name = "StashStaged";
+ this.StashStaged.Size = new System.Drawing.Size(171, 26);
+ this.StashStaged.TabIndex = 14;
+ this.StashStaged.TabStop = false;
+ this.StashStaged.Text = "S&tash staged changes";
+ this.StashStaged.UseVisualStyleBackColor = true;
+ this.StashStaged.Click += new System.EventHandler(this.StashStagedClick);
+ //
// Reset
//
this.Reset.Image = global::GitUI.Properties.Images.ResetWorkingDirChanges;
this.Reset.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.Reset.Location = new System.Drawing.Point(0, 110);
+ this.Reset.Location = new System.Drawing.Point(0, 142);
this.Reset.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.Reset.Name = "Reset";
this.Reset.Size = new System.Drawing.Size(171, 26);
@@ -1196,7 +1212,7 @@ private void InitializeComponent()
//
this.ResetUnStaged.Image = global::GitUI.Properties.Images.ResetWorkingDirChanges;
this.ResetUnStaged.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.ResetUnStaged.Location = new System.Drawing.Point(0, 142);
+ this.ResetUnStaged.Location = new System.Drawing.Point(0, 174);
this.ResetUnStaged.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.ResetUnStaged.Name = "ResetUnStaged";
this.ResetUnStaged.Size = new System.Drawing.Size(171, 26);
@@ -1679,6 +1695,7 @@ private void InitializeComponent()
private FlowLayoutPanel flowCommitButtons;
private Button Commit;
private Button CommitAndPush;
+ private Button StashStaged;
private Button Reset;
private CheckBox Amend;
private CheckBox ResetAuthor;
diff --git a/GitUI/CommandsDialogs/FormCommit.cs b/GitUI/CommandsDialogs/FormCommit.cs
index 90dd5f33bed..050730d074a 100644
--- a/GitUI/CommandsDialogs/FormCommit.cs
+++ b/GitUI/CommandsDialogs/FormCommit.cs
@@ -307,6 +307,11 @@ public FormCommit(GitUICommands commands, CommitKind commitKind = CommitKind.Nor
selectionFilter.Size = DpiUtil.Scale(selectionFilter.Size);
toolStripStatusBranchIcon.Width = DpiUtil.Scale(toolStripStatusBranchIcon.Width);
+ if (!Module.GitVersion.SupportStashStaged)
+ {
+ flowCommitButtons.Controls.Remove(StashStaged);
+ }
+
SetVisibilityOfSelectionFilter(AppSettings.CommitDialogSelectionFilter);
Reset.Visible = AppSettings.ShowResetAllChanges;
ResetUnStaged.Visible = AppSettings.ShowResetWorkTreeChanges;
@@ -2699,6 +2704,12 @@ private void HandleResetButton(bool onlyUnstaged)
Initialize();
}
+ private void StashStagedClick(object sender, EventArgs e)
+ {
+ BypassFormActivatedEventHandler(() => UICommands.StashStaged(owner: this));
+ Initialize();
+ }
+
private void BypassFormActivatedEventHandler(Action action)
{
try
diff --git a/GitUI/GitUICommands.cs b/GitUI/GitUICommands.cs
index 87bec4fd272..1bbd663ca40 100644
--- a/GitUI/GitUICommands.cs
+++ b/GitUI/GitUICommands.cs
@@ -202,6 +202,19 @@ bool Action()
return DoActionOnRepo(owner, Action);
}
+ public bool StashStaged(IWin32Window? owner)
+ {
+ bool Action()
+ {
+ FormProcess.ShowDialog(owner, arguments: "stash --staged", Module.WorkingDir, input: null, useDialogSettings: true);
+
+ // git-stash may have changed commits also if aborted, the grid must be refreshed
+ return true;
+ }
+
+ return DoActionOnRepo(owner, Action);
+ }
+
public bool StashPop(IWin32Window? owner)
{
bool Action()
diff --git a/GitUI/Translation/English.xlf b/GitUI/Translation/English.xlf
index c9d559d3fb6..31fb0838e75 100644
--- a/GitUI/Translation/English.xlf
+++ b/GitUI/Translation/English.xlf
@@ -3127,6 +3127,14 @@ Do you want to continue?
Apply and drop single stash
+
+
+
+ S&tash staged changes
+
+
Add selection to commit message