mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
27 lines
1,009 B
C#
27 lines
1,009 B
C#
|
using System.IO;
|
||
|
|
||
|
namespace SourceGit.Commands {
|
||
|
/// <summary>
|
||
|
/// 将Changes保存到文件流中
|
||
|
/// </summary>
|
||
|
public class SaveChangeToStream : Command {
|
||
|
private StreamWriter writer = null;
|
||
|
|
||
|
public SaveChangeToStream(string repo, Models.Change change, StreamWriter to) {
|
||
|
Cwd = repo;
|
||
|
if (change.WorkTree == Models.Change.Status.Added || change.WorkTree == Models.Change.Status.Untracked) {
|
||
|
Args = $"diff --no-index --no-ext-diff --find-renames -- /dev/null \"{change.Path}\"";
|
||
|
} else {
|
||
|
var pathspec = $"\"{change.Path}\"";
|
||
|
if (!string.IsNullOrEmpty(change.OriginalPath)) pathspec = $"\"{change.OriginalPath}\" \"{change.Path}\"";
|
||
|
Args = $"diff --binary --no-ext-diff --find-renames --full-index -- {pathspec}";
|
||
|
}
|
||
|
writer = to;
|
||
|
}
|
||
|
|
||
|
public override void OnReadline(string line) {
|
||
|
writer.WriteLine(line);
|
||
|
}
|
||
|
}
|
||
|
}
|