Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
        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));
            }
        }