public static byte[] GetResetUnstagedLinesAsPatch(GitModule module, string text, int selectionPosition, int selectionLength, bool staged, Encoding fileContentEncoding) { string header; ChunkList selectedChunks = ChunkList.GetSelectedChunks(text, selectionPosition, selectionLength, staged, out header); if (selectedChunks == null) { return(null); } string body = selectedChunks.ToResetUnstagedLinesPatch(); //git apply has problem with dealing with autocrlf //I noticed that patch applies when '\r' chars are removed from patch if autocrlf is set to true if (body != null && module.EffectiveConfigFile.core.autocrlf.ValueOrDefault == AutoCRLFType.@true) { body = body.Replace("\r", ""); } if (header == null || body == null) { return(null); } else { return(GetPatchBytes(header, body, fileContentEncoding)); } }
public static byte[] GetSelectedLinesAsPatch(GitModule module, string text, int selectionPosition, int selectionLength, bool staged, Encoding fileContentEncoding, bool isNewFile) { string header; ChunkList selectedChunks = ChunkList.GetSelectedChunks(text, selectionPosition, selectionLength, staged, out header); if (selectedChunks == null) { return(null); } //if file is new, --- /dev/null has to be replaced by --- a/fileName if (isNewFile) { header = CorrectHeaderForNewFile(header); } string body = selectedChunks.ToStagePatch(staged, false); if (header == null || body == null) { return(null); } else { return(GetPatchBytes(header, body, fileContentEncoding)); } }
public static byte[] GetResetUnstagedLinesAsPatch(GitModule module, string text, int selectionPosition, int selectionLength, bool staged, Encoding fileContentEncoding) { string header; ChunkList selectedChunks = ChunkList.GetSelectedChunks(text, selectionPosition, selectionLength, staged, out header); if (selectedChunks == null) { return(null); } string body = selectedChunks.ToResetUnstagedLinesPatch(); //git apply has problem with dealing with autocrlf //I noticed that patch applies when '\r' chars are removed from patch if autocrlf is set to true if (body != null && "true".Equals(module.GetEffectiveSetting("core.autocrlf"), StringComparison.InvariantCultureIgnoreCase)) { body = body.Replace("\r", ""); } if (header == null || body == null) { return(null); } else { return(GetPatchBytes(header, body, fileContentEncoding)); } }