On Windows, opening with "w" opens it as text instead of binary.
This causes translation of newline characters, so that "\n" turns
into "\r\n", which in turn leads to git detecting that the file
has changed and wanting to commit it.
llvm-svn: 226220
def restore_file():
#print "os.path.getmtime() before restore:", os.path.getmtime('main.c')
time.sleep(1)
- with open('main.c', 'w') as f:
+ with open('main.c', 'wb') as f:
f.write(original_content)
if self.TraceOn():
with open('main.c', 'r') as f:
# Modify the source code file.
- with open('main.c', 'w') as f:
+ with open('main.c', 'wb') as f:
time.sleep(1)
f.write(new_content)
if self.TraceOn():