mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
fix<Stash>: fix stash failed when there's too many files to be stashed
This commit is contained in:
parent
905531f2db
commit
ccb3c07064
4 changed files with 53 additions and 31 deletions
|
@ -31,7 +31,7 @@ namespace SourceGit.Commands {
|
|||
if (needStash) {
|
||||
var changes = new LocalChanges(Cwd).Result();
|
||||
if (changes.Count > 0) {
|
||||
if (!new Stash(Cwd).Push(changes, "PULL_AUTO_STASH")) {
|
||||
if (!new Stash(Cwd).Push(changes, "PULL_AUTO_STASH", true)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -11,7 +11,27 @@ namespace SourceGit.Commands {
|
|||
Cwd = repo;
|
||||
}
|
||||
|
||||
public bool Push(List<Models.Change> changes, string message) {
|
||||
public bool Push(List<Models.Change> changes, string message, bool bFull) {
|
||||
if (bFull) {
|
||||
var needAdd = new List<string>();
|
||||
foreach (var c in changes) {
|
||||
if (c.WorkTree == Models.Change.Status.Added || c.WorkTree == Models.Change.Status.Untracked) {
|
||||
needAdd.Add(c.Path);
|
||||
if (needAdd.Count > 10) {
|
||||
new Add(Cwd, needAdd).Exec();
|
||||
needAdd.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needAdd.Count > 0) {
|
||||
new Add(Cwd, needAdd).Exec();
|
||||
needAdd.Clear();
|
||||
}
|
||||
|
||||
Args = $"stash push -m \"{message}\"";
|
||||
return Exec();
|
||||
} else {
|
||||
var temp = Path.GetTempFileName();
|
||||
var stream = new FileStream(temp, FileMode.Create);
|
||||
var writer = new StreamWriter(stream);
|
||||
|
@ -43,6 +63,7 @@ namespace SourceGit.Commands {
|
|||
File.Delete(temp);
|
||||
return succ;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Apply(string name) {
|
||||
Args = $"stash apply -q {name}";
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace SourceGit.Views.Popups {
|
|||
var changes = new Commands.LocalChanges(repo).Result();
|
||||
if (changes.Count > 0) {
|
||||
if (AutoStash) {
|
||||
if (!new Commands.Stash(repo).Push(changes, "NEWBRANCH_AUTO_STASH")) {
|
||||
if (!new Commands.Stash(repo).Push(changes, "NEWBRANCH_AUTO_STASH", true)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace SourceGit.Views.Popups {
|
|||
return Task.Run(() => {
|
||||
Models.Watcher.SetEnabled(repo, false);
|
||||
|
||||
if (changes == null || changes.Count == 0) {
|
||||
var bFull = changes == null || changes.Count == 0;
|
||||
if (bFull) {
|
||||
changes = new Commands.LocalChanges(repo).Result();
|
||||
}
|
||||
|
||||
|
@ -42,7 +43,7 @@ namespace SourceGit.Views.Popups {
|
|||
}
|
||||
}
|
||||
|
||||
if (jobs.Count > 0) new Commands.Stash(repo).Push(changes, message);
|
||||
if (jobs.Count > 0) new Commands.Stash(repo).Push(changes, message, bFull);
|
||||
Models.Watcher.SetEnabled(repo, true);
|
||||
return true;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue