You are not logged in.

#1 2011-09-18 10:39:12

momus
Member
Registered: 2011-09-13
Posts: 12

Apply diff file to source tree

Hello,

I have a source tree and a diff file containing about 200 changes to different files in the source tree.
In the past I only applied changes to a source tree using patch files, but how do i do this with a diff file?

I tried stuff like patch srctree -n updates.diff, but that fails ...

Do i have to create a patch file out of the diff file? Cause i saw that it seems to be the normal case that you create
patch files using two different source trees and than compare them using diff.

Thank you!

Offline

#2 2011-09-18 11:15:04

jakobm
Member
Registered: 2008-03-24
Posts: 132

Re: Apply diff file to source tree

The terms "diff file" and "patch file" are equivalent. patch can read various formats generated by a diff program.
Have you simply tried the following (you may need the -p option)?

patch < updates.diff

Offline

#3 2011-09-18 11:45:14

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Apply diff file to source tree

The only thing different should be the extension, and Linux doesn't care about that.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#4 2011-09-18 13:40:52

momus
Member
Registered: 2011-09-13
Posts: 12

Re: Apply diff file to source tree

Hi!

thx for the help!

If i run patch < file.diff i get  " patch: **** Only garbage was found in the patch input. "
So i assumed the file has no valid format. The head of the file looks like that.

diff -rN old-ion-3plus-1/README new-ion-3plus/README
125a126,128
> The code in `de/unicode' (producing `de/precompose.c') is taken from
> xterm.
> 
diff -rN old-ion-3plus-1/build/rules.mk new-ion-3plus/build/rules.mk
126a127,128
> DEFINES += -DCF_EXECUTABLE=\"$(EXECUTABLE)\"
> 
141c143
< CC_PICFLAGS=-fPIC -DPIC
---
> #CC_PICFLAGS=-fPIC -DPIC 
diff -rN old-ion-3plus-1/config.h new-ion-3plus/config.h
32a33,35
> #define CF_USERTIME_DIFF_CURRENT 2000
> #define CF_USERTIME_DIFF_NEW 4000
> 
diff -rN old-ion-3plus-1/de/Makefile new-ion-3plus/de/Makefile
14c14
< SOURCES=init.c draw.c font.c colour.c brush.c fontset.c style.c
---
> SOURCES=init.c draw.c font.c colour.c brush.c fontset.c style.c precompose.c
diff -rN old-ion-3plus-1/de/font.c new-ion-3plus/de/fo

Should i be able to use this with patch?

Offline

#5 2011-09-18 13:50:22

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Apply diff file to source tree

Try

$ patch -Np1 -i updates.diff

And read the manual:

$ man patch

The diff -rN command you see in between the snippets to be removed or added is the command used to generate the patch btw.

Last edited by .:B:. (2011-09-18 13:51:39)


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#6 2011-09-18 14:54:25

momus
Member
Registered: 2011-09-13
Posts: 12

Re: Apply diff file to source tree

Hi!

should patch -i file.diff, interpret diff statments in the diff file?

Sadly patch still failes with complaining about garbage input ...

Offline

Board footer

Powered by FluxBB