I'm using a very recent build of the emacs source repo on a Linux box. I have a file that uses DOS-style line termination. This file is in git and has some modifications. I use (vc-diff) to get a buffer that shows those modifications. Currently this buffer is NOT set to use the DOS encoding, and emacs does a conversion, so this buffer is missing the extra CR characters the DOS encoding had. Because of this, if I save this buffer to a file, external tools can no longer be used to apply the patch. I'm attaching a tiny git repository that demonstrates the issue: dima@shorty:/tmp$ tar xvfz vc_encoding_error_test_repo.tar.gz vc_encoding_error_test_repo/ vc_encoding_error_test_repo/file dima@shorty:/tmp$ cd vc_encoding_error_test_repo dima@shorty:/tmp/vc_encoding_error_test_repo$ emacs --batch --eval '(progn (find-file "file") (vc-diff) (with-current-buffer "*vc-diff*" (write-file "/tmp/patch")))' -Q Finding changes in /tmp/vc_encoding_error_test_repo/file... Saving file /tmp/patch... Wrote /tmp/patch dima@shorty:/tmp/vc_encoding_error_test_repo$ git apply --cached /tmp/patch error: patch failed: file:1 error: file: patch does not apply Here we see git fail to apply the saved patch. This is due to the stripped CR characters. VC already has code in it to detect the encoding of its input. I'm attaching a small patch that sets this detected encoding to the *vc-diff* buffer. This fixes the issue.