Include diff options in the git-log manpage
[git/git.git] / Documentation / diff-format.txt
CommitLineData
9e6c7230
GP
1The output format from "git-diff-index", "git-diff-tree",
2"git-diff-files" and "git diff --raw" are very similar.
03ea2802 3
a6080a0a 4These commands all compare two sets of things; what is
f73ae1fc 5compared differs:
03ea2802 6
215a7ad1 7git-diff-index <tree-ish>::
03ea2802
DG
8 compares the <tree-ish> and the files on the filesystem.
9
215a7ad1 10git-diff-index --cached <tree-ish>::
5f3aa197 11 compares the <tree-ish> and the index.
03ea2802
DG
12
13git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]::
14 compares the trees named by the two arguments.
15
16git-diff-files [<pattern>...]::
5f3aa197 17 compares the index and the files on the filesystem.
03ea2802 18
03ea2802 19
81e50eab 20An output line is formatted this way:
03ea2802 21
8db9307c 22------------------------------------------------
b6d8f309
JH
23in-place edit :100644 100644 bcd1234... 0123456... M file0
24copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
25rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
8db9307c 26create :000000 100644 0000000... 1234567... A file4
b6d8f309
JH
27delete :100644 000000 1234567... 0000000... D file5
28unmerged :000000 000000 0000000... 0000000... U file6
8db9307c 29------------------------------------------------
b6d8f309
JH
30
31That is, from the left to the right:
32
8db9307c
JH
33. a colon.
34. mode for "src"; 000000 if creation or unmerged.
35. a space.
36. mode for "dst"; 000000 if deletion or unmerged.
37. a space.
38. sha1 for "src"; 0\{40\} if creation or unmerged.
39. a space.
40. sha1 for "dst"; 0\{40\} if creation, unmerged or "look at work tree".
41. a space.
42. status, followed by optional "score" number.
43. a tab or a NUL when '-z' option is used.
44. path for "src"
45. a tab or a NUL when '-z' option is used; only exists for C or R.
46. path for "dst"; only exists for C or R.
47. an LF or a NUL when '-z' option is used, to terminate the record.
03ea2802 48
f73ae1fc 49<sha1> is shown as all 0's if a file is new on the filesystem
5f3aa197 50and it is out of sync with the index.
03ea2802 51
8db9307c
JH
52Example:
53
54------------------------------------------------
55:100644 100644 5be4a4...... 000000...... M file.c
56------------------------------------------------
03ea2802 57
d88156e9
JH
58When `-z` option is not used, TAB, LF, and backslash characters
59in pathnames are represented as `\t`, `\n`, and `\\`,
60respectively.
61
3b559eab
JN
62diff format for merges
63----------------------
64
9e6c7230
GP
65"git-diff-tree", "git-diff-files" and "git-diff --raw"
66can take '-c' or '--cc' option
3b559eab
JN
67to generate diff output also for merge commits. The output differs
68from the format described above in the following way:
69
70. there is a colon for each parent
71. there are more "src" modes and "src" sha1
72. status is concatenated status characters for each parent
73. no optional "score" number
74. single path, only for "dst"
75
76Example:
77
78------------------------------------------------
79::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c
80------------------------------------------------
81
82Note that 'combined diff' lists only files which were modified from
83all parents.
84
d88156e9 85
272bd3cf 86include::diff-generate-patch.txt[]