line-endings

Dealing with EOL characters in Cygwin Git and Git for Windows accessing the same repository

不打扰是莪最后的温柔 提交于 2019-12-21 12:37:31
问题 My autocrlf is equal to true. In my cygwin-shell git status gives me a correct list of all my changes. In Git Bash git status says I modified all files in the project. I also see this in Git GUI and the Changes-tab in IntelliJ. How is this possible, and more importantly, how can I fix it? 回答1: Cygwin Git "sees the world" as if it runs on a POSIX platform—thanks to the emulation provided by Cygwin. Contrary to this, Git for Windows is a native Windows program which does not use any emulation

How can I fix the SVN import line endings error?

那年仲夏 提交于 2019-12-20 12:36:52
问题 I have to import an huge SVN repository that I have to transfer from one server to another. So I exported it from the old server: svnadmin dump . > archive.svn and imported it on the new one: svnadmin load . < archive.svn In the middle of the import process I got this error: Cannot accept non-LF line endings in 'svn:ignore' property How can I fix this? I have full control of both servers. 回答1: Have you changed the server version? This is a known issue in 1.6, and causes problems when going

Count the number of lines in a Swift String

喜夏-厌秋 提交于 2019-12-19 10:32:08
问题 After reading a medium sized file (about 500kByte) from a web-service I have a regular Swift String ( lines ) originally encoded in .isolatin1 . Before actually splitting it I would like to count the number of lines (quickly) in order to be able to initialise a progress bar. What is the best Swift idiom to achieve this? I came up with the following: let linesCount = lines.reduce(into: 0) { (count, letter) in if letter == "\r\n" { count += 1 } } This does not look too bad but I am asking

How can I normalize the EOL character in Java?

我的梦境 提交于 2019-12-18 12:11:29
问题 I have a linux server and many clients with many operating systems. The server takes an input file from clients. Linux has end of line char LF, while Mac has end of line char CR, and Windows has end of line char CR+LF The server needs as end of line char LF. Using java, I want to ensure that the file will always use the linux eol char LF. How can I achieve it? 回答1: Combining the two answers (by Visage & eumiro): EDIT: After reading the comment. line. System.getProperty("line.separator") has

How can I configure bash to handle CRLF shell scripts?

只愿长相守 提交于 2019-12-18 07:36:49
问题 I want to execute bash scripts that happen to use Windows/CRLF line endings. I know of the tofrodos package, and how to fromdos files, but if possible, I'd like to run them without any modification. Is there an environment variable that will force bash to handle CRLF? 回答1: Perhaps like this? dos2unix < script.sh|bash -s EDIT: As pointed out in the comments this is the better option, since it allows the script to read from stdin by running dos2unix and not bash in a subshell: bash <(dos2unix <

With Git, how do I turn off the “LF will be replaced by CRLF” warning

∥☆過路亽.° 提交于 2019-12-17 21:39:11
问题 With Git, when using the autocrlf = true flag, a warning is still given when line-endings are changed. I understand what the warning is for, and how to turn off the line-ending flag, but how do I turn off the warning itself? 回答1: You can turn off the warning with git config --global core.safecrlf false (This will only turn off the warning, not the function itself.) 回答2: You should use core.autocrlf input and core.eol input . Or just don't let git change the line endings at all with autocrlf

how C output LF to stdout without being changed to CR LF?

こ雲淡風輕ζ 提交于 2019-12-17 20:12:17
问题 On Windows this #include <stdio.h> int main() { putc('A',stdout); putc('\r',stdout); putc('\n',stdout); } outputs A<CR><CR><LF> How to write just LF char to stdout without automatic conversion to CR LF? I need it to make simple socket stream reader to stdout. I've tried bcc32 from CodeGear, mingw, tinycc all yield same result, changing putc to putchar, fputc, fwrite doesn't help either. 回答1: The MSVC solution is: #include <io.h> #include <fcntl.h> ... _setmode(1,_O_BINARY) Other runtimes may

How to WriteAllLines in C# without CRLF

大城市里の小女人 提交于 2019-12-17 19:38:43
问题 I'm using C# and am trying to output a few lines to an ASCII file. The issue I'm having is that my Linux host is seeing these files as: ASCII text, with CRLF line terminators I need this file to be just: ASCII text The CRLF is causing some issues and I was hoping there was a way in C# to just create the file formatted in the way I want. I'm basically using this code: string[] lines = { "Line1", "Line2" }; File.WriteAllLines(myOutputFile, lines, System.Text.Encoding.UTF8); Is there an easy way

What does Visual Studio mean by normalize inconsistent line endings?

丶灬走出姿态 提交于 2019-12-17 08:09:33
问题 Visual Studio occasionally tells me: The line endings in the following files are not consistent. Do you want to normalize the line endings? It then gives me a drop down with different standards or something, such as Windows, Mac, Unix, and a couple of Unicode ones. What does this mean and what is going to happen if I click Yes ? 回答1: What that usually means is that you have lines ending with something other than a carriage return/line feed pair. It often happens when you copy and paste from a

How do I fix line ending issues after migrating from SVN to git?

只愿长相守 提交于 2019-12-13 16:06:49
问题 I just finished converting a Subversion repository to git using git svn clone--stdlayout --authors-file=ourcommitters.txt svn://svn.internalserver.com While doing so, I had the git flag 'core.autocrlf' set to 'true' - just in case that matters. After a long time, the command finished. I cleaned the resulting git repository a bit (deleting unneded branches, creating tags etc.) and now everything looks really nice and works well. The repository is hosted on a Linux box, and cloning that onto