Reputation: 16321
I'm trying to use the normal format to create a patch and then apply it. Despite -n
on both diff
and patch
, and an explicit file output -o
on patch
, I get the error:
patch: **** Only garbage was found in the patch input.
How can I solve this? I can't use unified or context patches in this case, so that's not a solution.
Is it a bug or something? Editor format seems to work, for some reason:
$ echo a > a.txt
$ echo b > b.txt
$ diff -n a.txt b.txt > ab.diff
$ patch -n -o a.txt a.txt ab.diff
patch: **** Only garbage was found in the patch input.
$ diff -e a.txt b.txt > ab.diff
$ patch -e -o a.txt a.txt ab.diff
$ diff a.txt b.txt
$
This is on Linux Mint 16, with:
$ diff --version
diff (GNU diffutils) 3.2
$ patch --version
GNU patch 2.7.1
Upvotes: 4
Views: 3864
Reputation: 31484
According to the man page of diff
, you are not using the normal diff format with -n
but the RCS one:
-n --rcs Output an RCS format diff.
In order to use the normal format you can use the --normal
option.
In the patch
command instead -n
specifies the normal mode. So it's not a bug, more an unhappy naming convention.
$ echo a > a.txt
$ echo b > b.txt
$ diff --normal a.txt b.txt > ab.diff
$ patch --normal a.txt ab.diff
$ diff a.txt b.txt
$
(You can avoid the --normal
flags since they are the default format for both the commands)
Upvotes: 4