Normal format files containing garbage only error ... don't want to unify / context

I am trying to use the normal format to create a patch and then apply it. Despite the -n

on diff

and patch

, as well as the obvious conclusion file -o

on patch

, I get the error:

patch: **** Only garbage was found in the patch input.

      

How can I solve this? I cannot use unified or contextual fixes in this case, so this is not a solution.

Is this a bug or something else? The 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

      

+3


source to share


1 answer


According to the man page, diff

you are not using the usual diff format with -n

, but RCS one:

-n --rcs
   Output an RCS format diff.

      

To use normal format you can use the option --normal

. Instead, normal mode is indicated patch

instead -n

. So this is not a bug, but a more annoying naming convention.



Example

$ 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
$

      

(flags --normal

can be avoided as they are standard for both commands)

+3


source







All Articles