Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using Cygwin on Win7x32, when I use sed to replace some values in a file, git then considers the entire file to be completely rewritten (i.e., 500 insertions, 500 deletions). What's going on here? Only one line in the file is actually changed, and the replacement value is the same length as the original. I'd expect git to recognize only the lines that changed. The only thing that seems to have changed at all is the inode and time values as read from stat some/file.txt. Is there a way to tell git to ignore any relevant changed values for the duration of my sed calls, or to tell sed to not change any values that cause git to see a file with entirely new content?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I don't work with Windows much, but perhaps sed is changing your end-of-line markers. The file command will tell you which text encoding is being used. Also, you can run cat -e before and after you call sed; if the file is encoded for Windows each line will end with ^M.

share|improve this answer
    
This looks like the culprit; before, the file is ASCII C++ program text, with CRLF line terminators, and after, ASCII C++ program text. I was under the impression that sed didn't do any sort of automagical conversions like that, being a "stream editor," but oh well. –  wes Mar 6 '12 at 18:41
    
Does cygwin have the unix2dos tool? That'll put back the Windows end-of-line marker. –  eduffy Mar 6 '12 at 18:51
    
Yep, that's what I ended up using. Just a little surprised after hearing so many good things about sed. –  wes Mar 6 '12 at 18:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.