mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-22 02:45:00 +00:00
refactor: rewrite git restore
integration
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
80df53cf04
commit
78f9ae2fa9
5 changed files with 71 additions and 18 deletions
|
@ -124,9 +124,9 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < changes.Count; i += 10)
|
||||
for (int i = 0; i < changes.Count; i += 32)
|
||||
{
|
||||
var count = Math.Min(10, changes.Count - i);
|
||||
var count = Math.Min(32, changes.Count - i);
|
||||
var step = changes.GetRange(i, count);
|
||||
succ = new Commands.Stash(_repo.FullPath).Use(log).Push(Message, step, KeepIndex);
|
||||
if (!succ)
|
||||
|
|
|
@ -1634,13 +1634,14 @@ namespace SourceGit.ViewModels
|
|||
foreach (var c in changes)
|
||||
paths.Add(c.Path);
|
||||
|
||||
for (int i = 0; i < count; i += 10)
|
||||
for (int i = 0; i < count; i += 32)
|
||||
{
|
||||
var step = paths.GetRange(i, Math.Min(10, count - i));
|
||||
var step = paths.GetRange(i, Math.Min(32, count - i));
|
||||
await Task.Run(() => new Commands.Add(_repo.FullPath, step).Use(log).Exec());
|
||||
}
|
||||
}
|
||||
log.Complete();
|
||||
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
IsStaging = false;
|
||||
|
@ -1664,15 +1665,26 @@ namespace SourceGit.ViewModels
|
|||
log.AppendLine("$ git update-index --index-info ");
|
||||
await Task.Run(() => new Commands.UnstageChangesForAmend(_repo.FullPath, changes).Exec());
|
||||
}
|
||||
else if (count == _staged.Count)
|
||||
else if (Native.OS.GitVersion >= Models.GitVersions.RESTORE_WITH_PATHSPECFILE)
|
||||
{
|
||||
await Task.Run(() => new Commands.Restore(_repo.FullPath, true).Use(log).Exec());
|
||||
var paths = new List<string>();
|
||||
foreach (var c in changes)
|
||||
{
|
||||
paths.Add(c.Path);
|
||||
if (c.Index == Models.ChangeState.Renamed)
|
||||
paths.Add(c.OriginalPath);
|
||||
}
|
||||
|
||||
var tmpFile = Path.GetTempFileName();
|
||||
File.WriteAllLines(tmpFile, paths);
|
||||
await Task.Run(() => new Commands.Restore(_repo.FullPath, tmpFile, "--staged").Use(log).Exec());
|
||||
File.Delete(tmpFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < count; i += 10)
|
||||
for (int i = 0; i < count; i += 32)
|
||||
{
|
||||
var step = changes.GetRange(i, Math.Min(10, count - i));
|
||||
var step = changes.GetRange(i, Math.Min(32, count - i));
|
||||
var files = new List<string>();
|
||||
foreach (var c in step)
|
||||
{
|
||||
|
@ -1685,6 +1697,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
log.Complete();
|
||||
|
||||
_repo.MarkWorkingCopyDirtyManually();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
IsUnstaging = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue