public Patch GetSingleDiff(string @from, string to, string fileName, string oldFileName, string extraDiffArguments, Encoding encoding, bool cacheResult)
{
if (!string.IsNullOrEmpty(fileName))
{
fileName = fileName.ToPosixPath();
}
if (!string.IsNullOrEmpty(oldFileName))
{
oldFileName = oldFileName.ToPosixPath();
}
//fix refs slashes
from = from.ToPosixPath();
to = to.ToPosixPath();
string commitRange = string.Empty;
if (!to.IsNullOrEmpty())
commitRange = "\"" + to + "\"";
if (!from.IsNullOrEmpty())
commitRange = string.Join(" ", commitRange, "\"" + from + "\"");
if (AppSettings.UsePatienceDiffAlgorithm)
extraDiffArguments = string.Concat(extraDiffArguments, " --patience");
var patchManager = new PatchManager();
var arguments = String.Format("diff {0} -M -C {1} -- {2} {3}", extraDiffArguments, commitRange,
fileName.Quote(), oldFileName.Quote());
string patch;
if (cacheResult)
patch = RunCacheableCmd(AppSettings.GitCommand, arguments, LosslessEncoding);
else
patch = RunCmd(AppSettings.GitCommand, arguments, LosslessEncoding);
patchManager.LoadPatch(patch, false, encoding);
return GetPatch(patchManager, fileName, oldFileName);
}