How do I manually edit a patch? I am trying to add the book_module patch to allow a book to show on the front page from the start rather than just when you're viewing a page. There are "-"'s and "+"'s and I get that you switch them around - but what is an @ ... it doesn't seem to be that straightforward but I don't know how to add a patch with a program on windows.... /-:

Yours,
bobo

Comments

ahwayakchih’s picture

(i wanted to post example but it wouldn't allow me because of "suspicious data" :(

  • --- line is an old file name (the one next changes apply to) and date
  • +++ line is changed file name (the one which was "new" when patch was created - it's not used really) and date
  • @@ -253,7 +253,7 @@ line means that following code is code starting on line 253 (so first line of code is line number 253 in - file, and also in + file in this case), and results in 7 lines of code.
  • lines without "-" and "+" at the beginning should stay unchanged
  • - line should be removed
  • + line should be used in place of - line

That's all :)
There are also other formats of patch, but the one explained above is probably most often used.

chx’s picture

there _is_ a port of patch for Windows...

--
Drupal development: making the world better, one patch at a time. | A bedroom without a teddy is like a face without a smile.

Torenware’s picture

You really don't want to edit patch files by hand. Heck, the thought of it turns my stomach...

Best advice if you are using Windows (besides to use Linux or BSD instead....) is to install the free Cygwin tools, which lets you not only run patch, but also run any bash or other Unix shell scripts as well.

You can get it from Redhat's web site: http://sources.redhat.com/cygwin/. The installer makes it easy to install patch. Once you have it installed, just cd into the top level of what you want to patch (typically, the top level of a copy of your Drupal install), and do something like this:

patch -p0 < nasty-patch-file.patch

You may have to play with that number after -p. For details, you can check the man page for patch (you can install Unix man pages using Cygwin as well).

Rob
Torenware Networks

Rob Thorne
Torenware Networks

ahwayakchih’s picture

Actually applying patch by hand (which is what bobo asked about, if i understood him correctly) is not so bad. Writing patch file is probably much more work ;)