blob: 575c0b424a0c7ba02b8d146bd36a513cc510a963 [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>
Junio C Hamanoa3fd83c2007-03-02 10:34:36864<li>
865<p>
866<em>format:</em>
867</p>
868<p>The <em>format:</em> format allows you to specify which information
869you want to show. It works a little bit like printf format,
870with the notable exception that you get a newline with <em>%n</em>
871instead of <em>\n</em>.</p>
872</li>
Junio C Hamanoa340aaa2006-11-23 02:47:33873</ul>
Junio C Hamano1a4e8412005-12-27 08:17:23874</dd>
Junio C Hamanoa3fd83c2007-03-02 10:34:36875</dl>
876<p>E.g, <em>format:"The author of %h was %an, %ar%nThe title was &gt;&gt;%s&lt;&lt;"</em>
877would show something like this:</p>
878<p>The author of fe6e0ee was Junio C Hamano, 23 hours ago
879The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;</p>
880<p>The placeholders are:</p>
881<ul>
882<li>
883<p>
884<em>%H</em>: commit hash
885</p>
886</li>
887<li>
888<p>
889<em>%h</em>: abbreviated commit hash
890</p>
891</li>
892<li>
893<p>
894<em>%T</em>: tree hash
895</p>
896</li>
897<li>
898<p>
899<em>%t</em>: abbreviated tree hash
900</p>
901</li>
902<li>
903<p>
904<em>%P</em>: parent hashes
905</p>
906</li>
907<li>
908<p>
909<em>%p</em>: abbreviated parent hashes
910</p>
911</li>
912<li>
913<p>
914<em>%an</em>: author name
915</p>
916</li>
917<li>
918<p>
919<em>%ae</em>: author email
920</p>
921</li>
922<li>
923<p>
924<em>%ad</em>: author date
925</p>
926</li>
927<li>
928<p>
929<em>%aD</em>: author date, RFC2822 style
930</p>
931</li>
932<li>
933<p>
934<em>%ar</em>: author date, relative
935</p>
936</li>
937<li>
938<p>
939<em>%at</em>: author date, UNIX timestamp
940</p>
941</li>
942<li>
943<p>
944<em>%cn</em>: committer name
945</p>
946</li>
947<li>
948<p>
949<em>%ce</em>: committer email
950</p>
951</li>
952<li>
953<p>
954<em>%cd</em>: committer date
955</p>
956</li>
957<li>
958<p>
959<em>%cD</em>: committer date, RFC2822 style
960</p>
961</li>
962<li>
963<p>
964<em>%cr</em>: committer date, relative
965</p>
966</li>
967<li>
968<p>
969<em>%ct</em>: committer date, UNIX timestamp
970</p>
971</li>
972<li>
973<p>
974<em>%e</em>: encoding
975</p>
976</li>
977<li>
978<p>
979<em>%s</em>: subject
980</p>
981</li>
982<li>
983<p>
984<em>%b</em>: body
985</p>
986</li>
987<li>
988<p>
989<em>%Cred</em>: switch color to red
990</p>
991</li>
992<li>
993<p>
994<em>%Cgreen</em>: switch color to green
995</p>
996</li>
997<li>
998<p>
999<em>%Cblue</em>: switch color to blue
1000</p>
1001</li>
1002<li>
1003<p>
1004<em>%Creset</em>: reset color
1005</p>
1006</li>
1007<li>
1008<p>
1009<em>%n</em>: newline
1010</p>
1011<dl>
Junio C Hamano1a4e8412005-12-27 08:17:231012<dt>
Junio C Hamano775a0f42006-12-31 01:19:141013--encoding[=&lt;encoding&gt;]
1014</dt>
1015<dd>
1016<p>
1017 The commit objects record the encoding used for the log message
1018 in their encoding header; this option can be used to tell the
1019 command to re-code the commit log message in the encoding
1020 preferred by the user. For non plumbing commands this
1021 defaults to UTF-8.
1022</p>
1023</dd>
1024<dt>
Junio C Hamano1a4e8412005-12-27 08:17:231025--no-commit-id
1026</dt>
1027<dd>
1028<p>
1029 git-diff-tree outputs a line with the commit ID when
1030 applicable. This flag suppressed the commit ID output.
1031</p>
1032</dd>
Junio C Hamanofb56a962006-01-28 10:38:191033<dt>
Junio C Hamanoa8adb1e2006-04-10 23:46:161034-c
Junio C Hamanofb56a962006-01-28 10:38:191035</dt>
1036<dd>
1037<p>
Junio C Hamanoa8adb1e2006-04-10 23:46:161038 This flag changes the way a merge commit is displayed
Junio C Hamanofb56a962006-01-28 10:38:191039 (which means it is useful only when the command is given
1040 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
Junio C Hamanoa8adb1e2006-04-10 23:46:161041 from each of the parents to the merge result simultaneously
1042 instead of showing pairwise diff between a parent and the
1043 result one at a time (which is what the <em>-m</em> option does).
1044 Furthermore, it lists only files which were modified
1045 from all parents.
1046</p>
1047</dd>
1048<dt>
Junio C Hamano46338f52006-05-04 00:46:441049--cc
Junio C Hamanoa8adb1e2006-04-10 23:46:161050</dt>
1051<dd>
1052<p>
1053 This flag changes the way a merge commit patch is displayed,
1054 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
1055 and <em>-p</em> options and further compresses the patch output
1056 by omitting hunks that show differences from only one
Junio C Hamanofb56a962006-01-28 10:38:191057 parent, or show the same change from all but one parent
1058 for an Octopus merge. When this optimization makes all
1059 hunks disappear, the commit itself and the commit log
Junio C Hamanoa8adb1e2006-04-10 23:46:161060 message is not shown, just like in any other "empty diff" case.
Junio C Hamanofb56a962006-01-28 10:38:191061</p>
1062</dd>
Junio C Hamanod9d71c02006-02-08 00:52:331063<dt>
1064--always
1065</dt>
1066<dd>
1067<p>
1068 Show the commit itself and the commit log message even
1069 if the diff itself is empty.
1070</p>
1071</dd>
Junio C Hamano1a4e8412005-12-27 08:17:231072</dl>
Junio C Hamanoa3fd83c2007-03-02 10:34:361073</li>
1074</ul>
Junio C Hamano1a4e8412005-12-27 08:17:231075</div>
1076<h2>Limiting Output</h2>
1077<div class="sectionbody">
1078<p>If you're only interested in differences in a subset of files, for
1079example some architecture-specific files, you might do:</p>
1080<div class="literalblock">
1081<div class="content">
1082<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
1083</div></div>
1084<p>and it will only show you what changed in those two directories.</p>
1085<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
1086<div class="literalblock">
1087<div class="content">
1088<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
1089</div></div>
1090<p>and it will ignore all differences to other files.</p>
1091<p>The pattern is always the prefix, and is matched exactly. There are no
1092wildcards. Even stricter, it has to match a complete path component.
1093I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
1094so it can be used to name subdirectories.</p>
1095<p>An example of normal usage is:</p>
1096<div class="literalblock">
1097<div class="content">
1098<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
1099*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
1100</div></div>
1101<p>which tells you that the last commit changed just one file (it's from
1102this one:</p>
1103<div class="listingblock">
1104<div class="content">
1105<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1106tree 5319e4d609cdd282069cc4dce33c1db559539b03
1107parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1108author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1109committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1110
1111Make "git-fsck-objects" print out all the root commits it finds.
1112
1113Once I do the reference tracking, I'll also make it print out all the
1114HEAD commits it finds, which is even more interesting.</tt></pre>
1115</div></div>
1116<p>in case you care).</p>
1117</div>
1118<h2>Output format</h2>
1119<div class="sectionbody">
1120<p>The output format from "git-diff-index", "git-diff-tree" and
1121"git-diff-files" are very similar.</p>
1122<p>These commands all compare two sets of things; what is
1123compared differs:</p>
1124<dl>
1125<dt>
1126git-diff-index &lt;tree-ish&gt;
1127</dt>
1128<dd>
1129<p>
1130 compares the &lt;tree-ish&gt; and the files on the filesystem.
1131</p>
1132</dd>
1133<dt>
1134git-diff-index --cached &lt;tree-ish&gt;
1135</dt>
1136<dd>
1137<p>
1138 compares the &lt;tree-ish&gt; and the index.
1139</p>
1140</dd>
1141<dt>
1142git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1143</dt>
1144<dd>
1145<p>
1146 compares the trees named by the two arguments.
1147</p>
1148</dd>
1149<dt>
1150git-diff-files [&lt;pattern&gt;&#8230;]
1151</dt>
1152<dd>
1153<p>
1154 compares the index and the files on the filesystem.
1155</p>
1156</dd>
1157</dl>
1158<p>An output line is formatted this way:</p>
1159<div class="listingblock">
1160<div class="content">
1161<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1162copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1163rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1164create :000000 100644 0000000... 1234567... A file4
1165delete :100644 000000 1234567... 0000000... D file5
1166unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1167</div></div>
1168<p>That is, from the left to the right:</p>
1169<ol>
1170<li>
1171<p>
1172a colon.
1173</p>
1174</li>
1175<li>
1176<p>
1177mode for "src"; 000000 if creation or unmerged.
1178</p>
1179</li>
1180<li>
1181<p>
1182a space.
1183</p>
1184</li>
1185<li>
1186<p>
1187mode for "dst"; 000000 if deletion or unmerged.
1188</p>
1189</li>
1190<li>
1191<p>
1192a space.
1193</p>
1194</li>
1195<li>
1196<p>
1197sha1 for "src"; 0{40} if creation or unmerged.
1198</p>
1199</li>
1200<li>
1201<p>
1202a space.
1203</p>
1204</li>
1205<li>
1206<p>
1207sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1208</p>
1209</li>
1210<li>
1211<p>
1212a space.
1213</p>
1214</li>
1215<li>
1216<p>
1217status, followed by optional "score" number.
1218</p>
1219</li>
1220<li>
1221<p>
1222a tab or a NUL when <em>-z</em> option is used.
1223</p>
1224</li>
1225<li>
1226<p>
1227path for "src"
1228</p>
1229</li>
1230<li>
1231<p>
1232a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1233</p>
1234</li>
1235<li>
1236<p>
1237path for "dst"; only exists for C or R.
1238</p>
1239</li>
1240<li>
1241<p>
1242an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1243</p>
1244</li>
1245</ol>
1246<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1247and it is out of sync with the index.</p>
1248<p>Example:</p>
1249<div class="listingblock">
1250<div class="content">
1251<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1252</div></div>
1253<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1254in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1255respectively.</p>
1256</div>
1257<h2>Generating patches with -p</h2>
1258<div class="sectionbody">
1259<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1260with a <em>-p</em> option, they do not produce the output described above;
Junio C Hamano1c437122006-11-28 02:22:251261instead they produce a patch file. You can customize the creation
1262of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
1263environment variables.</p>
1264<p>What the -p option produces is slightly different from the traditional
1265diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231266<ol>
1267<li>
1268<p>
Junio C Hamano235a91e2006-01-07 01:13:581269It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231270 this:
1271</p>
1272<div class="literalblock">
1273<div class="content">
1274<pre><tt>diff --git a/file1 b/file2</tt></pre>
1275</div></div>
1276<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1277involved. Especially, even for a creation or a deletion,
1278<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
1279<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1280name of the source file of the rename/copy and the name of
1281the file that rename/copy produces, respectively.</p>
1282</li>
1283<li>
1284<p>
1285It is followed by one or more extended header lines:
1286</p>
1287<div class="literalblock">
1288<div class="content">
1289<pre><tt>old mode &lt;mode&gt;
1290new mode &lt;mode&gt;
1291deleted file mode &lt;mode&gt;
1292new file mode &lt;mode&gt;
1293copy from &lt;path&gt;
1294copy to &lt;path&gt;
1295rename from &lt;path&gt;
1296rename to &lt;path&gt;
1297similarity index &lt;number&gt;
1298dissimilarity index &lt;number&gt;
1299index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1300</div></div>
1301</li>
1302<li>
1303<p>
Junio C Hamanoa053d542006-10-27 09:29:131304TAB, LF, double quote and backslash characters in pathnames
1305 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1306 If there is need for such substitution then the whole
1307 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231308</p>
1309</li>
1310</ol>
1311</div>
Junio C Hamanofb56a962006-01-28 10:38:191312<h2>combined diff format</h2>
1313<div class="sectionbody">
1314<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
1315to produce <em>combined diff</em>, which looks like this:</p>
1316<div class="listingblock">
1317<div class="content">
1318<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291319index fabadb8,cc95eb0..4866510
1320--- a/describe.c
1321+++ b/describe.c
1322@@@ -98,20 -98,12 +98,20 @@@
1323 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191324 }
1325
1326- static void describe(char *arg)
1327 -static void describe(struct commit *cmit, int last_one)
1328++static void describe(char *arg, int last_one)
1329 {
Junio C Hamano29f14312006-10-26 08:47:291330 + unsigned char sha1[20];
1331 + struct commit *cmit;
1332 struct commit_list *list;
1333 static int initialized = 0;
1334 struct commit_name *n;
1335
1336 + if (get_sha1(arg, sha1) &lt; 0)
1337 + usage(describe_usage);
1338 + cmit = lookup_commit_reference(sha1);
1339 + if (!cmit)
1340 + usage(describe_usage);
1341 +
1342 if (!initialized) {
1343 initialized = 1;
1344 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191345</div></div>
Junio C Hamano29f14312006-10-26 08:47:291346<ol>
1347<li>
1348<p>
1349It is preceded with a "git diff" header, that looks like
1350 this (when <em>-c</em> option is used):
1351</p>
1352<div class="literalblock">
1353<div class="content">
1354<pre><tt>diff --combined file</tt></pre>
1355</div></div>
1356<p>or like this (when <em>--cc</em> option is used):</p>
1357<div class="literalblock">
1358<div class="content">
1359<pre><tt>diff --c file</tt></pre>
1360</div></div>
1361</li>
1362<li>
1363<p>
1364It is followed by one or more extended header lines
1365 (this example shows a merge with two parents):
1366</p>
1367<div class="literalblock">
1368<div class="content">
1369<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1370mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1371new file mode &lt;mode&gt;
1372deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1373</div></div>
1374<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:041375the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291376information about detected contents movement (renames and
1377copying detection) are designed to work with diff of two
1378&lt;tree-ish&gt; and are not used by combined diff format.</p>
1379</li>
1380<li>
1381<p>
1382It is followed by two-line from-file/to-file header
1383</p>
1384<div class="literalblock">
1385<div class="content">
1386<pre><tt>--- a/file
1387+++ b/file</tt></pre>
1388</div></div>
1389<p>Similar to two-line header for traditional <em>unified</em> diff
1390format, <tt>/dev/null</tt> is used to signal created or deleted
1391files.</p>
1392</li>
1393<li>
1394<p>
1395Chunk header format is modified to prevent people from
1396 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1397 was created for review of merge commit changes, and was not
1398 meant for apply. The change is similar to the change in the
1399 extended <em>index</em> header:
1400</p>
1401<div class="literalblock">
1402<div class="content">
1403<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1404</div></div>
1405<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1406header for combined diff format.</p>
1407</li>
1408</ol>
Junio C Hamanofb56a962006-01-28 10:38:191409<p>Unlike the traditional <em>unified</em> diff format, which shows two
1410files A and B with a single column that has <tt>-</tt> (minus &#8212;
1411appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291412added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191413compares two or more files file1, file2,&#8230; with one file X, and
1414shows how X differs from each of fileN. One column for each of
1415fileN is prepended to the output line to note how X's line is
1416different from it.</p>
1417<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291418fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191419in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291420and fileN does not have that line (in other words, the line was
1421added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191422<p>In the above example output, the function signature was changed
1423from both files (hence two <tt>-</tt> removals from both file1 and
1424file2, plus <tt>++</tt> to mean one line that was added does not appear
1425in either file1 nor file2). Also two other lines are the same
1426from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1427<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1428merge commit with the merge result (i.e. file1..fileN are the
1429parents). When shown by <tt>git diff-files -c</tt>, it compares the
1430two unresolved merge parents with the working tree file
1431(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1432"their version").</p>
1433</div>
Junio C Hamano1a4e8412005-12-27 08:17:231434<h2>Author</h2>
1435<div class="sectionbody">
1436<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1437</div>
1438<h2>Documentation</h2>
1439<div class="sectionbody">
1440<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1441</div>
1442<h2>GIT</h2>
1443<div class="sectionbody">
1444<p>Part of the <a href="git.html">git(7)</a> suite</p>
1445</div>
1446<div id="footer">
1447<div id="footer-text">
Junio C Hamanoa3fd83c2007-03-02 10:34:361448Last updated 02-Mar-2007 10:34:19 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231449</div>
1450</div>
1451</body>
1452</html>