mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-07 20:04:59 +00:00
refactor: use git reset --hard HEAD
to discard all changes and use git restore --staged
to unstage changes in text diff view
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
78f9ae2fa9
commit
f1052c3efc
3 changed files with 5 additions and 29 deletions
|
@ -36,7 +36,7 @@ namespace SourceGit.Commands
|
|||
});
|
||||
}
|
||||
|
||||
new Restore(repo) { Log = log }.Exec();
|
||||
new Reset(repo, "HEAD", "--hard") { Log = log }.Exec();
|
||||
if (includeIgnored)
|
||||
new Clean(repo) { Log = log }.Exec();
|
||||
}
|
||||
|
|
|
@ -1,33 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public class Reset : Command
|
||||
{
|
||||
public Reset(string repo)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = "reset";
|
||||
}
|
||||
|
||||
public Reset(string repo, List<Models.Change> changes)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("reset --");
|
||||
foreach (var c in changes)
|
||||
{
|
||||
builder.Append(" \"");
|
||||
builder.Append(c.Path);
|
||||
builder.Append("\"");
|
||||
}
|
||||
Args = builder.ToString();
|
||||
}
|
||||
|
||||
public Reset(string repo, string revision, string mode)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
|
|
|
@ -1928,8 +1928,10 @@ namespace SourceGit.Views
|
|||
{
|
||||
if (change.DataForAmend != null)
|
||||
new Commands.UnstageChangesForAmend(repo.FullPath, [change]).Exec();
|
||||
else if (change.Index == Models.ChangeState.Renamed)
|
||||
new Commands.Restore(repo.FullPath, [change.Path, change.OriginalPath], "--staged").Exec();
|
||||
else
|
||||
new Commands.Reset(repo.FullPath, [change]).Exec();
|
||||
new Commands.Restore(repo.FullPath, [change.Path], "--staged").Exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue