~ubuntu-branches/ubuntu/trusty/patch/trusty-security

« back to all changes in this revision

Viewing changes to patch.man

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2009-12-02 10:25:26 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20091202102526-5luk0zsqhghu58l2
Tags: 2.6-2
* Update watch file.
* Section: vcs.
* Suggests: diffutils-doc instead of diff-doc, thanks Christoph Anton
  Mitterer for spotting. Closes: #558974.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
.de Id
3
3
.ds Dt \\$4
4
4
..
5
 
.Id $Id: patch.man,v 1.31 2002/05/25 10:36:44 eggert Exp $
6
5
.ds = \-\^\-
7
6
.de Sp
8
7
.if t .sp .3
37
36
.B \*=backup
38
37
option.
39
38
The names of the files to be patched are usually taken from the patch file,
40
 
but if there's just one file to be patched it can specified on the
 
39
but if there's just one file to be patched it can be specified on the
41
40
command line as
42
41
.IR originalfile .
43
42
.PP
95
94
the first two and last two lines of context are ignored,
96
95
and another scan is made.
97
96
(The default maximum fuzz factor is 2.)
 
97
.PP
 
98
Hunks with less prefix context than suffix context (after applying fuzz)
 
99
must apply at the start of the file if their first line number is\ 1.  Hunks
 
100
with more prefix context than suffix context (after applying fuzz) must apply
 
101
at the end of the file.
 
102
.PP
98
103
If
99
104
.B patch
100
105
cannot find a place to install that hunk of the patch, it puts the
111
116
makes the file name too long, then
112
117
.B #
113
118
replaces the file name's last character).
114
 
(The rejected hunk comes out in ordinary context diff form regardless of
115
 
the input patch's form.
116
 
If the input was a normal diff, many of the contexts are simply null.)
 
119
.PP
 
120
The rejected hunk comes out in unified or context diff format.
 
121
If the input was a normal diff, many of the contexts are simply null.
117
122
The line numbers on the hunks in the reject file may be different than
118
123
in the patch file: they reflect the approximate location patch thinks the
119
124
failed hunks belong in the new file rather than the old one.
123
128
.B patch
124
129
thought the hunk should go on.
125
130
If the hunk is installed at a different line
126
 
from the line number specified in the diff you
 
131
from the line number specified in the diff, you
127
132
are told the offset.
128
133
A single large offset
129
134
.I may
282
287
is conforming to \s-1POSIX\s0.
283
288
.TP
284
289
\fB\-B\fP \fIpref\fP  or  \fB\*=prefix=\fP\fIpref\fP
285
 
Prefix
 
290
Use the
 
291
.B simple
 
292
method to determine backup file names (see the
 
293
.BI "\-V " method
 
294
or
 
295
.BI "\*=version\-control " method
 
296
option), and append
286
297
.I pref
287
 
to a file name when generating its simple backup file name.
 
298
to a file name when generating its backup file name.
288
299
For example, with
289
300
.B "\-B\ /junk/"
290
301
the simple backup file name for
293
304
.BR /junk/src/patch/util.c .
294
305
.TP
295
306
\fB\*=binary\fP
296
 
Read and write all files in binary mode,
297
 
except for standard output and
 
307
Write all files in binary mode, except for standard output and
298
308
.BR /dev/tty .
299
 
This option has no effect on \s-1POSIX\s0-conforming systems.
300
 
On systems like \s-1DOS\s0 where this option makes a difference,
301
 
the patch should be generated by
302
 
.BR "diff\ \-a\ \*=binary" .
 
309
When reading, disable the heuristic for transforming CRLF line endings into LF
 
310
line endings.
 
311
(On \s-1POSIX\s0-conforming systems, reads and writes never transform line
 
312
endings. On Windows, reads and writes do transform line endings by default,
 
313
and patches should be generated by
 
314
.B "diff\ \*=binary"
 
315
when line endings are significant.)
303
316
.TP
304
317
\fB\-c\fP  or  \fB\*=context\fP
305
318
Interpret the patch file as a ordinary context diff.
379
392
asks the user whether to get the file.
380
393
The default value of this option is given by the value of the
381
394
.B PATCH_GET
382
 
environment variable if it is set; if not, the default value is zero if
383
 
.B patch
384
 
is conforming to \s-1POSIX\s0, negative otherwise.
 
395
environment variable if it is set; if not, the default value is zero.
385
396
.TP
386
397
.B "\*=help"
387
398
Print a summary of options and exit.
403
414
Normal characters must still match exactly.
404
415
Each line of the context must still match a line in the original file.
405
416
.TP
 
417
\fB\*=merge\fP
 
418
Merge a patch file into the original files similar to \fBmerge\fP(1). If a
 
419
conflict is found, \fBpatch\fP outputs a warning and brackets the conflict
 
420
with \fB<<<<<<<\fP and \fB>>>>>>>\fP lines.  A typical conflict will look like
 
421
this:
 
422
.LP
 
423
.RS
 
424
.nf
 
425
.B <<<<<<<
 
426
.I lines from the original file
 
427
.B =======
 
428
.I lines from the patch
 
429
.B >>>>>>>
 
430
.RE
 
431
.fi
 
432
.IP "" 3
 
433
If there are conflicts, the user should edit the result and delete one
 
434
of the alternatives.  This option implies \fB\*=forward\fP and does not
 
435
take the \fB--fuzz\fR=\fInum\fP option into account.
 
436
.TP
406
437
\fB\-n\fP  or  \fB\*=normal\fP
407
438
Interpret the patch file as a normal diff.
408
439
.TP
418
449
Do not use this option if
419
450
.I outfile
420
451
is one of the files to be patched.
 
452
When \fIoutfile\fP is \fB\-\fP, send output to standard output, and send any
 
453
messages that would usually go to standard output to standard error.
421
454
.TP
422
455
\fB\-p\fP\fInum\fP  or  \fB\*=strip\fP\fB=\fP\fInum\fP
423
456
Strip the smallest prefix containing
515
548
.I rejectfile
516
549
instead of the default
517
550
.B \&.rej
518
 
file.
 
551
file.  When \fIrejectfile\fP is \fB\-\fP, discard rejects.
519
552
.TP
520
553
\fB\-R\fP  or  \fB\*=reverse\fP
521
554
Assume that this patch was created with the old and new files swapped.
546
579
reversed normal diffs begin with a delete, which fails, triggering
547
580
the heuristic.)
548
581
.TP
 
582
\fB\*=reject\-format=\fP\fIformat\fP
 
583
Produce reject files in the specified \fIformat\fP (either \fBcontext\fP or
 
584
\fBunified\fP).  Without this option, rejected hunks come out in unified diff
 
585
format if the input patch was of that format, otherwise in ordinary context
 
586
diff form.
 
587
.TP
549
588
\fB\-s\fP  or  \fB\*=silent\fP  or  \fB\*=quiet\fP
550
589
Work silently, unless an error occurs.
551
590
.TP
659
698
patchers.
660
699
.TP
661
700
\fB\-Y\fP \fIpref\fP  or  \fB\*=basename\-prefix=\fP\fIpref\fP
662
 
Prefix
 
701
Use the
 
702
.B simple
 
703
method to determine backup file names (see the
 
704
.BI "\-V " method
 
705
or
 
706
.BI "\*=version\-control " method
 
707
option), and prefix
663
708
.I pref
664
 
to the basename of a file name when generating its simple backup file name.
 
709
to the basename of a file name when generating its backup file name.
665
710
For example, with
666
711
.B "\-Y\ .del/"
667
712
the simple backup file name for
670
715
.BR src/patch/.del/util.c .
671
716
.TP
672
717
\fB\-z\fP \fIsuffix\fP  or  \fB\*=suffix=\fP\fIsuffix\fP
673
 
Use
 
718
Use the
 
719
.B simple
 
720
method to determine backup file names (see the
 
721
.BI "\-V " method
 
722
or
 
723
.BI "\*=version\-control " method
 
724
option), and use
674
725
.I suffix
675
 
as the simple backup suffix.
 
726
as the suffix.
676
727
For example, with
677
728
.B "\-z\ -"
678
 
the simple backup file name for
 
729
the backup file name for
679
730
.B src/patch/util.c
680
731
is
681
732
.BR src/patch/util.c- .
682
 
The backup suffix may also be specified by the
683
 
.B SIMPLE_BACKUP_SUFFIX
684
 
environment variable, which is overridden by this option.
685
733
.TP
686
734
\fB\-Z\fP  or  \fB\*=set\-utc\fP
687
735
Set the modification and access times of patched files from time stamps
765
813
option.
766
814
.SH FILES
767
815
.TP 3
768
 
.IB $TMPDIR "/p\(**"
 
816
.IB $TMPDIR "/p*"
769
817
temporary files
770
818
.TP
771
819
.B /dev/tty
772
820
controlling terminal; used to get answers to questions asked of the user
773
821
.SH "SEE ALSO"
774
822
.BR diff (1),
775
 
.BR ed (1)
 
823
.BR ed (1),
 
824
.BR merge (1).
776
825
.Sp
777
826
Marshall T. Rose and Einar A. Stefferud,
778
827
Proposed Standard for Message Encapsulation,
931
980
.BR patch 's
932
981
exit status is
933
982
0 if all hunks are applied successfully,
934
 
1 if some hunks cannot be applied,
 
983
1 if some hunks cannot be applied or there were merge conflicts,
935
984
and 2 if there is more serious trouble.
936
985
When applying a set of patches in a loop it behooves you to check this
937
986
exit status so you don't apply a later patch to a partially patched file.
949
998
script, and can detect
950
999
bad line numbers in a normal diff only when it finds a change or deletion.
951
1000
A context diff using fuzz factor 3 may have the same problem.
952
 
Until a suitable interactive interface is added, you should probably do
 
1001
You should probably do
953
1002
a context diff in these cases to see if the changes made sense.
954
1003
Of course, compiling without errors is a pretty good indication that the patch
955
1004
worked, but not always.
1108
1157
Please report bugs via email to
1109
1158
.BR <bug-patch@gnu.org> .
1110
1159
.PP
1111
 
.B patch
1112
 
could be smarter about partial matches, excessively deviant offsets and
1113
 
swapped code, but that would take an extra pass.
1114
 
.PP
1115
1160
If code has been duplicated (for instance with
1116
1161
\fB#ifdef OLDCODE\fP .\|.\|. \fB#else .\|.\|. #endif\fP),
1117
1162
.B patch
1122
1167
.B patch
1123
1168
thinks it is a reversed patch, and offers to un-apply the patch.
1124
1169
This could be construed as a feature.
 
1170
.PP
 
1171
Computing how to merge a hunk is significantly harder than using the standard
 
1172
fuzzy algorithm.  Bigger hunks, more context, a bigger offset from the
 
1173
original location, and a worse match all slow the algorithm down.
1125
1174
.SH COPYING
1126
1175
Copyright
1127
1176
.ie t \(co
1132
1181
.ie t \(co
1133
1182
.el (C)
1134
1183
1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
1135
 
2000, 2001, 2002 Free Software Foundation, Inc.
 
1184
2000, 2001, 2002, 2009 Free Software Foundation, Inc.
1136
1185
.PP
1137
1186
Permission is granted to make and distribute verbatim copies of
1138
1187
this manual provided the copyright notice and this permission notice
1158
1207
and made it conform better to \s-1POSIX\s0.
1159
1208
Other contributors include Wayne Davison, who added unidiff support,
1160
1209
and David MacKenzie, who added configuration and backup support.
 
1210
Andreas Gr\[:u]nbacher added support for merging.