Unified diff
From Just Solve the File Format Problem
(Difference between revisions)
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
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
- Unified Diff Format - Ad-hoc specification by Guido van Rossum
- GNU Diffutilis manual: Detailed Description of Unified Format
[edit] Software
- GNU Diffutils:
diff
(with-u
option),patch
- git:
git
with eithergit diff...
,git format-patch...
, orgit log -p
can be used to provide unified diff- Conversely
git apply ...
can be used to apply diff or patches that were created viagit
and that the user is inside a functional git filesystem, where top directory has a folder named.git
- Conversely
[edit] Sample files
- Example from the GNU Diffutils manual
- http://www.apache.org/dist/httpd/patches/ ...
- Updated git-remote documentation #6 in patch/diff format - GitHub - via inputting
https://github.com/git/git/pull/6.diff
into the address bar will make GitHub provide the pull request (PR) in a suitable patch/diff format
[edit] Links
- Wikipedia:Diff utility has a section on Unified diff