Skip to main content
Removing references to Cygwin, because the behavior of "diff" in this context is not specific to Cygwin.
Link

Why is my patch coming out in binary format on cygwin?

Source Link
Dexygen
  • 325
  • 1
  • 2
  • 7

Why is my patch coming out in binary format on cygwin?

I'm diffing two directories, 220 and sue, as follows:

diff -r 220 sue > diff.txt

The directory looks as follows afterwards:

$ ls -al
total 20
drwxrwx---+ 1 Administrators Domain Users     0 Jun 24 10:44 .
drwxrwx---+ 1 SYSTEM         SYSTEM           0 Jun 24 09:52 ..
drwxrwx---+ 1 Administrators Domain Users     0 Jun 24 09:54 220
-rw-rwxr--+ 1 jempty         Domain Users 15463 Jun 24 10:44 diff.txt
drwxrwx---+ 1 Administrators Domain Users     0 Jun 24 09:55 sue

Confirming diff.txt is text as follows:

$ file diff.txt
diff.txt: HTML document, ASCII text, with very long lines, with CRLF, LF line terminators

The above is primarily to demonstrate that I can use diff and see that there not a tremendous amount of differences.

Then creating a patch file as suggested by https://docs.moodle.org/dev/How_to_create_a_patch:

$ diff -Naur 220 sue > patch.txt

Results in the directory looking as follows:

$ ls -al
total 133836
drwxrwx---+ 1 Administrators Domain Users         0 Jun 24 10:57 .
drwxrwx---+ 1 SYSTEM         SYSTEM               0 Jun 24 09:52 ..
drwxrwx---+ 1 Administrators Domain Users         0 Jun 24 09:54 220
-rw-rwxr--+ 1 jempty         Domain Users     15463 Jun 24 10:44 diff.txt
-rw-rwxr--+ 1 jempty         Domain Users 137024100 Jun 24 10:57 patch.txt
drwxrwx---+ 1 Administrators Domain Users         0 Jun 24 09:55 sue

As you can see the patch.txt file is enormous and as it turns out it's binary:

$ file patch.txt
patch.txt: data

Should I be using the patch command instead of diff