4

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 

1 Answer 1

4

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.

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 $ 

(You can avoid the --normal flags since they are the default format for both the commands)

Sign up to request clarification or add additional context in comments.

1 Comment

I even read that, and it failed to click in my mind, unhappily as you say. Thanks for your help, it now works perfectly, of course. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.