blob: bd0a9bfd2f448c5fc43e757f52c91a2d8b212633 [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
340 abbreviation, to make it more machine friendly.
341</p>
342</dd>
343<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04344--shortstat
345</dt>
346<dd>
347<p>
348 Output only the last line of the --stat format containing total
349 number of modified files, as well as number of added and deleted
350 lines.
351</p>
352</dd>
353<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11354--summary
355</dt>
356<dd>
357<p>
358 Output a condensed summary of extended header information
359 such as creations, renames and mode changes.
360</p>
361</dd>
362<dt>
Junio C Hamanod1308c92006-04-16 11:01:09363--patch-with-stat
364</dt>
365<dd>
366<p>
Junio C Hamano9ae1a062006-07-10 08:12:34367 Synonym for "-p --stat".
Junio C Hamanod1308c92006-04-16 11:01:09368</p>
369</dd>
370<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23371-z
372</dt>
373<dd>
374<p>
375 \0 line termination on output
376</p>
377</dd>
378<dt>
379--name-only
380</dt>
381<dd>
382<p>
383 Show only names of changed files.
384</p>
385</dd>
386<dt>
387--name-status
388</dt>
389<dd>
390<p>
391 Show only names and status of changed files.
392</p>
393</dd>
394<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34395--color
396</dt>
397<dd>
398<p>
399 Show colored diff.
400</p>
401</dd>
402<dt>
403--no-color
404</dt>
405<dd>
406<p>
407 Turn off colored diff, even when the configuration file
408 gives the default to color output.
409</p>
410</dd>
411<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41412--color-words
413</dt>
414<dd>
415<p>
416 Show colored word diff, i.e. color words which have changed.
417</p>
418</dd>
419<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34420--no-renames
421</dt>
422<dd>
423<p>
424 Turn off rename detection, even when the configuration
425 file gives the default to do so.
426</p>
427</dd>
428<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23429--full-index
430</dt>
431<dd>
432<p>
433 Instead of the first handful characters, show full
434 object name of pre- and post-image blob on the "index"
435 line when generating a patch format output.
436</p>
437</dd>
438<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34439--binary
440</dt>
441<dd>
442<p>
443 In addition to --full-index, output "binary diff" that
444 can be applied with "git apply".
445</p>
446</dd>
447<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23448--abbrev[=&lt;n&gt;]
449</dt>
450<dd>
451<p>
452 Instead of showing the full 40-byte hexadecimal object
453 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58454 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23455 independent of --full-index option above, which controls
456 the diff-patch output format. Non default number of
457 digits can be specified with --abbrev=&lt;n&gt;.
458</p>
459</dd>
460<dt>
461-B
462</dt>
463<dd>
464<p>
465 Break complete rewrite changes into pairs of delete and create.
466</p>
467</dd>
468<dt>
469-M
470</dt>
471<dd>
472<p>
473 Detect renames.
474</p>
475</dd>
476<dt>
477-C
478</dt>
479<dd>
480<p>
481 Detect copies as well as renames.
482</p>
483</dd>
484<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01485--diff-filter=[ACDMRTUXB*]
486</dt>
487<dd>
488<p>
489 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
490 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
491 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
492 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
493 Any combination of the filter characters may be used.
494 When <tt>*</tt> (All-or-none) is added to the combination, all
495 paths are selected if there is any file that matches
496 other criteria in the comparison; if there is no file
497 that matches other criteria, nothing is selected.
498</p>
499</dd>
500<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23501--find-copies-harder
502</dt>
503<dd>
504<p>
505 For performance reasons, by default, -C option finds copies only
506 if the original file of the copy was modified in the same
507 changeset. This flag makes the command
508 inspect unmodified files as candidates for the source of
509 copy. This is a very expensive operation for large
510 projects, so use it with caution.
511</p>
512</dd>
513<dt>
514-l&lt;num&gt;
515</dt>
516<dd>
517<p>
518 -M and -C options require O(n^2) processing time where n
519 is the number of potential rename/copy targets. This
520 option prevents rename/copy detection from running if
521 the number of rename/copy targets exceeds the specified
522 number.
523</p>
524</dd>
525<dt>
526-S&lt;string&gt;
527</dt>
528<dd>
529<p>
530 Look for differences that contain the change in &lt;string&gt;.
531</p>
532</dd>
533<dt>
534--pickaxe-all
535</dt>
536<dd>
537<p>
538 When -S finds a change, show all the changes in that
539 changeset, not just the files that contain the change
540 in &lt;string&gt;.
541</p>
542</dd>
543<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28544--pickaxe-regex
545</dt>
546<dd>
547<p>
548 Make the &lt;string&gt; not a plain string but an extended POSIX
549 regex to match.
550</p>
551</dd>
552<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23553-O&lt;orderfile&gt;
554</dt>
555<dd>
556<p>
557 Output the patch in the order specified in the
558 &lt;orderfile&gt;, which has one shell glob pattern per line.
559</p>
560</dd>
561<dt>
562-R
563</dt>
564<dd>
565<p>
566 Swap two inputs; that is, show differences from index or
567 on-disk file to tree contents.
568</p>
569</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14570<dt>
571--text
572</dt>
573<dd>
574<p>
575 Treat all files as text.
576</p>
577</dd>
578<dt>
579-a
580</dt>
581<dd>
582<p>
583 Shorthand for "--text".
584</p>
585</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07586<dt>
587--ignore-space-change
588</dt>
589<dd>
590<p>
591 Ignore changes in amount of white space. This ignores white
592 space at line end, and consider all other sequences of one or
593 more white space characters to be equivalent.
594</p>
595</dd>
596<dt>
597-b
598</dt>
599<dd>
600<p>
601 Shorthand for "--ignore-space-change".
602</p>
603</dd>
604<dt>
605--ignore-all-space
606</dt>
607<dd>
608<p>
609 Ignore white space when comparing lines. This ignores
610 difference even if one line has white space where the other
611 line has none.
612</p>
613</dd>
614<dt>
615-w
616</dt>
617<dd>
618<p>
619 Shorthand for "--ignore-all-space".
620</p>
621</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23622</dl>
623<p>For more detailed explanation on these common options, see also
624<a href="diffcore.html">diffcore documentation</a>.</p>
625<dl>
626<dt>
627&lt;tree-ish&gt;
628</dt>
629<dd>
630<p>
631 The id of a tree object.
632</p>
633</dd>
634<dt>
635&lt;path&gt;&#8230;
636</dt>
637<dd>
638<p>
639 If provided, the results are limited to a subset of files
640 matching one of these prefix strings.
Junio C Hamano341071d2006-06-04 07:24:48641 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
Junio C Hamano1a4e8412005-12-27 08:17:23642 Note that this parameter does not provide any wildcard or regexp
643 features.
644</p>
645</dd>
646<dt>
647-r
648</dt>
649<dd>
650<p>
651 recurse into sub-trees
652</p>
653</dd>
654<dt>
655-t
656</dt>
657<dd>
658<p>
659 show tree entry itself as well as subtrees. Implies -r.
660</p>
661</dd>
662<dt>
663--root
664</dt>
665<dd>
666<p>
667 When <em>--root</em> is specified the initial commit will be showed as a big
668 creation event. This is equivalent to a diff against the NULL tree.
669</p>
670</dd>
671<dt>
672--stdin
673</dt>
674<dd>
675<p>
676 When <em>--stdin</em> is specified, the command does not take
677 &lt;tree-ish&gt; arguments from the command line. Instead, it
678 reads either one &lt;commit&gt; or a pair of &lt;tree-ish&gt;
679 separated with a single space from its standard input.
680</p>
681<p>When a single commit is given on one line of such input, it compares
682the commit with its parents. The following flags further affects its
Junio C Hamano341071d2006-06-04 07:24:48683behavior. This does not apply to the case where two &lt;tree-ish&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23684separated with a single space are given.</p>
685</dd>
686<dt>
687-m
688</dt>
689<dd>
690<p>
691 By default, "git-diff-tree --stdin" does not show
692 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16693 differences to that commit from all of its parents. See
694 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23695</p>
696</dd>
697<dt>
698-s
699</dt>
700<dd>
701<p>
702 By default, "git-diff-tree --stdin" shows differences,
703 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58704 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23705 only useful with <em>-v</em> flag.
706</p>
707</dd>
708<dt>
709-v
710</dt>
711<dd>
712<p>
713 This flag causes "git-diff-tree --stdin" to also show
714 the commit message before the differences.
715</p>
716</dd>
717<dt>
Junio C Hamanoa340aaa2006-11-23 02:47:33718--pretty[=<em>&lt;format&gt;</em>]
Junio C Hamano1a4e8412005-12-27 08:17:23719</dt>
720<dd>
721<p>
Junio C Hamanoa340aaa2006-11-23 02:47:33722 Pretty-prints the details of a commit. <tt>--pretty</tt>
723 without an explicit <tt>=&lt;format&gt;</tt> defaults to <em>medium</em>.
724 If the commit is a merge, and if the pretty-format
725 is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
726 inserted before the <em>Author:</em> line. This line begins with
727 "Merge: " and the sha1s of ancestral commits are printed,
728 separated by spaces. Note that the listed commits may not
729 necessarily be the list of the <strong>direct</strong> parent commits if you
730 have limited your view of history: for example, if you are
731 only interested in changes related to a certain directory or
732 file. Here are some additional details for each format:
Junio C Hamano1a4e8412005-12-27 08:17:23733</p>
Junio C Hamanoa340aaa2006-11-23 02:47:33734<ul>
735<li>
736<p>
737<em>oneline</em>
738</p>
739<div class="literalblock">
740<div class="content">
741<pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
742</div></div>
743<p>This is designed to be as compact as possible.</p>
744</li>
745<li>
746<p>
747<em>short</em>
748</p>
749<div class="literalblock">
750<div class="content">
751<pre><tt>commit &lt;sha1&gt;
752Author: &lt;author&gt;</tt></pre>
753</div></div>
754<div class="literalblock">
755<div class="content">
756<pre><tt>&lt;title line&gt;</tt></pre>
757</div></div>
758</li>
759<li>
760<p>
761<em>medium</em>
762</p>
763<div class="literalblock">
764<div class="content">
765<pre><tt>commit &lt;sha1&gt;
766Author: &lt;author&gt;
767Date: &lt;date&gt;</tt></pre>
768</div></div>
769<div class="literalblock">
770<div class="content">
771<pre><tt>&lt;title line&gt;</tt></pre>
772</div></div>
773<div class="literalblock">
774<div class="content">
775<pre><tt>&lt;full commit message&gt;</tt></pre>
776</div></div>
777</li>
778<li>
779<p>
780<em>full</em>
781</p>
782<div class="literalblock">
783<div class="content">
784<pre><tt>commit &lt;sha1&gt;
785Author: &lt;author&gt;
786Commit: &lt;committer&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>fuller</em>
800</p>
801<div class="literalblock">
802<div class="content">
803<pre><tt>commit &lt;sha1&gt;
804Author: &lt;author&gt;
805AuthorDate: &lt;date &amp; time&gt;
806Commit: &lt;committer&gt;
807CommitDate: &lt;date &amp; time&gt;</tt></pre>
808</div></div>
809<div class="literalblock">
810<div class="content">
811<pre><tt>&lt;title line&gt;</tt></pre>
812</div></div>
813<div class="literalblock">
814<div class="content">
815<pre><tt>&lt;full commit message&gt;</tt></pre>
816</div></div>
817</li>
818<li>
819<p>
820<em>email</em>
821</p>
822<div class="literalblock">
823<div class="content">
824<pre><tt>From &lt;sha1&gt; &lt;date&gt;
825From: &lt;author&gt;
826Date: &lt;date &amp; time&gt;
827Subject: [PATCH] &lt;title line&gt;</tt></pre>
828</div></div>
829<div class="literalblock">
830<div class="content">
831<pre><tt>full commit message&gt;</tt></pre>
832</div></div>
833</li>
834<li>
835<p>
836<em>raw</em>
837</p>
838<p>The <em>raw</em> format shows the entire commit exactly as
839stored in the commit object. Notably, the SHA1s are
840displayed in full, regardless of whether --abbrev or
841--no-abbrev are used, and <em>parents</em> information show the
842true parent commits, without taking grafts nor history
843simplification into account.</p>
844</li>
845</ul>
Junio C Hamano1a4e8412005-12-27 08:17:23846</dd>
847<dt>
848--no-commit-id
849</dt>
850<dd>
851<p>
852 git-diff-tree outputs a line with the commit ID when
853 applicable. This flag suppressed the commit ID output.
854</p>
855</dd>
Junio C Hamanofb56a962006-01-28 10:38:19856<dt>
Junio C Hamanoa8adb1e2006-04-10 23:46:16857-c
Junio C Hamanofb56a962006-01-28 10:38:19858</dt>
859<dd>
860<p>
Junio C Hamanoa8adb1e2006-04-10 23:46:16861 This flag changes the way a merge commit is displayed
Junio C Hamanofb56a962006-01-28 10:38:19862 (which means it is useful only when the command is given
863 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
Junio C Hamanoa8adb1e2006-04-10 23:46:16864 from each of the parents to the merge result simultaneously
865 instead of showing pairwise diff between a parent and the
866 result one at a time (which is what the <em>-m</em> option does).
867 Furthermore, it lists only files which were modified
868 from all parents.
869</p>
870</dd>
871<dt>
Junio C Hamano46338f52006-05-04 00:46:44872--cc
Junio C Hamanoa8adb1e2006-04-10 23:46:16873</dt>
874<dd>
875<p>
876 This flag changes the way a merge commit patch is displayed,
877 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
878 and <em>-p</em> options and further compresses the patch output
879 by omitting hunks that show differences from only one
Junio C Hamanofb56a962006-01-28 10:38:19880 parent, or show the same change from all but one parent
881 for an Octopus merge. When this optimization makes all
882 hunks disappear, the commit itself and the commit log
Junio C Hamanoa8adb1e2006-04-10 23:46:16883 message is not shown, just like in any other "empty diff" case.
Junio C Hamanofb56a962006-01-28 10:38:19884</p>
885</dd>
Junio C Hamanod9d71c02006-02-08 00:52:33886<dt>
887--always
888</dt>
889<dd>
890<p>
891 Show the commit itself and the commit log message even
892 if the diff itself is empty.
893</p>
894</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23895</dl>
896</div>
897<h2>Limiting Output</h2>
898<div class="sectionbody">
899<p>If you're only interested in differences in a subset of files, for
900example some architecture-specific files, you might do:</p>
901<div class="literalblock">
902<div class="content">
903<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
904</div></div>
905<p>and it will only show you what changed in those two directories.</p>
906<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
907<div class="literalblock">
908<div class="content">
909<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
910</div></div>
911<p>and it will ignore all differences to other files.</p>
912<p>The pattern is always the prefix, and is matched exactly. There are no
913wildcards. Even stricter, it has to match a complete path component.
914I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
915so it can be used to name subdirectories.</p>
916<p>An example of normal usage is:</p>
917<div class="literalblock">
918<div class="content">
919<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
920*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
921</div></div>
922<p>which tells you that the last commit changed just one file (it's from
923this one:</p>
924<div class="listingblock">
925<div class="content">
926<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
927tree 5319e4d609cdd282069cc4dce33c1db559539b03
928parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
929author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
930committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
931
932Make "git-fsck-objects" print out all the root commits it finds.
933
934Once I do the reference tracking, I'll also make it print out all the
935HEAD commits it finds, which is even more interesting.</tt></pre>
936</div></div>
937<p>in case you care).</p>
938</div>
939<h2>Output format</h2>
940<div class="sectionbody">
941<p>The output format from "git-diff-index", "git-diff-tree" and
942"git-diff-files" are very similar.</p>
943<p>These commands all compare two sets of things; what is
944compared differs:</p>
945<dl>
946<dt>
947git-diff-index &lt;tree-ish&gt;
948</dt>
949<dd>
950<p>
951 compares the &lt;tree-ish&gt; and the files on the filesystem.
952</p>
953</dd>
954<dt>
955git-diff-index --cached &lt;tree-ish&gt;
956</dt>
957<dd>
958<p>
959 compares the &lt;tree-ish&gt; and the index.
960</p>
961</dd>
962<dt>
963git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
964</dt>
965<dd>
966<p>
967 compares the trees named by the two arguments.
968</p>
969</dd>
970<dt>
971git-diff-files [&lt;pattern&gt;&#8230;]
972</dt>
973<dd>
974<p>
975 compares the index and the files on the filesystem.
976</p>
977</dd>
978</dl>
979<p>An output line is formatted this way:</p>
980<div class="listingblock">
981<div class="content">
982<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
983copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
984rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
985create :000000 100644 0000000... 1234567... A file4
986delete :100644 000000 1234567... 0000000... D file5
987unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
988</div></div>
989<p>That is, from the left to the right:</p>
990<ol>
991<li>
992<p>
993a colon.
994</p>
995</li>
996<li>
997<p>
998mode for "src"; 000000 if creation or unmerged.
999</p>
1000</li>
1001<li>
1002<p>
1003a space.
1004</p>
1005</li>
1006<li>
1007<p>
1008mode for "dst"; 000000 if deletion or unmerged.
1009</p>
1010</li>
1011<li>
1012<p>
1013a space.
1014</p>
1015</li>
1016<li>
1017<p>
1018sha1 for "src"; 0{40} if creation or unmerged.
1019</p>
1020</li>
1021<li>
1022<p>
1023a space.
1024</p>
1025</li>
1026<li>
1027<p>
1028sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1029</p>
1030</li>
1031<li>
1032<p>
1033a space.
1034</p>
1035</li>
1036<li>
1037<p>
1038status, followed by optional "score" number.
1039</p>
1040</li>
1041<li>
1042<p>
1043a tab or a NUL when <em>-z</em> option is used.
1044</p>
1045</li>
1046<li>
1047<p>
1048path for "src"
1049</p>
1050</li>
1051<li>
1052<p>
1053a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1054</p>
1055</li>
1056<li>
1057<p>
1058path for "dst"; only exists for C or R.
1059</p>
1060</li>
1061<li>
1062<p>
1063an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1064</p>
1065</li>
1066</ol>
1067<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1068and it is out of sync with the index.</p>
1069<p>Example:</p>
1070<div class="listingblock">
1071<div class="content">
1072<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1073</div></div>
1074<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1075in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1076respectively.</p>
1077</div>
1078<h2>Generating patches with -p</h2>
1079<div class="sectionbody">
1080<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1081with a <em>-p</em> option, they do not produce the output described above;
Junio C Hamano1c437122006-11-28 02:22:251082instead they produce a patch file. You can customize the creation
1083of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
1084environment variables.</p>
1085<p>What the -p option produces is slightly different from the traditional
1086diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231087<ol>
1088<li>
1089<p>
Junio C Hamano235a91e2006-01-07 01:13:581090It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231091 this:
1092</p>
1093<div class="literalblock">
1094<div class="content">
1095<pre><tt>diff --git a/file1 b/file2</tt></pre>
1096</div></div>
1097<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1098involved. Especially, even for a creation or a deletion,
1099<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
1100<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1101name of the source file of the rename/copy and the name of
1102the file that rename/copy produces, respectively.</p>
1103</li>
1104<li>
1105<p>
1106It is followed by one or more extended header lines:
1107</p>
1108<div class="literalblock">
1109<div class="content">
1110<pre><tt>old mode &lt;mode&gt;
1111new mode &lt;mode&gt;
1112deleted file mode &lt;mode&gt;
1113new file mode &lt;mode&gt;
1114copy from &lt;path&gt;
1115copy to &lt;path&gt;
1116rename from &lt;path&gt;
1117rename to &lt;path&gt;
1118similarity index &lt;number&gt;
1119dissimilarity index &lt;number&gt;
1120index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1121</div></div>
1122</li>
1123<li>
1124<p>
Junio C Hamanoa053d542006-10-27 09:29:131125TAB, LF, double quote and backslash characters in pathnames
1126 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1127 If there is need for such substitution then the whole
1128 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231129</p>
1130</li>
1131</ol>
1132</div>
Junio C Hamanofb56a962006-01-28 10:38:191133<h2>combined diff format</h2>
1134<div class="sectionbody">
1135<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
1136to produce <em>combined diff</em>, which looks like this:</p>
1137<div class="listingblock">
1138<div class="content">
1139<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291140index fabadb8,cc95eb0..4866510
1141--- a/describe.c
1142+++ b/describe.c
1143@@@ -98,20 -98,12 +98,20 @@@
1144 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191145 }
1146
1147- static void describe(char *arg)
1148 -static void describe(struct commit *cmit, int last_one)
1149++static void describe(char *arg, int last_one)
1150 {
Junio C Hamano29f14312006-10-26 08:47:291151 + unsigned char sha1[20];
1152 + struct commit *cmit;
1153 struct commit_list *list;
1154 static int initialized = 0;
1155 struct commit_name *n;
1156
1157 + if (get_sha1(arg, sha1) &lt; 0)
1158 + usage(describe_usage);
1159 + cmit = lookup_commit_reference(sha1);
1160 + if (!cmit)
1161 + usage(describe_usage);
1162 +
1163 if (!initialized) {
1164 initialized = 1;
1165 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191166</div></div>
Junio C Hamano29f14312006-10-26 08:47:291167<ol>
1168<li>
1169<p>
1170It is preceded with a "git diff" header, that looks like
1171 this (when <em>-c</em> option is used):
1172</p>
1173<div class="literalblock">
1174<div class="content">
1175<pre><tt>diff --combined file</tt></pre>
1176</div></div>
1177<p>or like this (when <em>--cc</em> option is used):</p>
1178<div class="literalblock">
1179<div class="content">
1180<pre><tt>diff --c file</tt></pre>
1181</div></div>
1182</li>
1183<li>
1184<p>
1185It is followed by one or more extended header lines
1186 (this example shows a merge with two parents):
1187</p>
1188<div class="literalblock">
1189<div class="content">
1190<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1191mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1192new file mode &lt;mode&gt;
1193deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1194</div></div>
1195<p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
1196the &lt;mode&gt; is diferent from the rest. Extended headers with
1197information about detected contents movement (renames and
1198copying detection) are designed to work with diff of two
1199&lt;tree-ish&gt; and are not used by combined diff format.</p>
1200</li>
1201<li>
1202<p>
1203It is followed by two-line from-file/to-file header
1204</p>
1205<div class="literalblock">
1206<div class="content">
1207<pre><tt>--- a/file
1208+++ b/file</tt></pre>
1209</div></div>
1210<p>Similar to two-line header for traditional <em>unified</em> diff
1211format, <tt>/dev/null</tt> is used to signal created or deleted
1212files.</p>
1213</li>
1214<li>
1215<p>
1216Chunk header format is modified to prevent people from
1217 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1218 was created for review of merge commit changes, and was not
1219 meant for apply. The change is similar to the change in the
1220 extended <em>index</em> header:
1221</p>
1222<div class="literalblock">
1223<div class="content">
1224<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1225</div></div>
1226<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1227header for combined diff format.</p>
1228</li>
1229</ol>
Junio C Hamanofb56a962006-01-28 10:38:191230<p>Unlike the traditional <em>unified</em> diff format, which shows two
1231files A and B with a single column that has <tt>-</tt> (minus &#8212;
1232appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291233added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191234compares two or more files file1, file2,&#8230; with one file X, and
1235shows how X differs from each of fileN. One column for each of
1236fileN is prepended to the output line to note how X's line is
1237different from it.</p>
1238<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291239fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191240in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291241and fileN does not have that line (in other words, the line was
1242added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191243<p>In the above example output, the function signature was changed
1244from both files (hence two <tt>-</tt> removals from both file1 and
1245file2, plus <tt>++</tt> to mean one line that was added does not appear
1246in either file1 nor file2). Also two other lines are the same
1247from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1248<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1249merge commit with the merge result (i.e. file1..fileN are the
1250parents). When shown by <tt>git diff-files -c</tt>, it compares the
1251two unresolved merge parents with the working tree file
1252(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1253"their version").</p>
1254</div>
Junio C Hamano1a4e8412005-12-27 08:17:231255<h2>Author</h2>
1256<div class="sectionbody">
1257<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1258</div>
1259<h2>Documentation</h2>
1260<div class="sectionbody">
1261<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1262</div>
1263<h2>GIT</h2>
1264<div class="sectionbody">
1265<p>Part of the <a href="git.html">git(7)</a> suite</p>
1266</div>
1267<div id="footer">
1268<div id="footer-text">
Junio C Hamano7d23f5e2006-12-16 07:44:041269Last updated 16-Dec-2006 07:43:50 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231270</div>
1271</div>
1272</body>
1273</html>