13902b7f39c1a9eb2a3f41b71ac19a37f17db91a
[git.git] / man1 / git-diff-tree.1
1 .\"Generated by db2man.xsl. Don't modify this, modify the source.
2 .de Sh \" Subsection
3 .br
4 .if t .Sp
5 .ne 5
6 .PP
7 \fB\\$1\fR
8 .PP
9 ..
10 .de Sp \" Vertical space (when we can't use .PP)
11 .if t .sp .5v
12 .if n .sp
13 ..
14 .de Ip \" List item
15 .br
16 .ie \\n(.$>=3 .ne \\$3
17 .el .ne 3
18 .IP "\\$1" \\$2
19 ..
20 .TH "GIT-DIFF-TREE" 1 "" "" ""
21 .SH NAME
22 git-diff-tree \- Compares the content and mode of blobs found via two tree objects
23 .SH "SYNOPSIS"
24
25 .nf
26 git\-diff\-tree [\-\-stdin] [\-m] [\-s] [\-v] [\-\-no\-commit\-id] [\-\-pretty] [\-t] [\-r]
27               [\-\-root] [<common diff options>] <tree\-ish> [<tree\-ish>] [<path>...]
28 .fi
29
30 .SH "DESCRIPTION"
31
32
33 Compares the content and mode of the blobs found via two tree objects\&.
34
35
36 If there is only one <tree\-ish> given, the commit is compared with its parents (see \-\-stdin below)\&.
37
38
39 Note that "git\-diff\-tree" can use the tree encapsulated in a commit object\&.
40
41 .SH "OPTIONS"
42
43 .TP
44 \-p
45 Generate patch (see section on generating patches)
46
47 .TP
48 \-u
49 Synonym for "\-p"\&.
50
51 .TP
52 \-z
53 \\0 line termination on output
54
55 .TP
56 \-\-name\-only
57 Show only names of changed files\&.
58
59 .TP
60 \-\-name\-status
61 Show only names and status of changed files\&.
62
63 .TP
64 \-\-full\-index
65 Instead of the first handful characters, show full object name of pre\- and post\-image blob on the "index" line when generating a patch format output\&.
66
67 .TP
68 \-\-abbrev[=<n>]
69 Instead of showing the full 40\-byte hexadecimal object name in diff\-raw format output and diff\-tree header lines, show only handful hexdigits prefix\&. This is independent of \-\-full\-index option above, which controls the diff\-patch output format\&. Non default number of digits can be specified with \-\-abbrev=<n>\&.
70
71 .TP
72 \-B
73 Break complete rewrite changes into pairs of delete and create\&.
74
75 .TP
76 \-M
77 Detect renames\&.
78
79 .TP
80 \-C
81 Detect copies as well as renames\&.
82
83 .TP
84 \-\-find\-copies\-harder
85 For performance reasons, by default, \-C option finds copies only if the original file of the copy was modified in the same changeset\&. This flag makes the command inspect unmodified files as candidates for the source of copy\&. This is a very expensive operation for large projects, so use it with caution\&.
86
87 .TP
88 \-l<num>
89 \-M and \-C options require O(n^2) processing time where n is the number of potential rename/copy targets\&. This option prevents rename/copy detection from running if the number of rename/copy targets exceeds the specified number\&.
90
91 .TP
92 \-S<string>
93 Look for differences that contain the change in <string>\&.
94
95 .TP
96 \-\-pickaxe\-all
97 When \-S finds a change, show all the changes in that changeset, not just the files that contain the change in <string>\&.
98
99 .TP
100 \-O<orderfile>
101 Output the patch in the order specified in the <orderfile>, which has one shell glob pattern per line\&.
102
103 .TP
104 \-R
105 Swap two inputs; that is, show differences from index or on\-disk file to tree contents\&.
106
107
108 For more detailed explanation on these common options, see also diffcore documentation: \fIdiffcore.html\fR\&.
109
110 .TP
111 <tree\-ish>
112 The id of a tree object\&.
113
114 .TP
115 <path>...
116 If provided, the results are limited to a subset of files matching one of these prefix strings\&. ie file matches /^<pattern1>|<pattern2>|.../ Note that this parameter does not provide any wildcard or regexp features\&.
117
118 .TP
119 \-r
120 recurse into sub\-trees
121
122 .TP
123 \-t
124 show tree entry itself as well as subtrees\&. Implies \-r\&.
125
126 .TP
127 \-\-root
128 When \-\-root is specified the initial commit will be showed as a big creation event\&. This is equivalent to a diff against the NULL tree\&.
129
130 .TP
131 \-\-stdin
132 When \-\-stdin is specified, the command does not take <tree\-ish> arguments from the command line\&. Instead, it reads either one <commit> or a pair of <tree\-ish> separated with a single space from its standard input\&.
133
134 When a single commit is given on one line of such input, it compares the commit with its parents\&. The following flags further affects its behaviour\&. This does not apply to the case where two <tree\-ish> separated with a single space are given\&.
135
136 .TP
137 \-m
138 By default, "git\-diff\-tree \-\-stdin" does not show differences for merge commits\&. With this flag, it shows differences to that commit from all of its parents\&.
139
140 .TP
141 \-s
142 By default, "git\-diff\-tree \-\-stdin" shows differences, either in machine\-readable form (without \-p) or in patch form (with \-p)\&. This output can be suppressed\&. It is only useful with \-v flag\&.
143
144 .TP
145 \-v
146 This flag causes "git\-diff\-tree \-\-stdin" to also show the commit message before the differences\&.
147
148 .TP
149 \-\-pretty[=(raw|medium|short)]
150 This is used to control "pretty printing" format of the commit message\&. Without "=<style>", it defaults to medium\&.
151
152 .TP
153 \-\-no\-commit\-id
154 git\-diff\-tree outputs a line with the commit ID when applicable\&. This flag suppressed the commit ID output\&.
155
156 .SH "LIMITING OUTPUT"
157
158
159 If you're only interested in differences in a subset of files, for example some architecture\-specific files, you might do:
160
161 .nf
162 git\-diff\-tree \-r <tree\-ish> <tree\-ish> arch/ia64 include/asm\-ia64
163 .fi
164
165
166 and it will only show you what changed in those two directories\&.
167
168
169 Or if you are searching for what changed in just kernel/sched\&.c, just do
170
171 .nf
172 git\-diff\-tree \-r <tree\-ish> <tree\-ish> kernel/sched\&.c
173 .fi
174
175
176 and it will ignore all differences to other files\&.
177
178
179 The pattern is always the prefix, and is matched exactly\&. There are no wildcards\&. Even stricter, it has to match a complete path component\&. I\&.e\&. "foo" does not pick up foobar\&.h\&. "foo" does match foo/bar\&.h so it can be used to name subdirectories\&.
180
181
182 An example of normal usage is:
183
184 .nf
185 torvalds@ppc970:~/git> git\-diff\-tree 5319e4\&.\&.\&.\&.\&.\&.
186 *100664\->100664 blob    ac348b\&.\&.\&.\&.\&.\&.\&.\->a01513\&.\&.\&.\&.\&.\&.\&.      git\-fsck\-objects\&.c
187 .fi
188
189
190 which tells you that the last commit changed just one file (it's from this one:
191
192 .IP
193 commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
194 tree 5319e4d609cdd282069cc4dce33c1db559539b03
195 parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
196 author Linus Torvalds <torvalds@ppc970\&.osdl\&.org> Sat Apr 9 12:02:30 2005
197 committer Linus Torvalds <torvalds@ppc970\&.osdl\&.org> Sat Apr 9 12:02:30 2005
198
199 Make "git\-fsck\-objects" print out all the root commits it finds\&.
200
201 Once I do the reference tracking, I'll also make it print out all the
202 HEAD commits it finds, which is even more interesting\&.
203
204 in case you care)\&.
205
206 .SH "OUTPUT FORMAT"
207
208
209 The output format from "git\-diff\-index", "git\-diff\-tree" and "git\-diff\-files" are very similar\&.
210
211
212 These commands all compare two sets of things; what is compared differs:
213
214 .TP
215 git\-diff\-index <tree\-ish>
216 compares the <tree\-ish> and the files on the filesystem\&.
217
218 .TP
219 git\-diff\-index \-\-cached <tree\-ish>
220 compares the <tree\-ish> and the index\&.
221
222 .TP
223 git\-diff\-tree [\-r] <tree\-ish\-1> <tree\-ish\-2> [<pattern>...]
224 compares the trees named by the two arguments\&.
225
226 .TP
227 git\-diff\-files [<pattern>...]
228 compares the index and the files on the filesystem\&.
229
230
231 An output line is formatted this way:
232
233 .IP
234 in\-place edit  :100644 100644 bcd1234\&.\&.\&. 0123456\&.\&.\&. M file0
235 copy\-edit      :100644 100644 abcd123\&.\&.\&. 1234567\&.\&.\&. C68 file1 file2
236 rename\-edit    :100644 100644 abcd123\&.\&.\&. 1234567\&.\&.\&. R86 file1 file3
237 create         :000000 100644 0000000\&.\&.\&. 1234567\&.\&.\&. A file4
238 delete         :100644 000000 1234567\&.\&.\&. 0000000\&.\&.\&. D file5
239 unmerged       :000000 000000 0000000\&.\&.\&. 0000000\&.\&.\&. U file6
240
241 That is, from the left to the right:
242
243 .TP 3
244 1.
245 a colon\&.
246 .TP
247 2.
248 mode for "src"; 000000 if creation or unmerged\&.
249 .TP
250 3.
251 a space\&.
252 .TP
253 4.
254 mode for "dst"; 000000 if deletion or unmerged\&.
255 .TP
256 5.
257 a space\&.
258 .TP
259 6.
260 sha1 for "src"; 0{40} if creation or unmerged\&.
261 .TP
262 7.
263 a space\&.
264 .TP
265 8.
266 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree"\&.
267 .TP
268 9.
269 a space\&.
270 .TP
271 10.
272 status, followed by optional "score" number\&.
273 .TP
274 11.
275 a tab or a NUL when \-z option is used\&.
276 .TP
277 12.
278 path for "src"
279 .TP
280 13.
281 a tab or a NUL when \-z option is used; only exists for C or R\&.
282 .TP
283 14.
284 path for "dst"; only exists for C or R\&.
285 .TP
286 15.
287 an LF or a NUL when \-z option is used, to terminate the record\&.
288 .LP
289
290
291 <sha1> is shown as all 0's if a file is new on the filesystem and it is out of sync with the index\&.
292
293
294 Example:
295
296 .IP
297 :100644 100644 5be4a4\&.\&.\&.\&.\&.\&. 000000\&.\&.\&.\&.\&.\&. M file\&.c
298
299 When \-z option is not used, TAB, LF, and backslash characters in pathnames are represented as \\t, \\n, and \\\\, respectively\&.
300
301 .SH "GENERATING PATCHES WITH -P"
302
303
304 When "git\-diff\-index", "git\-diff\-tree", or "git\-diff\-files" are run with a \-p option, they do not produce the output described above; instead they produce a patch file\&.
305
306
307 The patch generation can be customized at two levels\&.
308
309 .TP 3
310 1.
311 When the environment variable GIT_EXTERNAL_DIFF is not set, these commands internally invoke "diff" like this:
312
313
314 .nf
315 diff \-L a/<path> \-L b/<path> \-pu <old> <new>
316 .fi
317 For added files, /dev/null is used for <old>\&. For removed files, /dev/null is used for <new>
318
319 The "diff" formatting options can be customized via the environment variable GIT_DIFF_OPTS\&. For example, if you prefer context diff:
320
321 .nf
322 GIT_DIFF_OPTS=\-c git\-diff\-index \-p HEAD
323 .fi
324 .TP
325 2.
326 When the environment variable GIT_EXTERNAL_DIFF is set, the program named by it is called, instead of the diff invocation described above\&.
327
328 For a path that is added, removed, or modified, GIT_EXTERNAL_DIFF is called with 7 parameters:
329
330
331 .nf
332 path old\-file old\-hex old\-mode new\-file new\-hex new\-mode
333 .fi
334 where:
335
336 <old|new>\-file
337 are files GIT_EXTERNAL_DIFF can use to read the contents of <old|new>,
338 <old|new>\-hex
339 are the 40\-hexdigit SHA1 hashes,
340 <old|new>\-mode
341 are the octal representation of the file modes\&.
342 The file parameters can point at the user's working file (e\&.g\&. new\-file in "git\-diff\-files"), /dev/null (e\&.g\&. old\-file when a new file is added), or a temporary file (e\&.g\&. old\-file in the index)\&. GIT_EXTERNAL_DIFF should not worry about unlinking the temporary file \-\-\- it is removed when GIT_EXTERNAL_DIFF exits\&.
343 .LP
344
345
346 For a path that is unmerged, GIT_EXTERNAL_DIFF is called with 1 parameter, <path>\&.
347
348 .SH "GIT SPECIFIC EXTENSION TO DIFF FORMAT"
349
350
351 What \-p option produces is slightly different from the traditional diff format\&.
352
353 .TP 3
354 1.
355 It is preceded with a "git diff" header, that looks like this:
356
357
358 .nf
359 diff \-\-git a/file1 b/file2
360 .fi
361 The a/ and b/ filenames are the same unless rename/copy is involved\&. Especially, even for a creation or a deletion, /dev/null is _not_ used in place of a/ or b/ filenames\&.
362
363 When rename/copy is involved, file1 and file2 show the name of the source file of the rename/copy and the name of the file that rename/copy produces, respectively\&.
364 .TP
365 2.
366 It is followed by one or more extended header lines:
367
368 .nf
369 old mode <mode>
370 new mode <mode>
371 deleted file mode <mode>
372 new file mode <mode>
373 copy from <path>
374 copy to <path>
375 rename from <path>
376 rename to <path>
377 similarity index <number>
378 dissimilarity index <number>
379 index <hash>\&.\&.<hash> <mode>
380 .fi
381 .TP
382 3.
383 TAB, LF, and backslash characters in pathnames are represented as \\t, \\n, and \\\\, respectively\&.
384 .LP
385
386 .SH "AUTHOR"
387
388
389 Written by Linus Torvalds <torvalds@osdl\&.org>
390
391 .SH "DOCUMENTATION"
392
393
394 Documentation by David Greaves, Junio C Hamano and the git\-list <git@vger\&.kernel\&.org>\&.
395
396 .SH "GIT"
397
398
399 Part of the \fBgit\fR(7) suite
400