<s>
The	O
computer	O
tool	O
patch	B-Application
is	O
a	O
Unix	B-Application
program	B-Application
that	O
updates	O
text	O
files	O
according	O
to	O
instructions	O
contained	O
in	O
a	O
separate	O
file	O
,	O
called	O
a	O
patch	B-Application
file	I-Application
.	O
</s>
<s>
The	O
patch	B-Application
file	I-Application
(	O
also	O
called	O
a	O
patch	B-Application
for	O
short	O
)	O
is	O
a	O
text	O
file	O
that	O
consists	O
of	O
a	O
list	O
of	O
differences	O
and	O
is	O
produced	O
by	O
running	O
the	O
related	O
diff	B-Application
program	B-Application
with	O
the	O
original	O
and	O
updated	O
file	O
as	O
arguments	O
.	O
</s>
<s>
Updating	O
files	O
with	O
patch	B-Application
is	O
often	O
referred	O
to	O
as	O
applying	O
the	O
patch	B-Application
or	O
simply	O
patching	O
the	O
files	O
.	O
</s>
<s>
The	O
original	O
patch	B-Application
program	B-Application
was	O
written	O
by	O
Larry	O
Wall	O
(	O
who	O
went	O
on	O
to	O
create	O
the	O
Perl	B-Language
programming	I-Language
language	I-Language
)	O
and	O
posted	O
to	O
mod.sources	O
(	O
which	O
later	O
became	O
comp.sources.unix	O
)	O
in	O
May	O
1985	O
.	O
</s>
<s>
A	O
variant	O
of	O
the	O
program	B-Application
(	O
but	O
not	O
the	O
only	O
one	O
)	O
is	O
part	O
of	O
the	B-Application
GNU	I-Application
project	I-Application
and	O
is	O
maintained	O
by	O
the	O
FSF	B-Operating_System
.	O
</s>
<s>
Developed	O
by	O
a	O
programmer	O
for	O
other	O
programmers	O
,	O
patch	B-Application
was	O
frequently	O
used	O
for	O
updating	O
source	O
code	O
to	O
a	O
newer	O
version	O
.	O
</s>
<s>
Because	O
of	O
this	O
,	O
many	O
people	O
came	O
to	O
associate	O
patches	B-Application
with	O
source	O
code	O
,	O
whereas	O
patches	B-Application
can	O
in	O
fact	O
be	O
applied	O
to	O
any	O
text	O
.	O
</s>
<s>
Patched	O
files	O
do	O
not	O
accumulate	O
any	O
unneeded	O
text	O
,	O
which	O
is	O
what	O
some	O
people	O
perceive	O
based	O
on	O
the	O
English	O
meaning	O
of	O
the	O
word	O
;	O
patch	B-Application
is	O
as	O
capable	O
of	O
removing	O
text	O
as	O
it	O
is	O
of	O
adding	O
it	O
.	O
</s>
<s>
Patches	B-Application
described	O
here	O
should	O
not	O
be	O
confused	O
with	O
binary	O
patches	B-Application
,	O
which	O
,	O
although	O
can	O
be	O
conceptually	O
similar	O
,	O
are	O
distributed	O
to	O
update	O
binary	O
files	O
comprising	O
the	O
program	B-Application
to	O
a	O
new	O
release	O
.	O
</s>
<s>
The	O
diff	B-Application
files	O
that	O
serve	O
as	O
input	O
to	O
patch	B-Application
are	O
readable	O
text	O
files	O
,	O
which	O
means	O
that	O
they	O
can	O
be	O
easily	O
reviewed	O
or	O
modified	O
by	O
humans	O
before	O
use	O
.	O
</s>
<s>
In	O
addition	O
to	O
the	O
"	O
diff	B-Application
"	O
program	B-Application
,	O
diffs	B-Application
can	O
also	O
be	O
produced	O
by	O
other	O
programs	O
,	O
such	O
as	O
Subversion	B-Application
,	O
CVS	B-Application
,	O
RCS	B-Architecture
,	O
Mercurial	B-Protocol
and	O
Git	B-Application
.	O
</s>
<s>
Patches	B-Application
have	O
been	O
the	O
crucial	O
component	O
of	O
many	O
source	B-Architecture
control	I-Architecture
systems	O
,	O
including	O
CVS	B-Application
.	O
</s>
<s>
When	O
more	O
advanced	O
diffs	B-Application
are	O
used	O
,	O
patches	B-Application
can	O
be	O
applied	O
even	O
to	O
files	O
that	O
have	O
been	O
modified	O
in	O
the	O
meantime	O
,	O
as	O
long	O
as	O
those	O
modifications	O
do	O
not	O
interfere	O
with	O
the	O
patch	B-Application
.	O
</s>
<s>
This	O
is	O
achieved	O
by	O
using	O
"	O
context	O
diffs	B-Application
"	O
and	O
"	O
unified	O
diffs	B-Application
"	O
(	O
also	O
known	O
as	O
"	O
unidiffs	O
"	O
)	O
,	O
which	O
surround	O
each	O
change	O
with	O
context	O
,	O
which	O
is	O
the	O
text	O
immediately	O
before	O
and	O
after	O
the	O
changed	O
part	O
.	O
</s>
<s>
Patch	B-Application
can	O
then	O
use	O
this	O
context	O
to	O
locate	O
the	O
region	O
to	O
be	O
patched	O
even	O
if	O
it	O
has	O
been	O
displaced	O
by	O
changes	O
earlier	O
in	O
the	O
file	O
,	O
using	O
the	O
line	O
numbers	O
in	O
the	O
diffs	B-Application
as	O
a	O
starting	O
point	O
.	O
</s>
<s>
Because	O
of	O
this	O
property	O
,	O
context	O
and	O
unified	O
diffs	B-Application
are	O
the	O
preferred	O
form	O
of	O
patches	B-Application
for	O
submission	O
to	O
many	O
software	O
projects	O
.	O
</s>
<s>
The	O
above	O
features	O
make	O
diff	B-Application
and	O
patch	B-Application
especially	O
popular	O
for	O
exchanging	O
modifications	O
to	O
open-source	B-Application
software	I-Application
.	O
</s>
<s>
Outsiders	O
can	O
download	O
the	O
latest	O
publicly	O
available	O
source	O
code	O
,	O
make	O
modifications	O
to	O
it	O
,	O
and	O
send	O
them	O
,	O
in	O
diff	B-Application
form	O
,	O
to	O
the	O
development	O
team	O
.	O
</s>
<s>
Using	O
diffs	B-Application
,	O
the	O
development	O
team	O
has	O
the	O
ability	O
to	O
effectively	O
review	O
the	O
patches	B-Application
before	O
applying	O
them	O
,	O
and	O
can	O
apply	O
them	O
to	O
a	O
newer	O
code	O
base	O
than	O
the	O
one	O
the	O
outside	O
developer	O
had	O
access	O
to	O
.	O
</s>
<s>
To	O
create	O
a	O
patch	B-Application
,	O
one	O
could	O
run	O
the	O
following	O
command	B-Application
in	O
a	O
shell	O
:	O
</s>
<s>
To	O
apply	O
a	O
patch	B-Application
,	O
one	O
could	O
run	O
the	O
following	O
command	B-Application
in	O
a	O
shell	O
:	O
</s>
<s>
This	O
tells	O
patch	B-Application
to	O
apply	O
the	O
changes	O
to	O
the	O
specified	O
files	O
described	O
in	O
mods.diff	O
.	O
</s>
<s>
Patches	B-Application
to	O
files	O
in	O
subdirectories	O
require	O
the	O
additional	O
-pnumber	O
option	O
,	O
where	O
number	O
is	O
1	O
if	O
the	O
base	O
directory	O
of	O
the	O
source	O
tree	O
is	O
included	O
in	O
the	O
diff	B-Application
,	O
and	O
0	O
otherwise	O
.	O
</s>
<s>
Patches	B-Application
can	O
be	O
undone	O
,	O
or	O
reversed	O
,	O
with	O
the	O
'	O
-R	O
'	O
option	O
:	O
</s>
<s>
In	O
some	O
cases	O
when	O
the	O
file	O
is	O
not	O
identical	O
to	O
the	O
version	O
the	O
diff	B-Application
was	O
generated	O
against	O
,	O
the	O
patch	B-Application
will	O
not	O
be	O
able	O
to	O
be	O
applied	O
cleanly	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
lines	O
of	O
text	O
are	O
inserted	O
at	O
the	O
beginning	O
,	O
the	O
line	O
numbers	O
referred	O
to	O
in	O
the	O
patch	B-Application
will	O
be	O
incorrect	O
.	O
</s>
<s>
patch	B-Application
is	O
able	O
to	O
recover	O
from	O
this	O
,	O
by	O
looking	O
at	O
nearby	O
lines	O
to	O
relocate	O
the	O
text	O
to	O
be	O
patched	O
.	O
</s>
<s>
It	O
will	O
also	O
recover	O
when	O
lines	O
of	O
context	O
(	O
for	O
context	O
and	O
unified	O
diffs	B-Application
)	O
are	O
altered	O
;	O
this	O
is	O
described	O
as	O
fuzz	O
.	O
</s>
<s>
Originally	O
written	O
for	O
Unix	B-Application
and	O
Unix-like	B-Operating_System
systems	I-Operating_System
,	O
patch	B-Application
has	O
also	O
been	O
ported	O
to	O
Windows	B-Application
and	O
many	O
other	O
platforms	O
.	O
</s>
<s>
Windows	B-Application
ports	O
of	O
patch	B-Application
are	O
provided	O
by	O
GnuWin32	B-Language
and	O
UnxUtils	B-Application
.	O
</s>
<s>
A	O
patch	B-Application
command	B-Application
is	O
also	O
part	O
of	O
ASCII	O
's	O
MSX-DOS2	O
Tools	O
for	O
MSX-DOS	B-Operating_System
version	O
2	O
.	O
</s>
