Diff

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (Links)
Line 7: Line 7:
 
}}
 
}}
 
{{DISPLAYTITLE:diff}}
 
{{DISPLAYTITLE:diff}}
 +
:''For "diff files" in general, see [[Archiving#Diff files]].''
  
 
'''diff''' is a family of formats associated with the traditional Unix <code>diff</code> utility, especially the GNU implementation of it. It encodes the differences between two files. It is often used in the form of a "patch" file that can be used to convert one file to the other.
 
'''diff''' is a family of formats associated with the traditional Unix <code>diff</code> utility, especially the GNU implementation of it. It encodes the differences between two files. It is often used in the form of a "patch" file that can be used to convert one file to the other.

Revision as of 14:47, 21 September 2019

File Format
Name diff
Ontology
Extension(s) .patch, .diff

example of unified diff

example of unified diff

For "diff files" in general, see Archiving#Diff files.

diff is a family of formats associated with the traditional Unix diff utility, especially the GNU implementation of it. It encodes the differences between two files. It is often used in the form of a "patch" file that can be used to convert one file to the other.

Diff is intended for use with text files whose lines are mostly short, such as source code.

Contents

Formats

The diff utility can produce several different formats:

Normal diff

The default format, sometimes called "normal diff", contains just the differences, with no header or context.

Context diff

diff -c produces Context diff format. It has a header, and some contextual data that often makes it possible to patch files even after they have been modified.

It is characterized by lines with lots of asterisks:

 ***************

Note that the term "context diff" is sometimes used to mean "any diff format that features context" (which would include Unified diff, a different format).

Unified diff

Main article: Unified diff

diff -u produces Unified diff format. The idea is the same as with Context diff, but the format is more efficient and readable. It is characterized by lines that begin with "@@".

ed script

diff -e produces a script to be interpreted by the ed text editor. It was used for patch files before the introduction of the patch utility, but has long been obsolete for that purpose.

Software

Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox