before your firstupdate, do this: cp config.php-dist config.php-dist-old and diff -c config.php-dist config.php > config.php.patch
I don't think patch will work for this. You've got three files which are different and you have to match, merge on each line using different sets of rules (Comments, define)... in any event, I followed your instructions and it bombed...
My code completely rebuilds config.php from the new dist - matching on define statements and ignoring the comments or lack thereof in config.php as the case may be. Local changes to defines are replaced by the new dist if it wasn't in the old dist. Not sure if patch can do all that. Additionally, it give a stoplight display of the status, green, yellow, red and blue.
Here is what I did for a test case.
copied config.php to config.php-dist
edited config.php-dist first few lines to replace dbtypes with "xxxxx"
edited config.php and deleted a bunch of comment lines
then: diff -c config.php-dist config.php > config.php.patch
now I edited config.php-dist adding some define statements, changing others, added comments
then followed the rest of your instructions