line-endings

Dealing with files that Git refuses to reset?

末鹿安然 提交于 2019-11-29 07:41:41
I and my collegues are having terrible trouble getting git to behave properly with certain files on our Windows repostiory clones. The clones have been made by cloning a repository which originates on an OSX machine. We have set autocrlf to true, but the problem is that we reguarly find files that git thinks are changed even though we never touch them (we don't even open them in an editor. The following output illustrates the issue: any ideas where I am going wrong? $ git status # On branch master # Your branch is behind 'origin/master' by 27 commits, and can be fast-forwarded. # # Changed but

What's the difference between \\n and \\r\\n?

ε祈祈猫儿з 提交于 2019-11-29 03:14:51
They both mean "new line" but when is one used over the other? \r\n is a Windows Style \n is a POSIX Style \r is a old pre-OS X Macs Style, Modern Mac's using POSIX Style. \r is a carrige return and \n is a line feed, in old computers where it not have monitor, have only printer to get out programs result to user, if you want get printing from staring of new line from left, you must get \n for Line Feed , and \r for get Carriage return to the most left position, this is from old computers syntax saved to this time on Windows platform. \n is a newline only, \r\n is a newline and a carriage

How can I detect DOS line breaks in a file?

允我心安 提交于 2019-11-29 02:46:06
问题 I have a bunch of files. Some are Unix line endings, many are DOS. I'd like to test each file to see if if is dos formatted, before I switch the line endings. How would I do this? Is there a flag I can test for? Something similar? 回答1: You could search the string for \r\n . That's DOS style line ending. EDIT: Take a look at this 回答2: Python can automatically detect what newline convention is used in a file , thanks to the "universal newline mode" ( U ), and you can access Python's guess

Automatic EOL conversion in Eclipse

故事扮演 提交于 2019-11-28 21:04:01
Need to keep EOL format consistent in all resources under Eclipse workspace. I know about Eclipse preference that sets new line style for newly created files, but I would like to have automatic conversion for already existing files. Is there some settings/plugins? I want just setup once and be sure that all line endings are in the same format. In addition to the Window > Preferences > General > Workspace setting for new files that you already know about, there is a File > Convert Line Delimiters To option. I don't know of any existing plugin/tool that will do this automatically when you save,

git line endings - can't stash, reset and now can't rebase over spurious line endings commit

半世苍凉 提交于 2019-11-28 19:14:44
I have a repo I added a gitattributes to it and was working on it fine. I sync it via dropbox to another machine. When I opened it to the other machine a bunch of files suddenly appeared on the unstaged area as total diffs (all the file a huge diff which means line endings diff) - my crlf endings are basically .* text=auto and I am working on windows. I tried to stash the changes, reset the branch etc. At long last I decided to commit the files and then made some other commits I wanted to reorder (and squash) before the line endings commit. When I try rebasing I get a : error: Your local

How to redirect powershell output when run from Task Scheduler?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 19:07:59
When running a simple powershell script from Task Scheduler, I would like to redirect the output to a file. There is a long thread about this very topic here , yet its not clear if they reached the most appropriate solution in the end. I'm interested if anyone on SO has also solved this problem, and how they did it. Here is the command that worked for me. I didn't like the idea of redirecting the output in the script, since it would make it difficult to run manually. powershell -windowstyle minimized -c "powershell -c .\myscript.ps1 -verbose >> \\server\myscript.log 2>&1" I use the Transcript

How to determine the line ending of a file

坚强是说给别人听的谎言 提交于 2019-11-28 16:39:08
问题 I have a bunch (hundreds) of files that are supposed to have Unix line endings. I strongly suspect that some of them have Windows line endings, and I want to programmatically figure out which ones do. I know I can just run flip -u or something similar in a script to convert everything, but I want to be able to identify those files that need changing first. 回答1: You could use grep egrep -l $'\r'\$ * 回答2: You can use the file tool, which will tell you the type of line ending. Or, you could just

Carriage Return\\Line feed in Java

一个人想着一个人 提交于 2019-11-28 16:39:01
I have created a text file in Unix environment using Java code. For writing the text file I am using java.io.FileWriter and BufferedWriter . And for newline after each row I am using bw.newLine() method (where bw is object of BufferedWriter ). And I'm sending that text file by attaching in mail from Unix environment itself (automated that using Unix commands). My issue is, after I download the text file from mail in a Windows system, if I opened that text file the data is not properly aligned. newline() character is not working, I think so. I want same text file alignment as it is in Unix

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

微笑、不失礼 提交于 2019-11-28 15:17:00
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? You can turn off the warning with git config --global core.safecrlf false (This will only turn off the warning, not the function itself.) You should use core.autocrlf input and core.eol input . Or just don't let git change the line endings at all with autocrlf false and get rid of highlighting of crlfs in diffs, etc with core.whitespace cr-at-eol . Hope this helps Pat Notz

Do any Java stream-input libraries preserve line ending characters?

允我心安 提交于 2019-11-28 14:15:10
I'd like to iterate through a text file one line at a time, operate on the contents, and stream the result to a separate file. Textbook case for BufferedReader.readLine() . But: I need to glue my lines together with newlines, and what if the original file didn't have the "right" newlines for my platform (DOS files on Linux or vice versa)? I guess I could read ahead a bit in the stream and see what kind of line endings I find, even though that's really hacky. But: suppose my input file doesn't have a trailing newline. I'd like to keep things how they were. Now I need to peek ahead to the next