blob: 15c7e794f4adaccb8885683946a9f4e7e4dc92c2 [file] [log] [blame]
David Kågedalf552e512009-07-28 10:32:18 +02001Raw output format
2-----------------
3
4The raw output format from "git-diff-index", "git-diff-tree",
Gerrit Pape9e6c7232007-10-31 13:59:16 +00005"git-diff-files" and "git diff --raw" are very similar.
David Greaves03ea2802005-05-08 18:22:48 +01006
Junio C Hamanoa6080a02007-06-07 00:04:01 -07007These commands all compare two sets of things; what is
Christian Mederf73ae1f2005-10-05 15:08:26 -07008compared differs:
David Greaves03ea2802005-05-08 18:22:48 +01009
Junio C Hamano215a7ad2005-09-07 17:26:23 -070010git-diff-index <tree-ish>::
David Greaves03ea2802005-05-08 18:22:48 +010011 compares the <tree-ish> and the files on the filesystem.
12
Junio C Hamano215a7ad2005-09-07 17:26:23 -070013git-diff-index --cached <tree-ish>::
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010014 compares the <tree-ish> and the index.
David Greaves03ea2802005-05-08 18:22:48 +010015
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>...]::
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010020 compares the index and the files on the filesystem.
David Greaves03ea2802005-05-08 18:22:48 +010021
Ralf Wildenhues6a5d0b02010-01-31 14:24:39 +010022The "git-diff-tree" command begins its output by printing the hash of
David Kågedalf552e512009-07-28 10:32:18 +020023what is being compared. After that, all the commands print one output
24line per changed file.
David Greaves03ea2802005-05-08 18:22:48 +010025
Junio C Hamano81e50ea2005-05-21 19:42:18 -070026An output line is formatted this way:
David Greaves03ea2802005-05-08 18:22:48 +010027
Junio C Hamano8db93072005-08-30 13:51:01 -070028------------------------------------------------
Junio C Hamanob6d8f302005-05-23 14:55:33 -070029in-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
Junio C Hamano8db93072005-08-30 13:51:01 -070032create :000000 100644 0000000... 1234567... A file4
Junio C Hamanob6d8f302005-05-23 14:55:33 -070033delete :100644 000000 1234567... 0000000... D file5
34unmerged :000000 000000 0000000... 0000000... U file6
Junio C Hamano8db93072005-08-30 13:51:01 -070035------------------------------------------------
David Greaves03ea2802005-05-08 18:22:48 +010036
Junio C Hamanob6d8f302005-05-23 14:55:33 -070037That is, from the left to the right:
David Greaves03ea2802005-05-08 18:22:48 +010038
Junio C Hamano8db93072005-08-30 13:51:01 -070039. 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.
49. a tab or a NUL when '-z' option is used.
50. path for "src"
51. a tab or a NUL when '-z' option is used; only exists for C or R.
52. path for "dst"; only exists for C or R.
53. an LF or a NUL when '-z' option is used, to terminate the record.
David Greaves03ea2802005-05-08 18:22:48 +010054
Yann Dirsona5a323f2008-11-02 14:37:28 +010055Possible 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
Markus Heidelberg04c8ce92008-12-19 13:14:18 +010067Status letters C and R are always followed by a score (denoting the
Yann Dirsona5a323f2008-11-02 14:37:28 +010068percentage of similarity between the source and target of the move or
69copy), and are the only ones to be so.
70
Christian Mederf73ae1f2005-10-05 15:08:26 -070071<sha1> is shown as all 0's if a file is new on the filesystem
Lukas_Sandström5f3aa192005-11-11 02:12:27 +010072and it is out of sync with the index.
David Greaves03ea2802005-05-08 18:22:48 +010073
Junio C Hamano8db93072005-08-30 13:51:01 -070074Example:
75
76------------------------------------------------
77:100644 100644 5be4a4...... 000000...... M file.c
78------------------------------------------------
David Greaves03ea2802005-05-08 18:22:48 +010079
Junio C Hamanod88156e2005-10-14 21:56:46 -070080When `-z` option is not used, TAB, LF, and backslash characters
81in pathnames are represented as `\t`, `\n`, and `\\`,
82respectively.
83
Jakub Narebski3b559ea2007-05-05 00:48:35 +020084diff format for merges
85----------------------
86
Gerrit Pape9e6c7232007-10-31 13:59:16 +000087"git-diff-tree", "git-diff-files" and "git-diff --raw"
88can take '-c' or '--cc' option
Jakub Narebski3b559ea2007-05-05 00:48:35 +020089to generate diff output also for merge commits. The output differs
90from the format described above in the following way:
91
92. there is a colon for each parent
93. there are more "src" modes and "src" sha1
94. status is concatenated status characters for each parent
95. no optional "score" number
96. single path, only for "dst"
97
98Example:
99
100------------------------------------------------
101::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c
102------------------------------------------------
103
104Note that 'combined diff' lists only files which were modified from
105all parents.
106
Junio C Hamanod88156e2005-10-14 21:56:46 -0700107
Miklos Vajna272bd3c2007-11-01 15:57:40 +0100108include::diff-generate-patch.txt[]
Junio C Hamanof6046522007-12-11 23:46:30 -0800109
110
111other diff formats
112------------------
113
114The `--summary` option describes newly added, deleted, renamed and
115copied files. The `--stat` option adds diffstat(1) graph to the
116output. These options can be combined with other options, such as
117`-p`, and are meant for human consumption.
118
119When showing a change that involves a rename or a copy, `--stat` output
120formats the pathnames compactly by combining common prefix and suffix of
121the pathnames. For example, a change that moves `arch/i386/Makefile` to
122`arch/x86/Makefile` while modifying 4 lines will be shown like this:
123
124------------------------------------
125arch/{i386 => x86}/Makefile | 4 +--
126------------------------------------
127
128The `--numstat` option gives the diffstat(1) information but is designed
129for easier machine consumption. An entry in `--numstat` output looks
130like this:
131
132----------------------------------------
1331 2 README
1343 1 arch/{i386 => x86}/Makefile
135----------------------------------------
136
137That is, from left to right:
138
139. the number of added lines;
140. a tab;
141. the number of deleted lines;
142. a tab;
143. pathname (possibly with rename/copy information);
144. a newline.
145
146When `-z` output option is in effect, the output is formatted this way:
147
148----------------------------------------
1491 2 README NUL
1503 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
151----------------------------------------
152
153That is:
154
155. the number of added lines;
156. a tab;
157. the number of deleted lines;
158. a tab;
159. a NUL (only exists if renamed/copied);
160. pathname in preimage;
161. a NUL (only exists if renamed/copied);
162. pathname in postimage (only exists if renamed/copied);
163. a NUL.
164
165The extra `NUL` before the preimage path in renamed case is to allow
166scripts that read the output to tell if the current record being read is
167a single-path record or a rename/copy record without reading ahead.
168After reading added and deleted lines, reading up to `NUL` would yield
169the pathname, but if that is `NUL`, the record will show two paths.