mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +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
|
@ -13,9 +13,17 @@ namespace SourceGit.ViewModels {
|
|||
private set;
|
||||
}
|
||||
|
||||
public Discard(Repository repo, List<Models.Change> changes = null) {
|
||||
public Discard(Repository repo) {
|
||||
_repo = repo;
|
||||
|
||||
Mode = new DiscardModeAll();
|
||||
View = new Views.Discard { DataContext = this };
|
||||
}
|
||||
|
||||
public Discard(Repository repo, List<Models.Change> changes, bool isUnstaged) {
|
||||
_repo = repo;
|
||||
_changes = changes;
|
||||
_isUnstaged = isUnstaged;
|
||||
|
||||
if (_changes == null) {
|
||||
Mode = new DiscardModeAll();
|
||||
|
@ -35,8 +43,10 @@ namespace SourceGit.ViewModels {
|
|||
return Task.Run(() => {
|
||||
if (_changes == null) {
|
||||
Commands.Discard.All(_repo.FullPath);
|
||||
} else if (_isUnstaged) {
|
||||
Commands.Discard.ChangesInWorkTree(_repo.FullPath, _changes);
|
||||
} else {
|
||||
Commands.Discard.Changes(_repo.FullPath, _changes);
|
||||
Commands.Discard.ChangesInStaged(_repo.FullPath, _changes);
|
||||
}
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
|
@ -46,5 +56,6 @@ namespace SourceGit.ViewModels {
|
|||
|
||||
private Repository _repo = null;
|
||||
private List<Models.Change> _changes = null;
|
||||
private bool _isUnstaged = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue