blob: e37c93479e6f5b84087420929a9082556578559f [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanod9d71c02006-02-08 00:52:336<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-diff-tree(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff-tree(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff-tree -
269 Compares the content and mode of blobs found via two tree objects
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
Junio C Hamanofb56a962006-01-28 10:38:19276<div class="content"><em>git-diff-tree</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
277 [-t] [-r] [-c | --cc] [--root] [&lt;common diff options&gt;]
278 &lt;tree-ish&gt; [&lt;tree-ish&gt;] [&lt;path&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23279</div>
280<h2>DESCRIPTION</h2>
281<div class="sectionbody">
282<p>Compares the content and mode of the blobs found via two tree objects.</p>
283<p>If there is only one &lt;tree-ish&gt; given, the commit is compared with its parents
284(see --stdin below).</p>
285<p>Note that "git-diff-tree" can use the tree encapsulated in a commit object.</p>
286</div>
287<h2>OPTIONS</h2>
288<div class="sectionbody">
289<dl>
290<dt>
291-p
292</dt>
293<dd>
294<p>
295 Generate patch (see section on generating patches)
296</p>
297</dd>
298<dt>
299-u
300</dt>
301<dd>
302<p>
303 Synonym for "-p".
304</p>
305</dd>
306<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34307--raw
308</dt>
309<dd>
310<p>
311 Generate the raw format.
312</p>
313</dd>
314<dt>
Junio C Hamano54559c82006-04-13 07:45:12315--patch-with-raw
316</dt>
317<dd>
318<p>
Junio C Hamano9ae1a062006-07-10 08:12:34319 Synonym for "-p --raw".
Junio C Hamano54559c82006-04-13 07:45:12320</p>
321</dd>
322<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29323--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42324</dt>
325<dd>
326<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29327 Generate a diffstat. You can override the default
328 output width for 80-column terminal by "--stat=width".
329 The width of the filename part can be controlled by
330 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42331</p>
332</dd>
333<dt>
Junio C Hamanofbe00522006-10-19 05:58:48334--numstat
335</dt>
336<dd>
337<p>
338 Similar to --stat, but shows number of added and
339 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43340 abbreviation, to make it more machine friendly. For
341 binary files, outputs two <tt>-</tt> instead of saying
342 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48343</p>
344</dd>
345<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04346--shortstat
347</dt>
348<dd>
349<p>
350 Output only the last line of the --stat format containing total
351 number of modified files, as well as number of added and deleted
352 lines.
353</p>
354</dd>
355<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11356--summary
357</dt>
358<dd>
359<p>
360 Output a condensed summary of extended header information
361 such as creations, renames and mode changes.
362</p>
363</dd>
364<dt>
Junio C Hamanod1308c92006-04-16 11:01:09365--patch-with-stat
366</dt>
367<dd>
368<p>
Junio C Hamano9ae1a062006-07-10 08:12:34369 Synonym for "-p --stat".
Junio C Hamanod1308c92006-04-16 11:01:09370</p>
371</dd>
372<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23373-z
374</dt>
375<dd>
376<p>
377 \0 line termination on output
378</p>
379</dd>
380<dt>
381--name-only
382</dt>
383<dd>
384<p>
385 Show only names of changed files.
386</p>
387</dd>
388<dt>
389--name-status
390</dt>
391<dd>
392<p>
393 Show only names and status of changed files.
394</p>
395</dd>
396<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34397--color
398</dt>
399<dd>
400<p>
401 Show colored diff.
402</p>
403</dd>
404<dt>
405--no-color
406</dt>
407<dd>
408<p>
409 Turn off colored diff, even when the configuration file
410 gives the default to color output.
411</p>
412</dd>
413<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41414--color-words
415</dt>
416<dd>
417<p>
418 Show colored word diff, i.e. color words which have changed.
419</p>
420</dd>
421<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34422--no-renames
423</dt>
424<dd>
425<p>
426 Turn off rename detection, even when the configuration
427 file gives the default to do so.
428</p>
429</dd>
430<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21431--check
432</dt>
433<dd>
434<p>
435 Warn if changes introduce trailing whitespace
436 or an indent that uses a space before a tab.
437</p>
438</dd>
439<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23440--full-index
441</dt>
442<dd>
443<p>
444 Instead of the first handful characters, show full
445 object name of pre- and post-image blob on the "index"
446 line when generating a patch format output.
447</p>
448</dd>
449<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34450--binary
451</dt>
452<dd>
453<p>
454 In addition to --full-index, output "binary diff" that
455 can be applied with "git apply".
456</p>
457</dd>
458<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23459--abbrev[=&lt;n&gt;]
460</dt>
461<dd>
462<p>
463 Instead of showing the full 40-byte hexadecimal object
464 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58465 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23466 independent of --full-index option above, which controls
467 the diff-patch output format. Non default number of
468 digits can be specified with --abbrev=&lt;n&gt;.
469</p>
470</dd>
471<dt>
472-B
473</dt>
474<dd>
475<p>
476 Break complete rewrite changes into pairs of delete and create.
477</p>
478</dd>
479<dt>
480-M
481</dt>
482<dd>
483<p>
484 Detect renames.
485</p>
486</dd>
487<dt>
488-C
489</dt>
490<dd>
491<p>
492 Detect copies as well as renames.
493</p>
494</dd>
495<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01496--diff-filter=[ACDMRTUXB*]
497</dt>
498<dd>
499<p>
500 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
501 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
502 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
503 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
504 Any combination of the filter characters may be used.
505 When <tt>*</tt> (All-or-none) is added to the combination, all
506 paths are selected if there is any file that matches
507 other criteria in the comparison; if there is no file
508 that matches other criteria, nothing is selected.
509</p>
510</dd>
511<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23512--find-copies-harder
513</dt>
514<dd>
515<p>
516 For performance reasons, by default, -C option finds copies only
517 if the original file of the copy was modified in the same
518 changeset. This flag makes the command
519 inspect unmodified files as candidates for the source of
520 copy. This is a very expensive operation for large
521 projects, so use it with caution.
522</p>
523</dd>
524<dt>
525-l&lt;num&gt;
526</dt>
527<dd>
528<p>
529 -M and -C options require O(n^2) processing time where n
530 is the number of potential rename/copy targets. This
531 option prevents rename/copy detection from running if
532 the number of rename/copy targets exceeds the specified
533 number.
534</p>
535</dd>
536<dt>
537-S&lt;string&gt;
538</dt>
539<dd>
540<p>
541 Look for differences that contain the change in &lt;string&gt;.
542</p>
543</dd>
544<dt>
545--pickaxe-all
546</dt>
547<dd>
548<p>
549 When -S finds a change, show all the changes in that
550 changeset, not just the files that contain the change
551 in &lt;string&gt;.
552</p>
553</dd>
554<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28555--pickaxe-regex
556</dt>
557<dd>
558<p>
559 Make the &lt;string&gt; not a plain string but an extended POSIX
560 regex to match.
561</p>
562</dd>
563<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23564-O&lt;orderfile&gt;
565</dt>
566<dd>
567<p>
568 Output the patch in the order specified in the
569 &lt;orderfile&gt;, which has one shell glob pattern per line.
570</p>
571</dd>
572<dt>
573-R
574</dt>
575<dd>
576<p>
577 Swap two inputs; that is, show differences from index or
578 on-disk file to tree contents.
579</p>
580</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14581<dt>
582--text
583</dt>
584<dd>
585<p>
586 Treat all files as text.
587</p>
588</dd>
589<dt>
590-a
591</dt>
592<dd>
593<p>
594 Shorthand for "--text".
595</p>
596</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07597<dt>
Junio C Hamanofd468962007-02-14 23:45:04598--ignore-space-at-eol
599</dt>
600<dd>
601<p>
602 Ignore changes in white spaces at EOL.
603</p>
604</dd>
605<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07606--ignore-space-change
607</dt>
608<dd>
609<p>
610 Ignore changes in amount of white space. This ignores white
611 space at line end, and consider all other sequences of one or
612 more white space characters to be equivalent.
613</p>
614</dd>
615<dt>
616-b
617</dt>
618<dd>
619<p>
620 Shorthand for "--ignore-space-change".
621</p>
622</dd>
623<dt>
624--ignore-all-space
625</dt>
626<dd>
627<p>
628 Ignore white space when comparing lines. This ignores
629 difference even if one line has white space where the other
630 line has none.
631</p>
632</dd>
633<dt>
634-w
635</dt>
636<dd>
637<p>
638 Shorthand for "--ignore-all-space".
639</p>
640</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23641</dl>
642<p>For more detailed explanation on these common options, see also
643<a href="diffcore.html">diffcore documentation</a>.</p>
644<dl>
645<dt>
646&lt;tree-ish&gt;
647</dt>
648<dd>
649<p>
650 The id of a tree object.
651</p>
652</dd>
653<dt>
654&lt;path&gt;&#8230;
655</dt>
656<dd>
657<p>
658 If provided, the results are limited to a subset of files
659 matching one of these prefix strings.
Junio C Hamano341071d2006-06-04 07:24:48660 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
Junio C Hamano1a4e8412005-12-27 08:17:23661 Note that this parameter does not provide any wildcard or regexp
662 features.
663</p>
664</dd>
665<dt>
666-r
667</dt>
668<dd>
669<p>
670 recurse into sub-trees
671</p>
672</dd>
673<dt>
674-t
675</dt>
676<dd>
677<p>
678 show tree entry itself as well as subtrees. Implies -r.
679</p>
680</dd>
681<dt>
682--root
683</dt>
684<dd>
685<p>
686 When <em>--root</em> is specified the initial commit will be showed as a big
687 creation event. This is equivalent to a diff against the NULL tree.
688</p>
689</dd>
690<dt>
691--stdin
692</dt>
693<dd>
694<p>
695 When <em>--stdin</em> is specified, the command does not take
696 &lt;tree-ish&gt; arguments from the command line. Instead, it
697 reads either one &lt;commit&gt; or a pair of &lt;tree-ish&gt;
698 separated with a single space from its standard input.
699</p>
700<p>When a single commit is given on one line of such input, it compares
701the commit with its parents. The following flags further affects its
Junio C Hamano341071d2006-06-04 07:24:48702behavior. This does not apply to the case where two &lt;tree-ish&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23703separated with a single space are given.</p>
704</dd>
705<dt>
706-m
707</dt>
708<dd>
709<p>
710 By default, "git-diff-tree --stdin" does not show
711 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16712 differences to that commit from all of its parents. See
713 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23714</p>
715</dd>
716<dt>
717-s
718</dt>
719<dd>
720<p>
721 By default, "git-diff-tree --stdin" shows differences,
722 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58723 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23724 only useful with <em>-v</em> flag.
725</p>
726</dd>
727<dt>
728-v
729</dt>
730<dd>
731<p>
732 This flag causes "git-diff-tree --stdin" to also show
733 the commit message before the differences.
734</p>
735</dd>
736<dt>
Junio C Hamanoa340aaa2006-11-23 02:47:33737--pretty[=<em>&lt;format&gt;</em>]
Junio C Hamano1a4e8412005-12-27 08:17:23738</dt>
739<dd>
740<p>
Junio C Hamanoa340aaa2006-11-23 02:47:33741 Pretty-prints the details of a commit. <tt>--pretty</tt>
742 without an explicit <tt>=&lt;format&gt;</tt> defaults to <em>medium</em>.
743 If the commit is a merge, and if the pretty-format
744 is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
745 inserted before the <em>Author:</em> line. This line begins with
746 "Merge: " and the sha1s of ancestral commits are printed,
747 separated by spaces. Note that the listed commits may not
748 necessarily be the list of the <strong>direct</strong> parent commits if you
749 have limited your view of history: for example, if you are
750 only interested in changes related to a certain directory or
751 file. Here are some additional details for each format:
Junio C Hamano1a4e8412005-12-27 08:17:23752</p>
Junio C Hamanoa340aaa2006-11-23 02:47:33753<ul>
754<li>
755<p>
756<em>oneline</em>
757</p>
758<div class="literalblock">
759<div class="content">
760<pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
761</div></div>
762<p>This is designed to be as compact as possible.</p>
763</li>
764<li>
765<p>
766<em>short</em>
767</p>
768<div class="literalblock">
769<div class="content">
770<pre><tt>commit &lt;sha1&gt;
771Author: &lt;author&gt;</tt></pre>
772</div></div>
773<div class="literalblock">
774<div class="content">
775<pre><tt>&lt;title line&gt;</tt></pre>
776</div></div>
777</li>
778<li>
779<p>
780<em>medium</em>
781</p>
782<div class="literalblock">
783<div class="content">
784<pre><tt>commit &lt;sha1&gt;
785Author: &lt;author&gt;
786Date: &lt;date&gt;</tt></pre>
787</div></div>
788<div class="literalblock">
789<div class="content">
790<pre><tt>&lt;title line&gt;</tt></pre>
791</div></div>
792<div class="literalblock">
793<div class="content">
794<pre><tt>&lt;full commit message&gt;</tt></pre>
795</div></div>
796</li>
797<li>
798<p>
799<em>full</em>
800</p>
801<div class="literalblock">
802<div class="content">
803<pre><tt>commit &lt;sha1&gt;
804Author: &lt;author&gt;
805Commit: &lt;committer&gt;</tt></pre>
806</div></div>
807<div class="literalblock">
808<div class="content">
809<pre><tt>&lt;title line&gt;</tt></pre>
810</div></div>
811<div class="literalblock">
812<div class="content">
813<pre><tt>&lt;full commit message&gt;</tt></pre>
814</div></div>
815</li>
816<li>
817<p>
818<em>fuller</em>
819</p>
820<div class="literalblock">
821<div class="content">
822<pre><tt>commit &lt;sha1&gt;
823Author: &lt;author&gt;
824AuthorDate: &lt;date &amp; time&gt;
825Commit: &lt;committer&gt;
826CommitDate: &lt;date &amp; time&gt;</tt></pre>
827</div></div>
828<div class="literalblock">
829<div class="content">
830<pre><tt>&lt;title line&gt;</tt></pre>
831</div></div>
832<div class="literalblock">
833<div class="content">
834<pre><tt>&lt;full commit message&gt;</tt></pre>
835</div></div>
836</li>
837<li>
838<p>
839<em>email</em>
840</p>
841<div class="literalblock">
842<div class="content">
843<pre><tt>From &lt;sha1&gt; &lt;date&gt;
844From: &lt;author&gt;
845Date: &lt;date &amp; time&gt;
846Subject: [PATCH] &lt;title line&gt;</tt></pre>
847</div></div>
848<div class="literalblock">
849<div class="content">
850<pre><tt>full commit message&gt;</tt></pre>
851</div></div>
852</li>
853<li>
854<p>
855<em>raw</em>
856</p>
857<p>The <em>raw</em> format shows the entire commit exactly as
858stored in the commit object. Notably, the SHA1s are
859displayed in full, regardless of whether --abbrev or
860--no-abbrev are used, and <em>parents</em> information show the
861true parent commits, without taking grafts nor history
862simplification into account.</p>
863</li>
864</ul>
Junio C Hamano1a4e8412005-12-27 08:17:23865</dd>
866<dt>
Junio C Hamano775a0f42006-12-31 01:19:14867--encoding[=&lt;encoding&gt;]
868</dt>
869<dd>
870<p>
871 The commit objects record the encoding used for the log message
872 in their encoding header; this option can be used to tell the
873 command to re-code the commit log message in the encoding
874 preferred by the user. For non plumbing commands this
875 defaults to UTF-8.
876</p>
877</dd>
878<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23879--no-commit-id
880</dt>
881<dd>
882<p>
883 git-diff-tree outputs a line with the commit ID when
884 applicable. This flag suppressed the commit ID output.
885</p>
886</dd>
Junio C Hamanofb56a962006-01-28 10:38:19887<dt>
Junio C Hamanoa8adb1e2006-04-10 23:46:16888-c
Junio C Hamanofb56a962006-01-28 10:38:19889</dt>
890<dd>
891<p>
Junio C Hamanoa8adb1e2006-04-10 23:46:16892 This flag changes the way a merge commit is displayed
Junio C Hamanofb56a962006-01-28 10:38:19893 (which means it is useful only when the command is given
894 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
Junio C Hamanoa8adb1e2006-04-10 23:46:16895 from each of the parents to the merge result simultaneously
896 instead of showing pairwise diff between a parent and the
897 result one at a time (which is what the <em>-m</em> option does).
898 Furthermore, it lists only files which were modified
899 from all parents.
900</p>
901</dd>
902<dt>
Junio C Hamano46338f52006-05-04 00:46:44903--cc
Junio C Hamanoa8adb1e2006-04-10 23:46:16904</dt>
905<dd>
906<p>
907 This flag changes the way a merge commit patch is displayed,
908 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
909 and <em>-p</em> options and further compresses the patch output
910 by omitting hunks that show differences from only one
Junio C Hamanofb56a962006-01-28 10:38:19911 parent, or show the same change from all but one parent
912 for an Octopus merge. When this optimization makes all
913 hunks disappear, the commit itself and the commit log
Junio C Hamanoa8adb1e2006-04-10 23:46:16914 message is not shown, just like in any other "empty diff" case.
Junio C Hamanofb56a962006-01-28 10:38:19915</p>
916</dd>
Junio C Hamanod9d71c02006-02-08 00:52:33917<dt>
918--always
919</dt>
920<dd>
921<p>
922 Show the commit itself and the commit log message even
923 if the diff itself is empty.
924</p>
925</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23926</dl>
927</div>
928<h2>Limiting Output</h2>
929<div class="sectionbody">
930<p>If you're only interested in differences in a subset of files, for
931example some architecture-specific files, you might do:</p>
932<div class="literalblock">
933<div class="content">
934<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
935</div></div>
936<p>and it will only show you what changed in those two directories.</p>
937<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
938<div class="literalblock">
939<div class="content">
940<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
941</div></div>
942<p>and it will ignore all differences to other files.</p>
943<p>The pattern is always the prefix, and is matched exactly. There are no
944wildcards. Even stricter, it has to match a complete path component.
945I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
946so it can be used to name subdirectories.</p>
947<p>An example of normal usage is:</p>
948<div class="literalblock">
949<div class="content">
950<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
951*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
952</div></div>
953<p>which tells you that the last commit changed just one file (it's from
954this one:</p>
955<div class="listingblock">
956<div class="content">
957<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
958tree 5319e4d609cdd282069cc4dce33c1db559539b03
959parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
960author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
961committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
962
963Make "git-fsck-objects" print out all the root commits it finds.
964
965Once I do the reference tracking, I'll also make it print out all the
966HEAD commits it finds, which is even more interesting.</tt></pre>
967</div></div>
968<p>in case you care).</p>
969</div>
970<h2>Output format</h2>
971<div class="sectionbody">
972<p>The output format from "git-diff-index", "git-diff-tree" and
973"git-diff-files" are very similar.</p>
974<p>These commands all compare two sets of things; what is
975compared differs:</p>
976<dl>
977<dt>
978git-diff-index &lt;tree-ish&gt;
979</dt>
980<dd>
981<p>
982 compares the &lt;tree-ish&gt; and the files on the filesystem.
983</p>
984</dd>
985<dt>
986git-diff-index --cached &lt;tree-ish&gt;
987</dt>
988<dd>
989<p>
990 compares the &lt;tree-ish&gt; and the index.
991</p>
992</dd>
993<dt>
994git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
995</dt>
996<dd>
997<p>
998 compares the trees named by the two arguments.
999</p>
1000</dd>
1001<dt>
1002git-diff-files [&lt;pattern&gt;&#8230;]
1003</dt>
1004<dd>
1005<p>
1006 compares the index and the files on the filesystem.
1007</p>
1008</dd>
1009</dl>
1010<p>An output line is formatted this way:</p>
1011<div class="listingblock">
1012<div class="content">
1013<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1014copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1015rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1016create :000000 100644 0000000... 1234567... A file4
1017delete :100644 000000 1234567... 0000000... D file5
1018unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1019</div></div>
1020<p>That is, from the left to the right:</p>
1021<ol>
1022<li>
1023<p>
1024a colon.
1025</p>
1026</li>
1027<li>
1028<p>
1029mode for "src"; 000000 if creation or unmerged.
1030</p>
1031</li>
1032<li>
1033<p>
1034a space.
1035</p>
1036</li>
1037<li>
1038<p>
1039mode for "dst"; 000000 if deletion or unmerged.
1040</p>
1041</li>
1042<li>
1043<p>
1044a space.
1045</p>
1046</li>
1047<li>
1048<p>
1049sha1 for "src"; 0{40} if creation or unmerged.
1050</p>
1051</li>
1052<li>
1053<p>
1054a space.
1055</p>
1056</li>
1057<li>
1058<p>
1059sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1060</p>
1061</li>
1062<li>
1063<p>
1064a space.
1065</p>
1066</li>
1067<li>
1068<p>
1069status, followed by optional "score" number.
1070</p>
1071</li>
1072<li>
1073<p>
1074a tab or a NUL when <em>-z</em> option is used.
1075</p>
1076</li>
1077<li>
1078<p>
1079path for "src"
1080</p>
1081</li>
1082<li>
1083<p>
1084a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1085</p>
1086</li>
1087<li>
1088<p>
1089path for "dst"; only exists for C or R.
1090</p>
1091</li>
1092<li>
1093<p>
1094an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1095</p>
1096</li>
1097</ol>
1098<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1099and it is out of sync with the index.</p>
1100<p>Example:</p>
1101<div class="listingblock">
1102<div class="content">
1103<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1104</div></div>
1105<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1106in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1107respectively.</p>
1108</div>
1109<h2>Generating patches with -p</h2>
1110<div class="sectionbody">
1111<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1112with a <em>-p</em> option, they do not produce the output described above;
Junio C Hamano1c437122006-11-28 02:22:251113instead they produce a patch file. You can customize the creation
1114of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
1115environment variables.</p>
1116<p>What the -p option produces is slightly different from the traditional
1117diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231118<ol>
1119<li>
1120<p>
Junio C Hamano235a91e2006-01-07 01:13:581121It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231122 this:
1123</p>
1124<div class="literalblock">
1125<div class="content">
1126<pre><tt>diff --git a/file1 b/file2</tt></pre>
1127</div></div>
1128<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1129involved. Especially, even for a creation or a deletion,
1130<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
1131<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1132name of the source file of the rename/copy and the name of
1133the file that rename/copy produces, respectively.</p>
1134</li>
1135<li>
1136<p>
1137It is followed by one or more extended header lines:
1138</p>
1139<div class="literalblock">
1140<div class="content">
1141<pre><tt>old mode &lt;mode&gt;
1142new mode &lt;mode&gt;
1143deleted file mode &lt;mode&gt;
1144new file mode &lt;mode&gt;
1145copy from &lt;path&gt;
1146copy to &lt;path&gt;
1147rename from &lt;path&gt;
1148rename to &lt;path&gt;
1149similarity index &lt;number&gt;
1150dissimilarity index &lt;number&gt;
1151index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1152</div></div>
1153</li>
1154<li>
1155<p>
Junio C Hamanoa053d542006-10-27 09:29:131156TAB, LF, double quote and backslash characters in pathnames
1157 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1158 If there is need for such substitution then the whole
1159 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231160</p>
1161</li>
1162</ol>
1163</div>
Junio C Hamanofb56a962006-01-28 10:38:191164<h2>combined diff format</h2>
1165<div class="sectionbody">
1166<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
1167to produce <em>combined diff</em>, which looks like this:</p>
1168<div class="listingblock">
1169<div class="content">
1170<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291171index fabadb8,cc95eb0..4866510
1172--- a/describe.c
1173+++ b/describe.c
1174@@@ -98,20 -98,12 +98,20 @@@
1175 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191176 }
1177
1178- static void describe(char *arg)
1179 -static void describe(struct commit *cmit, int last_one)
1180++static void describe(char *arg, int last_one)
1181 {
Junio C Hamano29f14312006-10-26 08:47:291182 + unsigned char sha1[20];
1183 + struct commit *cmit;
1184 struct commit_list *list;
1185 static int initialized = 0;
1186 struct commit_name *n;
1187
1188 + if (get_sha1(arg, sha1) &lt; 0)
1189 + usage(describe_usage);
1190 + cmit = lookup_commit_reference(sha1);
1191 + if (!cmit)
1192 + usage(describe_usage);
1193 +
1194 if (!initialized) {
1195 initialized = 1;
1196 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191197</div></div>
Junio C Hamano29f14312006-10-26 08:47:291198<ol>
1199<li>
1200<p>
1201It is preceded with a "git diff" header, that looks like
1202 this (when <em>-c</em> option is used):
1203</p>
1204<div class="literalblock">
1205<div class="content">
1206<pre><tt>diff --combined file</tt></pre>
1207</div></div>
1208<p>or like this (when <em>--cc</em> option is used):</p>
1209<div class="literalblock">
1210<div class="content">
1211<pre><tt>diff --c file</tt></pre>
1212</div></div>
1213</li>
1214<li>
1215<p>
1216It is followed by one or more extended header lines
1217 (this example shows a merge with two parents):
1218</p>
1219<div class="literalblock">
1220<div class="content">
1221<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1222mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1223new file mode &lt;mode&gt;
1224deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1225</div></div>
1226<p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
Junio C Hamanoee1e4282007-02-04 08:32:041227the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291228information about detected contents movement (renames and
1229copying detection) are designed to work with diff of two
1230&lt;tree-ish&gt; and are not used by combined diff format.</p>
1231</li>
1232<li>
1233<p>
1234It is followed by two-line from-file/to-file header
1235</p>
1236<div class="literalblock">
1237<div class="content">
1238<pre><tt>--- a/file
1239+++ b/file</tt></pre>
1240</div></div>
1241<p>Similar to two-line header for traditional <em>unified</em> diff
1242format, <tt>/dev/null</tt> is used to signal created or deleted
1243files.</p>
1244</li>
1245<li>
1246<p>
1247Chunk header format is modified to prevent people from
1248 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1249 was created for review of merge commit changes, and was not
1250 meant for apply. The change is similar to the change in the
1251 extended <em>index</em> header:
1252</p>
1253<div class="literalblock">
1254<div class="content">
1255<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1256</div></div>
1257<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1258header for combined diff format.</p>
1259</li>
1260</ol>
Junio C Hamanofb56a962006-01-28 10:38:191261<p>Unlike the traditional <em>unified</em> diff format, which shows two
1262files A and B with a single column that has <tt>-</tt> (minus &#8212;
1263appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291264added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191265compares two or more files file1, file2,&#8230; with one file X, and
1266shows how X differs from each of fileN. One column for each of
1267fileN is prepended to the output line to note how X's line is
1268different from it.</p>
1269<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291270fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191271in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291272and fileN does not have that line (in other words, the line was
1273added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191274<p>In the above example output, the function signature was changed
1275from both files (hence two <tt>-</tt> removals from both file1 and
1276file2, plus <tt>++</tt> to mean one line that was added does not appear
1277in either file1 nor file2). Also two other lines are the same
1278from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1279<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1280merge commit with the merge result (i.e. file1..fileN are the
1281parents). When shown by <tt>git diff-files -c</tt>, it compares the
1282two unresolved merge parents with the working tree file
1283(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1284"their version").</p>
1285</div>
Junio C Hamano1a4e8412005-12-27 08:17:231286<h2>Author</h2>
1287<div class="sectionbody">
1288<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1289</div>
1290<h2>Documentation</h2>
1291<div class="sectionbody">
1292<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1293</div>
1294<h2>GIT</h2>
1295<div class="sectionbody">
1296<p>Part of the <a href="git.html">git(7)</a> suite</p>
1297</div>
1298<div id="footer">
1299<div id="footer-text">
Junio C Hamanofd468962007-02-14 23:45:041300Last updated 14-Feb-2007 23:44:51 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231301</div>
1302</div>
1303</body>
1304</html>