blob: cf5262622f6a7f82b3989cbcb4ee1ebd4652b220 [file] [log] [blame]
Junio C Hamano543f8d62009-07-29 08:35:211Raw output format
2-----------------
3
4The raw output format from "git-diff-index", "git-diff-tree",
Junio C Hamano7ae0ab22007-11-03 02:46:465"git-diff-files" and "git diff --raw" are very similar.
Junio C Hamano1a4e8412005-12-27 08:17:236
Junio C Hamanoa77a5132007-06-08 16:13:447These commands all compare two sets of things; what is
Junio C Hamano1a4e8412005-12-27 08:17:238compared differs:
9
10git-diff-index <tree-ish>::
11 compares the <tree-ish> and the files on the filesystem.
12
13git-diff-index --cached <tree-ish>::
14 compares the <tree-ish> and the index.
15
16git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]::
17 compares the trees named by the two arguments.
18
19git-diff-files [<pattern>...]::
20 compares the index and the files on the filesystem.
21
Junio C Hamano167b1382010-01-31 23:04:3122The "git-diff-tree" command begins its output by printing the hash of
Junio C Hamano543f8d62009-07-29 08:35:2123what is being compared. After that, all the commands print one output
24line per changed file.
Junio C Hamano1a4e8412005-12-27 08:17:2325
26An output line is formatted this way:
27
28------------------------------------------------
29in-place edit :100644 100644 bcd1234... 0123456... M file0
30copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
31rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
32create :000000 100644 0000000... 1234567... A file4
33delete :100644 000000 1234567... 0000000... D file5
34unmerged :000000 000000 0000000... 0000000... U file6
35------------------------------------------------
36
37That is, from the left to the right:
38
39. a colon.
40. mode for "src"; 000000 if creation or unmerged.
41. a space.
42. mode for "dst"; 000000 if deletion or unmerged.
43. a space.
44. sha1 for "src"; 0\{40\} if creation or unmerged.
45. a space.
46. sha1 for "dst"; 0\{40\} if creation, unmerged or "look at work tree".
47. a space.
48. status, followed by optional "score" number.
Junio C Hamano92d80372016-07-13 22:00:0549. a tab or a NUL when `-z` option is used.
Junio C Hamano1a4e8412005-12-27 08:17:2350. path for "src"
Junio C Hamano92d80372016-07-13 22:00:0551. a tab or a NUL when `-z` option is used; only exists for C or R.
Junio C Hamano1a4e8412005-12-27 08:17:2352. path for "dst"; only exists for C or R.
Junio C Hamano92d80372016-07-13 22:00:0553. an LF or a NUL when `-z` option is used, to terminate the record.
Junio C Hamano1a4e8412005-12-27 08:17:2354
Junio C Hamanoaa17c7c2008-11-03 04:36:5855Possible status letters are:
56
57- A: addition of a file
58- C: copy of a file into a new one
59- D: deletion of a file
60- M: modification of the contents or mode of a file
61- R: renaming of a file
62- T: change in the type of the file
63- U: file is unmerged (you must complete the merge before it can
64be committed)
65- X: "unknown" change type (most probably a bug, please report it)
66
Junio C Hamano54bf1e22008-12-20 06:30:1167Status letters C and R are always followed by a score (denoting the
Junio C Hamanoaa17c7c2008-11-03 04:36:5868percentage of similarity between the source and target of the move or
Junio C Hamano6bb32e62015-02-17 22:11:2669copy). Status letter M may be followed by a score (denoting the
70percentage of dissimilarity) for file rewrites.
Junio C Hamanoaa17c7c2008-11-03 04:36:5871
Junio C Hamano1a4e8412005-12-27 08:17:2372<sha1> is shown as all 0's if a file is new on the filesystem
73and it is out of sync with the index.
74
75Example:
76
77------------------------------------------------
78:100644 100644 5be4a4...... 000000...... M file.c
79------------------------------------------------
80
81When `-z` option is not used, TAB, LF, and backslash characters
82in pathnames are represented as `\t`, `\n`, and `\\`,
83respectively.
84
Junio C Hamano67fad6d2007-05-06 08:53:1285diff format for merges
86----------------------
87
Junio C Hamano7ae0ab22007-11-03 02:46:4688"git-diff-tree", "git-diff-files" and "git-diff --raw"
Junio C Hamano92d80372016-07-13 22:00:0589can take `-c` or `--cc` option
Junio C Hamano67fad6d2007-05-06 08:53:1290to generate diff output also for merge commits. The output differs
91from the format described above in the following way:
92
93. there is a colon for each parent
94. there are more "src" modes and "src" sha1
95. status is concatenated status characters for each parent
96. no optional "score" number
97. single path, only for "dst"
98
99Example:
100
101------------------------------------------------
102::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c
103------------------------------------------------
104
105Note that 'combined diff' lists only files which were modified from
106all parents.
107
Junio C Hamano1a4e8412005-12-27 08:17:23108
Junio C Hamano00b8b632007-12-07 09:50:49109include::diff-generate-patch.txt[]
Junio C Hamano3a702342007-12-12 21:34:02110
111
112other diff formats
113------------------
114
115The `--summary` option describes newly added, deleted, renamed and
116copied files. The `--stat` option adds diffstat(1) graph to the
117output. These options can be combined with other options, such as
118`-p`, and are meant for human consumption.
119
120When showing a change that involves a rename or a copy, `--stat` output
121formats the pathnames compactly by combining common prefix and suffix of
122the pathnames. For example, a change that moves `arch/i386/Makefile` to
123`arch/x86/Makefile` while modifying 4 lines will be shown like this:
124
125------------------------------------
126arch/{i386 => x86}/Makefile | 4 +--
127------------------------------------
128
129The `--numstat` option gives the diffstat(1) information but is designed
130for easier machine consumption. An entry in `--numstat` output looks
131like this:
132
133----------------------------------------
1341 2 README
1353 1 arch/{i386 => x86}/Makefile
136----------------------------------------
137
138That is, from left to right:
139
140. the number of added lines;
141. a tab;
142. the number of deleted lines;
143. a tab;
144. pathname (possibly with rename/copy information);
145. a newline.
146
147When `-z` output option is in effect, the output is formatted this way:
148
149----------------------------------------
1501 2 README NUL
1513 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
152----------------------------------------
153
154That is:
155
156. the number of added lines;
157. a tab;
158. the number of deleted lines;
159. a tab;
160. a NUL (only exists if renamed/copied);
161. pathname in preimage;
162. a NUL (only exists if renamed/copied);
163. pathname in postimage (only exists if renamed/copied);
164. a NUL.
165
166The extra `NUL` before the preimage path in renamed case is to allow
167scripts that read the output to tell if the current record being read is
168a single-path record or a rename/copy record without reading ahead.
169After reading added and deleted lines, reading up to `NUL` would yield
170the pathname, but if that is `NUL`, the record will show two paths.