mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00: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
|
@ -11,37 +11,58 @@ namespace SourceGit.Commands {
|
|||
Cwd = repo;
|
||||
}
|
||||
|
||||
public bool Push(List<Models.Change> changes, string message) {
|
||||
var temp = Path.GetTempFileName();
|
||||
var stream = new FileStream(temp, FileMode.Create);
|
||||
var writer = new StreamWriter(stream);
|
||||
|
||||
var needAdd = new List<string>();
|
||||
foreach (var c in changes) {
|
||||
writer.WriteLine(c.Path);
|
||||
|
||||
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();
|
||||
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();
|
||||
}
|
||||
|
||||
writer.Flush();
|
||||
stream.Flush();
|
||||
writer.Close();
|
||||
stream.Close();
|
||||
if (needAdd.Count > 0) {
|
||||
new Add(Cwd, needAdd).Exec();
|
||||
needAdd.Clear();
|
||||
}
|
||||
|
||||
Args = $"stash push -m \"{message}\" --pathspec-from-file=\"{temp}\"";
|
||||
var succ = Exec();
|
||||
File.Delete(temp);
|
||||
return succ;
|
||||
Args = $"stash push -m \"{message}\"";
|
||||
return Exec();
|
||||
} else {
|
||||
var temp = Path.GetTempFileName();
|
||||
var stream = new FileStream(temp, FileMode.Create);
|
||||
var writer = new StreamWriter(stream);
|
||||
|
||||
var needAdd = new List<string>();
|
||||
foreach (var c in changes) {
|
||||
writer.WriteLine(c.Path);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
writer.Flush();
|
||||
stream.Flush();
|
||||
writer.Close();
|
||||
stream.Close();
|
||||
|
||||
Args = $"stash push -m \"{message}\" --pathspec-from-file=\"{temp}\"";
|
||||
var succ = Exec();
|
||||
File.Delete(temp);
|
||||
return succ;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Apply(string name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue