Unified diff

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (Links)
(Indicate and provide example of git utility can be used to also generate and apply unified diff.)
 
Line 17: Line 17:
 
== Software ==
 
== Software ==
 
* [http://www.gnu.org/software/diffutils/ GNU Diffutils]: <code>diff</code> (with <code>-u</code> option), <code>patch</code>
 
* [http://www.gnu.org/software/diffutils/ GNU Diffutils]: <code>diff</code> (with <code>-u</code> option), <code>patch</code>
 +
* [https://git-scm.com/ git]: <code>git</code> with either <code>git diff...</code>, <code>git format-patch...</code>, or <code>git log -p</code> can be used to provide unified diff
 +
** Conversely <code>git apply ...</code> can be used to apply diff or patches that were created via <code>git</code> and that the user is inside a functional git filesystem, where top directory has a folder named <code>.git</code>
  
 
== Sample files ==
 
== Sample files ==
 
* [http://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html Example from the GNU Diffutils manual]
 
* [http://www.gnu.org/software/diffutils/manual/html_node/Example-Unified.html Example from the GNU Diffutils manual]
 
* http://www.apache.org/dist/httpd/patches/ ...
 
* http://www.apache.org/dist/httpd/patches/ ...
 +
* [https://patch-diff.githubusercontent.com/raw/git/git/pull/6.diff Updated git-remote documentation #6 in patch/diff format - GitHub] - via inputting <code>https://github.com/git/git/pull/6.diff</code> into the address bar will make GitHub provide the pull request (PR) in a suitable patch/diff format
  
 
== Links ==
 
== Links ==
 
* [[Wikipedia:Diff utility#Unified_format|Wikipedia:Diff utility]] has a section on Unified diff
 
* [[Wikipedia:Diff utility#Unified_format|Wikipedia:Diff utility]] has a section on Unified diff

Latest revision as of 22:56, 20 September 2025

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

Unified diff example

Unified diff example

Unified diff (or diff unified format, unified context diff, unidiff) is a diff format commonly used for patch files.

Contents

[edit] Identification

Unlike other diff formats, Unified diff has lines that begin with "@@".

[edit] Specifications

[edit] Software

  • GNU Diffutils: diff (with -u option), patch
  • git: git with either git diff..., git format-patch..., or git log -p can be used to provide unified diff
    • Conversely git apply ... can be used to apply diff or patches that were created via git and that the user is inside a functional git filesystem, where top directory has a folder named .git

[edit] Sample files

[edit] Links

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox