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