Hi all,
Can anyone tell me what is a patch file,what does that use for and how can i write and test a patch file.
Thanks in advance
Hi all,
Can anyone tell me what is a patch file,what does that use for and how can i write and test a patch file.
Thanks in advance
diana --> programming is tough
A patch file represents changes to a file. Lets say i have 10 million lines of code in my project and i update 3 of them. I could redistribute the entire project to everyone in my group or i could send them a small file that details the differences.
you shouldent ever "write" a patch file, they are generated using the diff command. I usually find projects requiring a unified diff (diff -u)
to test out a patch file, write a small program and save it. Modify the program and save it as a different file. then do the following.
diff -u oldfile.c newfile.c > myPatch.patch
you can now have a look at what the patch looks like. A "-" shows what will be removed... a "+" shows what will be added. To apply the patch run
patch -p0 < myPatch.patch
the file "oldfile.c" will now be patched with the contents of "newfile.c"
edit: this of course is all from a linux point of view
For example, this are the two files readmaze.c and robot2.c that i need to produce a patch file for.
So what you mean is that, first i run
i understand what is a patch file suppose to do,but now i don't know where to start from.Code:diff -u readmaze.c diff -u robot2.c
diana --> programming is tough
what is the patch for? Patches are for a change in a file. So if you have an original version of readmaze.c and then you modify it to get a new version of readmaze.c you would run:Originally Posted by dianazheng
diff -u original-readmaze.c new-readmaze.c
to get a patch representing your changes.
You can generate the patch from higher directory levels but this will affect the "-pnum" value you use to apply the patch.
ex:
diff -u original/readmaze.c myproject/readmaze.c
Ahhh, i get what you means already. thanks.
diana --> programming is tough