diff

From Just Solve the File Format Problem
Revision as of 08:39, 28 December 2023 by Joergj (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
File Format
Name diff
Ontology
Extension(s) .patch, .diff, .pch[1], .dif[2], .rej[3]
MIME Type(s) text/x-patch[4]

example of unified diff

example of unified diff

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

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

References

  1. https://file-extension.net/seeker/file_extension_pch
  2. https://file-extension.net/seeker/file_extension_dif
  3. https://file-extension.net/seeker/file_extension_rej
  4. https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in freedesktop shared-mime-info database
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox