How I use "patch and diff"

While patching a file to code repository, I use the following commands. I generate diff at the location that I want to patch. 

Generating diff:

#diff -cp5 > patch.txt

Do a dry run:

#patch --dry-run -p0 -i patch.txt
--dry-run gives output without actually applying the patch. The output should tell us if everything is going right or if something needs our attention.
In one instance, this is how output looked on my linux box.
supadhy@harlow patch --dry-run -p0 -i patch.txt
patching file pkt/sw/se/xc/bsd/include/cfm/cfm_cli_const.h
patching file pkt/sw/se/xc/bsd/include/cfm/cfg_cfm.h
patching file pkt/sw/se/xc/bsd/include/cfm/cfg_cfm_ma.h
patching file pkt/sw/se/xc/bsd/include/cfm/cfm_exec_show.h
patching file pkt/sw/se/xc/bsd/include/cfm/cfmConf.ddl
In above command, -p0 flag is used when patching at the same level where diff is generated. If its one level above, use -p1 instead and so on. -i flag indicates what follows is a patch file.

If output looks fine, run the patch command without the
'--dry-run' flag.
#patch -p0 -i patch.txt