|
|
1.1 ! root 1: ''' $Header: patch.man,v 1.3 85/03/26 15:11:06 lwall Exp $ ! 2: ''' ! 3: ''' $Log: patch.man,v $ ! 4: ''' Revision 1.3 85/03/26 15:11:06 lwall ! 5: ''' Frozen. ! 6: ''' ! 7: ''' Revision 1.2.1.4 85/03/12 16:14:27 lwall ! 8: ''' Documented -p. ! 9: ''' ! 10: ''' Revision 1.2.1.3 85/03/12 16:09:41 lwall ! 11: ''' Documented -D. ! 12: ''' ! 13: ''' Revision 1.2.1.2 84/12/05 11:06:55 lwall ! 14: ''' Added -l switch, and noted bistability bug. ! 15: ''' ! 16: ''' Revision 1.2.1.1 84/12/04 17:23:39 lwall ! 17: ''' Branch for sdcrdcf changes. ! 18: ''' ! 19: ''' Revision 1.2 84/12/04 17:22:02 lwall ! 20: ''' Baseline version. ! 21: ''' ! 22: .de Sh ! 23: .br ! 24: .ne 5 ! 25: .PP ! 26: \fB\\$1\fR ! 27: .PP ! 28: .. ! 29: .de Sp ! 30: .if t .sp .5v ! 31: .if n .sp ! 32: .. ! 33: ''' ! 34: ''' Set up \*(-- to give an unbreakable dash; ! 35: ''' string Tr holds user defined translation string. ! 36: ''' Bell System Logo is used as a dummy character. ! 37: ''' ! 38: .ie n \{\ ! 39: .tr \(bs-\*(Tr ! 40: .ds -- \(bs- ! 41: .if (\n(.H=4u)&(1m=24u) .ds -- \(bs\h'-12u'\(bs\h'-12u'-\" diablo 10 pitch ! 42: .if (\n(.H=4u)&(1m=20u) .ds -- \(bs\h'-12u'\(bs\h'-8u'-\" diablo 12 pitch ! 43: .ds L" "" ! 44: .ds R" "" ! 45: .ds L' ' ! 46: .ds R' ' ! 47: 'br\} ! 48: .el\{\ ! 49: .ds -- \(em\| ! 50: .tr \*(Tr ! 51: .ds L" `` ! 52: .ds R" '' ! 53: .ds L' ` ! 54: .ds R' ' ! 55: 'br\} ! 56: .TH PATCH 1 "May 10, 1986" "Systems Development Corp" ! 57: .SH NAME ! 58: patch \- a program for applying a diff file to an original ! 59: .SH SYNOPSIS ! 60: .B patch ! 61: [options] orig diff [+ [options] orig] ! 62: .SH DESCRIPTION ! 63: .I Patch ! 64: will take a patch file containing any of the three forms of difference ! 65: listing produced by the ! 66: .I diff ! 67: program and apply those differences to an original file, producing a patched ! 68: version. ! 69: By default, the patched version is put in place of the original, with ! 70: the original file backed up to the same name with the ! 71: extension \*(L".orig\*(R", or as specified by the ! 72: .B -b ! 73: switch. ! 74: You may also specify where you want the output to go with a ! 75: .B -o ! 76: switch. ! 77: If ! 78: .I diff ! 79: is omitted, or is a hyphen, the patch will be read from standard input. ! 80: .PP ! 81: Upon startup, patch will attempt to determine the type of the diff file, ! 82: unless over-ruled by a ! 83: .BR -c , ! 84: .BR -e , ! 85: or ! 86: .B -n ! 87: switch. ! 88: Context diffs and normal diffs are applied by the ! 89: .I patch ! 90: program itself, while ed diffs are simply fed to the ! 91: .I ed ! 92: editor via a pipe. ! 93: .PP ! 94: .I Patch ! 95: will try to skip any leading garbage, apply the diff, ! 96: and then skip any trailing garbage. ! 97: Thus you could feed an article or message containing a context or normal ! 98: diff to ! 99: .IR patch , ! 100: and it should work. ! 101: If the entire diff is indented by a consistent amount, ! 102: this will be taken into account. ! 103: .PP ! 104: With context diffs, and to a lesser extent with normal diffs, ! 105: .I patch ! 106: can detect when the line numbers mentioned in the patch are incorrect, ! 107: and will attempt to find the correct place to apply each hunk of the patch. ! 108: As a first guess, it takes the line number mentioned for the hunk, plus or ! 109: minus any offset used in applying the previous hunk. ! 110: If that is not the correct place, ! 111: .I patch ! 112: will scan both forwards and backwards for a set of lines matching the context ! 113: given in the hunk. ! 114: All lines of the context must match. ! 115: If ! 116: .I patch ! 117: cannot find a place to install that hunk of the patch, it will put the ! 118: hunk out to a reject file, which normally is the name of the output file ! 119: plus \*(L".rej\*(R". ! 120: (Note that the rejected hunk will come out in context diff form whether the ! 121: input patch was a context diff or a normal diff. ! 122: If the input was a normal diff, many of the contexts will simply be null.) ! 123: .PP ! 124: If no original file is specified on the command line, ! 125: .I patch ! 126: will try to figure out from the leading garbage what the name of the file ! 127: to edit is. ! 128: In the header of a context diff, the filename is found from lines beginning ! 129: with \*(L"***\*(R" or \*(L"---\*(R", with the shortest name of an existing ! 130: file winning. ! 131: Only context diffs have lines like that, but if there is an \*(L"Index:\*(R" ! 132: line in the leading garbage, ! 133: .I patch ! 134: will try to use the filename from that line. ! 135: The context diff header takes precedence over an Index line. ! 136: If no filename can be intuited from the leading garbage, you will be asked ! 137: for the name of the file to patch. ! 138: .PP ! 139: (If the original file cannot be found, but a suitable SCCS or RCS file is ! 140: handy, ! 141: .I patch ! 142: will attempt to get or check out the file.) ! 143: .PP ! 144: Additionally, if the leading garbage contains a \*(L"Prereq: \*(R" line, ! 145: .I patch ! 146: will take the first word from the prerequisites line (normally a version ! 147: number) and check the input file to see if that word can be found. ! 148: If not, ! 149: .I patch ! 150: will ask for confirmation before proceeding. ! 151: .PP ! 152: The upshot of all this is that you should be able to say, while in a news ! 153: interface, the following: ! 154: .Sp ! 155: | patch -d /usr/src/local/blurfl ! 156: .Sp ! 157: and patch a file in the blurfl directory directly from the article containing ! 158: the patch. ! 159: .PP ! 160: If the patch file contains more than one patch, ! 161: .I patch ! 162: will try to apply each of them as if they came from separate patch files. ! 163: This means, among other things, that it is assumed that separate patches ! 164: will apply to separate files, and that the garbage before each patch will ! 165: be examined for interesting things such as filenames and revision level, as ! 166: mentioned previously. ! 167: You can give switches (and another original file name) for the second and ! 168: subsequent patches by separating the corresponding argument lists ! 169: by a \*(L'+\*(R'. ! 170: The argument list for a second or subsequent patch may not specify a new ! 171: patch file, however. ! 172: .PP ! 173: .I Patch ! 174: recognizes the following switches: ! 175: .TP 5 ! 176: .B \-b ! 177: causes the next argument to be interpreted as the backup extension, to be ! 178: used in place of \*(L".orig\*(R". ! 179: .TP 5 ! 180: .B \-c ! 181: forces ! 182: .I patch ! 183: to interpret the patch file as a context diff. ! 184: .TP 5 ! 185: .B \-d ! 186: causes ! 187: .I patch ! 188: to interpret the next argument as a directory, and cd to it before doing ! 189: anything else. ! 190: .TP 5 ! 191: .B \-D ! 192: causes ! 193: .I patch ! 194: to use the "#ifdef...#endif" construct to mark changes. ! 195: The argument following will be used as the differentiating symbol. ! 196: Note that, unlike the C compiler, there must be a space between the ! 197: .B \-D ! 198: and the argument. ! 199: .TP 5 ! 200: .B \-e ! 201: forces ! 202: .I patch ! 203: to interpret the patch file as an ed script. ! 204: .TP 5 ! 205: .B \-l ! 206: causes the pattern matching to be done loosely, in case the tabs and ! 207: spaces have been munged in you input file. ! 208: Any sequence of whitespace in the pattern line will match any sequence ! 209: in the input file. ! 210: Normal characters must still match exactly. ! 211: Each line of the context must still match a line in the input file. ! 212: .TP 5 ! 213: .B \-n ! 214: forces ! 215: .I patch ! 216: to interpret the patch file as a normal diff. ! 217: .TP 5 ! 218: .B \-N ! 219: forces patch to not try and reverse the diffs if it thinks that they may have ! 220: been swapped. See the ! 221: .B \-R ! 222: option below. ! 223: .TP 5 ! 224: .B \-o ! 225: causes the next argument to be interpreted as the output file name. ! 226: .TP 5 ! 227: .B \-p ! 228: causes leading pathnames to be kept. ! 229: If the diff is of the file \*(lqb/a.c\*(rq, patch will look for \*(lqa.c\*(rq ! 230: in the \*(lqb\*(rq directory, instead of the current directory. ! 231: This probably won't work if the diff has rooted pathnames. ! 232: .TP 5 ! 233: .B \-r ! 234: causes the next argument to be interpreted as the reject file name. ! 235: .TP 5 ! 236: .B \-R ! 237: tells ! 238: .I patch ! 239: that this patch was created with the old and new files swapped. ! 240: (Yes, I'm afraid that does happen occasionally, human nature being what it ! 241: is.) ! 242: .I Patch ! 243: will attempt to swap each hunk around before applying it. ! 244: Rejects will come out in the swapped format. ! 245: The ! 246: .B \-R ! 247: switch will not work with ed diff scripts because there is too little ! 248: information to reconstruct the reverse operation. ! 249: .Sp ! 250: If the first hunk of a patch fails, ! 251: .I patch ! 252: will reverse the hunk to see if it can be applied that way unless the ! 253: .B \-N ! 254: option is supplied. ! 255: If it can, the ! 256: .B \-R ! 257: switch will be set automatically. ! 258: If it can't, the patch will continue to be applied normally. ! 259: (Note: this method cannot detect a reversed patch if it is a normal diff ! 260: and if the first command is an append (i.e. it should have been a delete) ! 261: since appends always succeed. ! 262: Luckily, most patches add lines rather than delete them, so most reversed ! 263: normal diffs will begin with a delete, which will fail, triggering the ! 264: heuristic.) ! 265: .TP 5 ! 266: .B \-s ! 267: makes ! 268: .I patch ! 269: do its work silently, unless an error occurs. ! 270: .TP 5 ! 271: .B \-x<number> ! 272: sets internal debugging flags, and is of interest only to ! 273: .I patch ! 274: patchers. ! 275: .SH ENVIRONMENT ! 276: No environment variables are used by ! 277: .IR patch . ! 278: .SH FILES ! 279: /tmp/patch* ! 280: .SH SEE ALSO ! 281: diff(1) ! 282: .SH DIAGNOSTICS ! 283: Too many to list here, but generally indicative that ! 284: .I patch ! 285: couldn't parse your patch file. ! 286: .PP ! 287: The message \*(L"Hmm...\*(R" indicates that there is unprocessed text in ! 288: the patch file and that ! 289: .I patch ! 290: is attempting to intuit whether there is a patch in that text and, if so, ! 291: what kind of patch it is. ! 292: .SH CAVEATS ! 293: .I Patch ! 294: cannot tell if the line numbers are off in an ed script, and can only detect ! 295: bad line numbers in a normal diff when it finds a \*(L"change\*(R" command. ! 296: Until a suitable interactive interface is added, you should probably do ! 297: a context diff in these cases to see if the changes made sense. ! 298: Of course, compiling without errors is a pretty good indication that it ! 299: worked, but not always. ! 300: .PP ! 301: .I Patch ! 302: usually produces the correct results, even when it has to do a lot of ! 303: guessing. ! 304: However, the results are guaranteed to be correct only when the patch is ! 305: applied to exactly the same version of the file that the patch was ! 306: generated from. ! 307: .SH BUGS ! 308: Could be smarter about partial matches, excessively \&deviant offsets and ! 309: swapped code, but that would take an extra pass. ! 310: .PP ! 311: If code has been duplicated (for instance with #ifdef OLDCODE ... #else ... ! 312: #endif), ! 313: .I patch ! 314: is incapable of patching both versions, and, if it works at all, will likely ! 315: patch the wrong one, and tell you it succeeded to boot. ! 316: .PP ! 317: If you apply a patch you've already applied, ! 318: .I patch ! 319: will think it is a reversed patch, and un-apply the patch. ! 320: This could be construed as a feature.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.