mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
fix<Discard>: wrong discard behavior with changes both in worktree and staged
This commit is contained in:
parent
a770ff542d
commit
1c005983c7
4 changed files with 58 additions and 18 deletions
|
@ -8,7 +8,7 @@ namespace SourceGit.Commands {
|
|||
new Clean(repo).Exec();
|
||||
}
|
||||
|
||||
public static void Changes(string repo, List<Models.Change> changes) {
|
||||
public static void ChangesInWorkTree(string repo, List<Models.Change> changes) {
|
||||
var needClean = new List<string>();
|
||||
var needCheckout = new List<string>();
|
||||
|
||||
|
@ -30,5 +30,14 @@ namespace SourceGit.Commands {
|
|||
new Checkout(repo).Files(needCheckout.GetRange(i, count));
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangesInStaged(string repo, List<Models.Change> changes) {
|
||||
for (int i = 0; i < changes.Count; i += 10) {
|
||||
var count = Math.Min(10, changes.Count - i);
|
||||
var files = new List<string>();
|
||||
for (int j = 0; j < count; j++) files.Add(changes[i + j].Path);
|
||||
new Restore(repo, files, "--staged --worktree").Exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue