Raw
1 Raw output format
2 -----------------
3
4 The raw output format from `git-diff-index`, `git-diff-tree`,
5 `git-diff-files` and `git diff --raw` are very similar.
6
7 These commands all compare two sets of things; what is
8 compared differs:
9
10 `git-diff-index <tree-ish>`::
11 compares the _<tree-ish>_ and the files on the filesystem.
12
13 `git-diff-index --cached <tree-ish>`::
14 compares the _<tree-ish>_ and the index.
15
16 `git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]`::
17 compares the trees named by the two arguments.
18
19 `git-diff-files [<pattern>...]`::
20 compares the index and the files on the filesystem.
21
22 All the commands print one output line per changed file,
23 except `git diff-files` in the case of an unmerged file, which prints
24 both an "unmerged" and an "in-place edit" line.
25
26 An output line is formatted this way:
27
28 ------------------------------------------------
29 in-place edit :100644 100644 bcd1234 0123456 M file0
30 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
31 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
32 create :000000 100644 0000000 1234567 A file4
33 delete :100644 000000 1234567 0000000 D file5
34 unmerged :000000 000000 0000000 0000000 U file6
35 ------------------------------------------------
36
37 That is, from the left to the right:
38
39 . a colon.
40 . mode for "src"; 000000 if creation, or if "src" is from the index and is unmerged.
41 . a space.
42 . mode for "dst"; 000000 if deletion, or if "dst" is from the index and is unmerged.
43 . a space.
44 . sha1 for "src"; 0\{40\} if creation, or if "src" is from the index and is unmerged.
45 . a space.
46 . sha1 for "dst"; 0\{40\} if deletion, if "dst" is from the index and is unmerged, or if "dst" is from the work tree and is out of sync with the index.
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.
54
55 Possible 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 (regular file, symbolic link or submodule)
63 - `U`: file is unmerged (you must complete the merge before it can
64 be committed)
65 - `X`: "unknown" change type (most probably a bug, please report it)
66
67 Status letters `C` and `R` are always followed by a score (denoting the
68 percentage of similarity between the source and target of the move or
69 copy). Status letter `M` may be followed by a score (denoting the
70 percentage of dissimilarity) for file rewrites.
71
72 The sha1 for "dst" is shown as all 0's if a file on the filesystem
73 is out of sync with the index.
74
75 Example:
76
77 ------------------------------------------------
78 :100644 100644 5be4a4a 0000000 M file.c
79 ------------------------------------------------
80
81 Without the `-z` option, pathnames with "unusual" characters are
82 quoted as explained for the configuration variable `core.quotePath`
83 (see linkgit:git-config[1]). Using `-z` the filename is output
84 verbatim and the line is terminated by a NUL byte.
85
86 diff format for merges
87 ----------------------
88
89 `git-diff-tree`, `git-diff-files` and `git-diff --raw`
90 can take `-c` or `--cc` option
91 to generate diff output also for merge commits. The output differs
92 from the format described above in the following way:
93
94 . there is a colon for each parent
95 . there are more "src" modes and "src" sha1
96 . status is concatenated status characters for each parent
97 . no optional "score" number
98 . tab-separated pathname(s) of the file
99
100 For `-c` and `--cc`, only the destination or final path is shown even
101 if the file was renamed on any side of history. With
102 `--combined-all-paths`, the name of the path in each parent is shown
103 followed by the name of the path in the merge commit.
104
105 Examples for `-c` and `--cc` without `--combined-all-paths`:
106
107 ------------------------------------------------
108 ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c
109 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM bar.sh
110 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR phooey.c
111 ------------------------------------------------
112
113 Examples when `--combined-all-paths` added to either `-c` or `--cc`:
114
115 ------------------------------------------------
116 ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM desc.c desc.c desc.c
117 ::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM foo.sh bar.sh bar.sh
118 ::100644 100644 100644 e07d6c5 9042e82 ee91881 RR fooey.c fuey.c phooey.c
119 ------------------------------------------------
120
121 Note that 'combined diff' lists only files which were modified from
122 all parents.
123
124
125 include::diff-generate-patch.adoc[]
126
127
128 other diff formats
129 ------------------
130
131 The `--summary` option describes newly added, deleted, renamed and
132 copied files. The `--stat` option adds `diffstat`(1) graph to the
133 output. These options can be combined with other options, such as
134 `-p`, and are meant for human consumption.
135
136 When showing a change that involves a rename or a copy, `--stat` output
137 formats the pathnames compactly by combining common prefix and suffix of
138 the pathnames. For example, a change that moves `arch/i386/Makefile` to
139 `arch/x86/Makefile` while modifying 4 lines will be shown like this:
140
141 ------------------------------------
142 arch/{i386 => x86}/Makefile | 4 +--
143 ------------------------------------
144
145 The `--numstat` option gives the diffstat(1) information but is designed
146 for easier machine consumption. An entry in `--numstat` output looks
147 like this:
148
149 ----------------------------------------
150 1 2 README
151 3 1 arch/{i386 => x86}/Makefile
152 ----------------------------------------
153
154 That is, from left to right:
155
156 . the number of added lines;
157 . a tab;
158 . the number of deleted lines;
159 . a tab;
160 . pathname (possibly with rename/copy information);
161 . a newline.
162
163 When `-z` output option is in effect, the output is formatted this way:
164
165 ----------------------------------------
166 1 2 README NUL
167 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
168 ----------------------------------------
169
170 That is:
171
172 . the number of added lines;
173 . a tab;
174 . the number of deleted lines;
175 . a tab;
176 . a NUL (only exists if renamed/copied);
177 . pathname in preimage;
178 . a NUL (only exists if renamed/copied);
179 . pathname in postimage (only exists if renamed/copied);
180 . a NUL.
181
182 The extra `NUL` before the preimage path in renamed case is to allow
183 scripts that read the output to tell if the current record being read is
184 a single-path record or a rename/copy record without reading ahead.
185 After reading added and deleted lines, reading up to `NUL` would yield
186 the pathname, but if that is `NUL`, the record will show two paths.