Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:diff_patch_tips

Diff and patch Usage

Genral diff usage

Compare differences between 2 text files

-y side by side compare; „|“ indicates differences
-s Report when two files are the same
-r Recursively compare any subdirectories found
-w Ignore changes in white space
-N treat absent files as empty
-a treat all files as text
-u output NUM (default 3) lines of unified context

Use cmp for binary files.

Create a patch file

Initital situation: You have the source tree of the original project and your improved version of the project:

.
|-- project.org/
`-- project.new/

Create the patch file with:

diff -Naur project.org project.new > improvement.patch

If your editor is set to change the amount of whitespace (which may be useful, eg. when it automatically deletes trailing spaces) in project.new/ than you shold ignore this in the diff command in order not to confuse the receiver of the patch:

diff -Naurw project.org project.new > improvement.patch

Apply the patch file

Initital situation: You have the source tree of the project to be patched and the patch file:

.
|-- project.toBePatched/
`-- improvement.patch

Patch the project with:

  cd project.toBePatched
  patch -p1 < ../improvement.patch

You can test also try out first what the patch actually would do withou changing anything:

patch -p1 --dry-run < ../improvement.patch

More info at http://www.kegel.com/academy/opensource.html#patches

Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/diff_patch_tips.txt · Zuletzt geändert: 2013-02-18 12:10 von becki

Impressum - Datenschutzerklärung