mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-20 21:01:06 +08:00
refactor: use git reset HEAD --pathspec-from-file=<pathspec> instead of git restore --staged --pathspec-from-file=<pathspec> to unstage files
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -86,7 +86,7 @@ namespace SourceGit.Commands
|
||||
{
|
||||
var pathSpecFile = Path.GetTempFileName();
|
||||
await File.WriteAllLinesAsync(pathSpecFile, restores).ConfigureAwait(false);
|
||||
await new Restore(repo, pathSpecFile, false).Use(log).ExecAsync().ConfigureAwait(false);
|
||||
await new Restore(repo, pathSpecFile).Use(log).ExecAsync().ConfigureAwait(false);
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,12 @@
|
||||
Context = repo;
|
||||
Args = $"reset {mode} {revision}";
|
||||
}
|
||||
|
||||
public Reset(string repo, string pathspec)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
Args = $"reset HEAD --pathspec-from-file={pathspec.Quoted()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
using System.Text;
|
||||
|
||||
namespace SourceGit.Commands
|
||||
namespace SourceGit.Commands
|
||||
{
|
||||
public class Restore : Command
|
||||
{
|
||||
public Restore(string repo, string pathspecFile, bool isStaged)
|
||||
public Restore(string repo, string pathspecFile)
|
||||
{
|
||||
WorkingDirectory = repo;
|
||||
Context = repo;
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("restore --progress ");
|
||||
builder.Append(isStaged ? "--staged " : "--worktree --recurse-submodules ");
|
||||
builder.Append("--pathspec-from-file=").Append(pathspecFile.Quoted());
|
||||
|
||||
Args = builder.ToString();
|
||||
Args = $"restore --progress --worktree --recurse-submodules --pathspec-from-file={pathspecFile.Quoted()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace SourceGit.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
await new Commands.Restore(_repo.FullPath, pathSpecFile, true).Use(log).ExecAsync();
|
||||
await new Commands.Reset(_repo.FullPath, pathSpecFile).Use(log).ExecAsync();
|
||||
File.Delete(pathSpecFile);
|
||||
}
|
||||
log.Complete();
|
||||
|
||||
Reference in New Issue
Block a user