blob: b9d1dcff0c49d5c676ec6f00422676a29c266663 [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>
Junio C Hamanoff979792007-11-16 10:11:30295 Generate patch (see section on generating patches).
296
Junio C Hamano1a4e8412005-12-27 08:17:23297</p>
298</dd>
299<dt>
300-u
301</dt>
302<dd>
303<p>
304 Synonym for "-p".
305</p>
306</dd>
307<dt>
Junio C Hamano69361562007-07-26 02:14:34308-U&lt;n&gt;
309</dt>
310<dd>
311<p>
312 Shorthand for "--unified=&lt;n&gt;".
313</p>
314</dd>
315<dt>
316--unified=&lt;n&gt;
317</dt>
318<dd>
319<p>
320 Generate diffs with &lt;n&gt; lines of context instead of
321 the usual three. Implies "-p".
322</p>
323</dd>
324<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34325--raw
326</dt>
327<dd>
328<p>
329 Generate the raw format.
Junio C Hamanoff979792007-11-16 10:11:30330 This is the default.
Junio C Hamano9ae1a062006-07-10 08:12:34331</p>
332</dd>
333<dt>
Junio C Hamano54559c82006-04-13 07:45:12334--patch-with-raw
335</dt>
336<dd>
337<p>
Junio C Hamano9ae1a062006-07-10 08:12:34338 Synonym for "-p --raw".
Junio C Hamano54559c82006-04-13 07:45:12339</p>
340</dd>
341<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29342--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42343</dt>
344<dd>
345<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29346 Generate a diffstat. You can override the default
347 output width for 80-column terminal by "--stat=width".
348 The width of the filename part can be controlled by
349 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42350</p>
351</dd>
352<dt>
Junio C Hamanofbe00522006-10-19 05:58:48353--numstat
354</dt>
355<dd>
356<p>
357 Similar to --stat, but shows number of added and
358 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43359 abbreviation, to make it more machine friendly. For
360 binary files, outputs two <tt>-</tt> instead of saying
361 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48362</p>
363</dd>
364<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04365--shortstat
366</dt>
367<dd>
368<p>
369 Output only the last line of the --stat format containing total
370 number of modified files, as well as number of added and deleted
371 lines.
372</p>
373</dd>
374<dt>
Junio C Hamano6a45be92008-04-22 08:19:03375--dirstat[=limit]
376</dt>
377<dd>
378<p>
379 Output only the sub-directories that are impacted by a diff,
380 and to what degree they are impacted. You can override the
381 default cut-off in percent (3) by "--dirstat=limit". If you
382 want to enable "cumulative" directory statistics, you can use
383 the "--cumulative" flag, which adds up percentages recursively
384 even when they have been already reported for a sub-directory.
385</p>
386</dd>
387<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11388--summary
389</dt>
390<dd>
391<p>
392 Output a condensed summary of extended header information
393 such as creations, renames and mode changes.
394</p>
395</dd>
396<dt>
Junio C Hamanod1308c92006-04-16 11:01:09397--patch-with-stat
398</dt>
399<dd>
400<p>
Junio C Hamano9ae1a062006-07-10 08:12:34401 Synonym for "-p --stat".
Junio C Hamanoff979792007-11-16 10:11:30402
Junio C Hamanod1308c92006-04-16 11:01:09403</p>
404</dd>
405<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23406-z
407</dt>
408<dd>
409<p>
Junio C Hamanob968dbb2007-07-27 07:26:40410 NUL-line termination on output. This affects the --raw
411 output field terminator. Also output from commands such
412 as "git-log" will be delimited with NUL between commits.
Junio C Hamano1a4e8412005-12-27 08:17:23413</p>
414</dd>
415<dt>
416--name-only
417</dt>
418<dd>
419<p>
420 Show only names of changed files.
421</p>
422</dd>
423<dt>
424--name-status
425</dt>
426<dd>
427<p>
Junio C Hamanoa9aee782008-04-23 16:09:20428 Show only names and status of changed files. See the description
429 of the <tt>--diff-filter</tt> option on what the status letters mean.
Junio C Hamano1a4e8412005-12-27 08:17:23430</p>
431</dd>
432<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34433--color
434</dt>
435<dd>
436<p>
437 Show colored diff.
438</p>
439</dd>
440<dt>
441--no-color
442</dt>
443<dd>
444<p>
445 Turn off colored diff, even when the configuration file
446 gives the default to color output.
447</p>
448</dd>
449<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41450--color-words
451</dt>
452<dd>
453<p>
454 Show colored word diff, i.e. color words which have changed.
455</p>
456</dd>
457<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34458--no-renames
459</dt>
460<dd>
461<p>
462 Turn off rename detection, even when the configuration
463 file gives the default to do so.
464</p>
465</dd>
466<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21467--check
468</dt>
469<dd>
470<p>
471 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54472 or an indent that uses a space before a tab. Exits with
473 non-zero status if problems are found. Not compatible with
474 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21475</p>
476</dd>
477<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23478--full-index
479</dt>
480<dd>
481<p>
482 Instead of the first handful characters, show full
483 object name of pre- and post-image blob on the "index"
484 line when generating a patch format output.
485</p>
486</dd>
487<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34488--binary
489</dt>
490<dd>
491<p>
492 In addition to --full-index, output "binary diff" that
493 can be applied with "git apply".
494</p>
495</dd>
496<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23497--abbrev[=&lt;n&gt;]
498</dt>
499<dd>
500<p>
501 Instead of showing the full 40-byte hexadecimal object
502 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58503 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23504 independent of --full-index option above, which controls
505 the diff-patch output format. Non default number of
506 digits can be specified with --abbrev=&lt;n&gt;.
507</p>
508</dd>
509<dt>
510-B
511</dt>
512<dd>
513<p>
514 Break complete rewrite changes into pairs of delete and create.
515</p>
516</dd>
517<dt>
518-M
519</dt>
520<dd>
521<p>
522 Detect renames.
523</p>
524</dd>
525<dt>
526-C
527</dt>
528<dd>
529<p>
Junio C Hamano16f98872007-06-12 16:09:14530 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23531</p>
532</dd>
533<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01534--diff-filter=[ACDMRTUXB*]
535</dt>
536<dd>
537<p>
538 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
539 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
540 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
541 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
542 Any combination of the filter characters may be used.
543 When <tt>*</tt> (All-or-none) is added to the combination, all
544 paths are selected if there is any file that matches
545 other criteria in the comparison; if there is no file
546 that matches other criteria, nothing is selected.
547</p>
548</dd>
549<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23550--find-copies-harder
551</dt>
552<dd>
553<p>
Junio C Hamano16f98872007-06-12 16:09:14554 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano1a4e8412005-12-27 08:17:23555 if the original file of the copy was modified in the same
556 changeset. This flag makes the command
557 inspect unmodified files as candidates for the source of
558 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14559 projects, so use it with caution. Giving more than one
560 <tt>-C</tt> option has the same effect.
Junio C Hamano1a4e8412005-12-27 08:17:23561</p>
562</dd>
563<dt>
564-l&lt;num&gt;
565</dt>
566<dd>
567<p>
568 -M and -C options require O(n^2) processing time where n
569 is the number of potential rename/copy targets. This
570 option prevents rename/copy detection from running if
571 the number of rename/copy targets exceeds the specified
572 number.
573</p>
574</dd>
575<dt>
576-S&lt;string&gt;
577</dt>
578<dd>
579<p>
580 Look for differences that contain the change in &lt;string&gt;.
581</p>
582</dd>
583<dt>
584--pickaxe-all
585</dt>
586<dd>
587<p>
588 When -S finds a change, show all the changes in that
589 changeset, not just the files that contain the change
590 in &lt;string&gt;.
591</p>
592</dd>
593<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28594--pickaxe-regex
595</dt>
596<dd>
597<p>
598 Make the &lt;string&gt; not a plain string but an extended POSIX
599 regex to match.
600</p>
601</dd>
602<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23603-O&lt;orderfile&gt;
604</dt>
605<dd>
606<p>
607 Output the patch in the order specified in the
608 &lt;orderfile&gt;, which has one shell glob pattern per line.
609</p>
610</dd>
611<dt>
612-R
613</dt>
614<dd>
615<p>
616 Swap two inputs; that is, show differences from index or
617 on-disk file to tree contents.
618</p>
619</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14620<dt>
Junio C Hamano24bc09a2008-02-28 00:27:44621--relative[=&lt;path&gt;]
622</dt>
623<dd>
624<p>
625 When run from a subdirectory of the project, it can be
626 told to exclude changes outside the directory and show
627 pathnames relative to it with this option. When you are
628 not in a subdirectory (e.g. in a bare repository), you
629 can name which subdirectory to make the output relative
630 to by giving a &lt;path&gt; as an argument.
631</p>
632</dd>
633<dt>
Junio C Hamanoc26f5482006-07-09 09:38:14634--text
635</dt>
636<dd>
637<p>
638 Treat all files as text.
639</p>
640</dd>
641<dt>
642-a
643</dt>
644<dd>
645<p>
646 Shorthand for "--text".
647</p>
648</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07649<dt>
Junio C Hamanofd468962007-02-14 23:45:04650--ignore-space-at-eol
651</dt>
652<dd>
653<p>
Junio C Hamano3a702342007-12-12 21:34:02654 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04655</p>
656</dd>
657<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07658--ignore-space-change
659</dt>
660<dd>
661<p>
Junio C Hamano3a702342007-12-12 21:34:02662 Ignore changes in amount of whitespace. This ignores whitespace
663 at line end, and considers all other sequences of one or
664 more whitespace characters to be equivalent.
Junio C Hamanod9c2d2f2006-12-06 08:59:07665</p>
666</dd>
667<dt>
668-b
669</dt>
670<dd>
671<p>
672 Shorthand for "--ignore-space-change".
673</p>
674</dd>
675<dt>
676--ignore-all-space
677</dt>
678<dd>
679<p>
Junio C Hamano3a702342007-12-12 21:34:02680 Ignore whitespace when comparing lines. This ignores
681 differences even if one line has whitespace where the other
Junio C Hamanod9c2d2f2006-12-06 08:59:07682 line has none.
683</p>
684</dd>
685<dt>
686-w
687</dt>
688<dd>
689<p>
690 Shorthand for "--ignore-all-space".
691</p>
692</dd>
Junio C Hamano48fd2f62007-03-19 02:02:30693<dt>
694--exit-code
695</dt>
696<dd>
697<p>
698 Make the program exit with codes similar to diff(1).
699 That is, it exits with 1 if there were differences and
700 0 means no differences.
701</p>
702</dd>
Junio C Hamano35e57552007-03-25 07:54:35703<dt>
704--quiet
705</dt>
706<dd>
707<p>
708 Disable all output of the program. Implies --exit-code.
709</p>
710</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40711<dt>
712--ext-diff
713</dt>
714<dd>
715<p>
716 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53717 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
718 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40719</p>
720</dd>
721<dt>
722--no-ext-diff
723</dt>
724<dd>
725<p>
726 Disallow external diff drivers.
727</p>
728</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33729<dt>
730--src-prefix=&lt;prefix&gt;
731</dt>
732<dd>
733<p>
734 Show the given source prefix instead of "a/".
735</p>
736</dd>
737<dt>
738--dst-prefix=&lt;prefix&gt;
739</dt>
740<dd>
741<p>
742 Show the given destination prefix instead of "b/".
743</p>
744</dd>
745<dt>
746--no-prefix
747</dt>
748<dd>
749<p>
750 Do not show any source or destination prefix.
751</p>
752</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23753</dl>
754<p>For more detailed explanation on these common options, see also
755<a href="diffcore.html">diffcore documentation</a>.</p>
756<dl>
757<dt>
758&lt;tree-ish&gt;
759</dt>
760<dd>
761<p>
762 The id of a tree object.
763</p>
764</dd>
765<dt>
766&lt;path&gt;&#8230;
767</dt>
768<dd>
769<p>
770 If provided, the results are limited to a subset of files
771 matching one of these prefix strings.
Junio C Hamano341071d2006-06-04 07:24:48772 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
Junio C Hamano1a4e8412005-12-27 08:17:23773 Note that this parameter does not provide any wildcard or regexp
774 features.
775</p>
776</dd>
777<dt>
778-r
779</dt>
780<dd>
781<p>
782 recurse into sub-trees
783</p>
784</dd>
785<dt>
786-t
787</dt>
788<dd>
789<p>
790 show tree entry itself as well as subtrees. Implies -r.
791</p>
792</dd>
793<dt>
794--root
795</dt>
796<dd>
797<p>
798 When <em>--root</em> is specified the initial commit will be showed as a big
799 creation event. This is equivalent to a diff against the NULL tree.
800</p>
801</dd>
802<dt>
803--stdin
804</dt>
805<dd>
806<p>
807 When <em>--stdin</em> is specified, the command does not take
808 &lt;tree-ish&gt; arguments from the command line. Instead, it
809 reads either one &lt;commit&gt; or a pair of &lt;tree-ish&gt;
810 separated with a single space from its standard input.
811</p>
812<p>When a single commit is given on one line of such input, it compares
813the commit with its parents. The following flags further affects its
Junio C Hamano341071d2006-06-04 07:24:48814behavior. This does not apply to the case where two &lt;tree-ish&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23815separated with a single space are given.</p>
816</dd>
817<dt>
818-m
819</dt>
820<dd>
821<p>
822 By default, "git-diff-tree --stdin" does not show
823 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16824 differences to that commit from all of its parents. See
825 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23826</p>
827</dd>
828<dt>
829-s
830</dt>
831<dd>
832<p>
833 By default, "git-diff-tree --stdin" shows differences,
834 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58835 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23836 only useful with <em>-v</em> flag.
837</p>
838</dd>
839<dt>
840-v
841</dt>
842<dd>
843<p>
844 This flag causes "git-diff-tree --stdin" to also show
845 the commit message before the differences.
846</p>
847</dd>
848<dt>
Junio C Hamanoa340aaa2006-11-23 02:47:33849--pretty[=<em>&lt;format&gt;</em>]
Junio C Hamano1a4e8412005-12-27 08:17:23850</dt>
851<dd>
852<p>
Junio C Hamanoa3770f92007-07-25 08:53:33853 Pretty-print the contents of the commit logs in a given format,
Junio C Hamano0430e3a2007-05-15 03:13:17854 where <em>&lt;format&gt;</em> can be one of <em>oneline</em>, <em>short</em>, <em>medium</em>,
855 <em>full</em>, <em>fuller</em>, <em>email</em>, <em>raw</em> and <em>format:&lt;string&gt;</em>.
Junio C Hamanoa3770f92007-07-25 08:53:33856 When omitted, the format defaults to <em>medium</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23857</p>
Junio C Hamano86bcccc2008-03-08 09:33:55858<p>Note: you can specify the default pretty format in the repository
859configuration (see <a href="git-config.html">git-config(1)</a>).</p>
Junio C Hamano0430e3a2007-05-15 03:13:17860</dd>
861<dt>
Junio C Hamanoee695f22007-06-21 00:35:36862--abbrev-commit
863</dt>
864<dd>
865<p>
866 Instead of showing the full 40-byte hexadecimal commit object
867 name, show only handful hexdigits prefix. Non default number of
868 digits can be specified with "--abbrev=&lt;n&gt;" (which also modifies
869 diff output, if it is displayed).
870</p>
871<p>This should make "--pretty=oneline" a whole lot more readable for
872people using 80-column terminals.</p>
873</dd>
874<dt>
Junio C Hamano0430e3a2007-05-15 03:13:17875--encoding[=&lt;encoding&gt;]
876</dt>
877<dd>
878<p>
879 The commit objects record the encoding used for the log message
880 in their encoding header; this option can be used to tell the
881 command to re-code the commit log message in the encoding
882 preferred by the user. For non plumbing commands this
883 defaults to UTF-8.
884</p>
885</dd>
886<dt>
887--no-commit-id
888</dt>
889<dd>
890<p>
891 git-diff-tree outputs a line with the commit ID when
892 applicable. This flag suppressed the commit ID output.
893</p>
894</dd>
895<dt>
896-c
897</dt>
898<dd>
899<p>
900 This flag changes the way a merge commit is displayed
901 (which means it is useful only when the command is given
902 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
903 from each of the parents to the merge result simultaneously
904 instead of showing pairwise diff between a parent and the
905 result one at a time (which is what the <em>-m</em> option does).
906 Furthermore, it lists only files which were modified
907 from all parents.
908</p>
909</dd>
910<dt>
911--cc
912</dt>
913<dd>
914<p>
915 This flag changes the way a merge commit patch is displayed,
916 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
917 and <em>-p</em> options and further compresses the patch output
918 by omitting hunks that show differences from only one
919 parent, or show the same change from all but one parent
920 for an Octopus merge. When this optimization makes all
921 hunks disappear, the commit itself and the commit log
922 message is not shown, just like in any other "empty diff" case.
923</p>
924</dd>
925<dt>
926--always
927</dt>
928<dd>
929<p>
930 Show the commit itself and the commit log message even
931 if the diff itself is empty.
932</p>
933</dd>
934</dl>
935</div>
936<h2>PRETTY FORMATS</h2>
937<div class="sectionbody">
938<p>If the commit is a merge, and if the pretty-format
939is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
940inserted before the <em>Author:</em> line. This line begins with
941"Merge: " and the sha1s of ancestral commits are printed,
942separated by spaces. Note that the listed commits may not
943necessarily be the list of the <strong>direct</strong> parent commits if you
944have limited your view of history: for example, if you are
945only interested in changes related to a certain directory or
946file.</p>
947<p>Here are some additional details for each format:</p>
Junio C Hamanoa340aaa2006-11-23 02:47:33948<ul>
949<li>
950<p>
951<em>oneline</em>
952</p>
953<div class="literalblock">
954<div class="content">
955<pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
956</div></div>
957<p>This is designed to be as compact as possible.</p>
958</li>
959<li>
960<p>
961<em>short</em>
962</p>
963<div class="literalblock">
964<div class="content">
965<pre><tt>commit &lt;sha1&gt;
966Author: &lt;author&gt;</tt></pre>
967</div></div>
968<div class="literalblock">
969<div class="content">
970<pre><tt>&lt;title line&gt;</tt></pre>
971</div></div>
972</li>
973<li>
974<p>
975<em>medium</em>
976</p>
977<div class="literalblock">
978<div class="content">
979<pre><tt>commit &lt;sha1&gt;
980Author: &lt;author&gt;
981Date: &lt;date&gt;</tt></pre>
982</div></div>
983<div class="literalblock">
984<div class="content">
985<pre><tt>&lt;title line&gt;</tt></pre>
986</div></div>
987<div class="literalblock">
988<div class="content">
989<pre><tt>&lt;full commit message&gt;</tt></pre>
990</div></div>
991</li>
992<li>
993<p>
994<em>full</em>
995</p>
996<div class="literalblock">
997<div class="content">
998<pre><tt>commit &lt;sha1&gt;
999Author: &lt;author&gt;
1000Commit: &lt;committer&gt;</tt></pre>
1001</div></div>
1002<div class="literalblock">
1003<div class="content">
1004<pre><tt>&lt;title line&gt;</tt></pre>
1005</div></div>
1006<div class="literalblock">
1007<div class="content">
1008<pre><tt>&lt;full commit message&gt;</tt></pre>
1009</div></div>
1010</li>
1011<li>
1012<p>
1013<em>fuller</em>
1014</p>
1015<div class="literalblock">
1016<div class="content">
1017<pre><tt>commit &lt;sha1&gt;
1018Author: &lt;author&gt;
1019AuthorDate: &lt;date &amp; time&gt;
1020Commit: &lt;committer&gt;
1021CommitDate: &lt;date &amp; time&gt;</tt></pre>
1022</div></div>
1023<div class="literalblock">
1024<div class="content">
1025<pre><tt>&lt;title line&gt;</tt></pre>
1026</div></div>
1027<div class="literalblock">
1028<div class="content">
1029<pre><tt>&lt;full commit message&gt;</tt></pre>
1030</div></div>
1031</li>
1032<li>
1033<p>
1034<em>email</em>
1035</p>
1036<div class="literalblock">
1037<div class="content">
1038<pre><tt>From &lt;sha1&gt; &lt;date&gt;
1039From: &lt;author&gt;
1040Date: &lt;date &amp; time&gt;
1041Subject: [PATCH] &lt;title line&gt;</tt></pre>
1042</div></div>
1043<div class="literalblock">
1044<div class="content">
Junio C Hamano0430e3a2007-05-15 03:13:171045<pre><tt>&lt;full commit message&gt;</tt></pre>
Junio C Hamanoa340aaa2006-11-23 02:47:331046</div></div>
1047</li>
1048<li>
1049<p>
1050<em>raw</em>
1051</p>
1052<p>The <em>raw</em> format shows the entire commit exactly as
1053stored in the commit object. Notably, the SHA1s are
1054displayed in full, regardless of whether --abbrev or
1055--no-abbrev are used, and <em>parents</em> information show the
1056true parent commits, without taking grafts nor history
1057simplification into account.</p>
1058</li>
Junio C Hamanoa3fd83c2007-03-02 10:34:361059<li>
1060<p>
1061<em>format:</em>
1062</p>
1063<p>The <em>format:</em> format allows you to specify which information
1064you want to show. It works a little bit like printf format,
1065with the notable exception that you get a newline with <em>%n</em>
1066instead of <em>\n</em>.</p>
Junio C Hamano0430e3a2007-05-15 03:13:171067<p>E.g, <em>format:"The author of %h was %an, %ar%nThe title was &gt;&gt;%s&lt;&lt;%n"</em>
Junio C Hamanoa3fd83c2007-03-02 10:34:361068would show something like this:</p>
Junio C Hamano0430e3a2007-05-15 03:13:171069<div class="listingblock">
1070<div class="content">
1071<pre><tt>The author of fe6e0ee was Junio C Hamano, 23 hours ago
1072The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;
1073</tt></pre>
1074</div></div>
Junio C Hamanoa3fd83c2007-03-02 10:34:361075<p>The placeholders are:</p>
1076<ul>
1077<li>
1078<p>
1079<em>%H</em>: commit hash
1080</p>
1081</li>
1082<li>
1083<p>
1084<em>%h</em>: abbreviated commit hash
1085</p>
1086</li>
1087<li>
1088<p>
1089<em>%T</em>: tree hash
1090</p>
1091</li>
1092<li>
1093<p>
1094<em>%t</em>: abbreviated tree hash
1095</p>
1096</li>
1097<li>
1098<p>
1099<em>%P</em>: parent hashes
1100</p>
1101</li>
1102<li>
1103<p>
1104<em>%p</em>: abbreviated parent hashes
1105</p>
1106</li>
1107<li>
1108<p>
1109<em>%an</em>: author name
1110</p>
1111</li>
1112<li>
1113<p>
1114<em>%ae</em>: author email
1115</p>
1116</li>
1117<li>
1118<p>
1119<em>%ad</em>: author date
1120</p>
1121</li>
1122<li>
1123<p>
1124<em>%aD</em>: author date, RFC2822 style
1125</p>
1126</li>
1127<li>
1128<p>
1129<em>%ar</em>: author date, relative
1130</p>
1131</li>
1132<li>
1133<p>
1134<em>%at</em>: author date, UNIX timestamp
1135</p>
1136</li>
1137<li>
1138<p>
Junio C Hamano02f130b2007-07-14 08:26:561139<em>%ai</em>: author date, ISO 8601 format
1140</p>
1141</li>
1142<li>
1143<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361144<em>%cn</em>: committer name
1145</p>
1146</li>
1147<li>
1148<p>
1149<em>%ce</em>: committer email
1150</p>
1151</li>
1152<li>
1153<p>
1154<em>%cd</em>: committer date
1155</p>
1156</li>
1157<li>
1158<p>
1159<em>%cD</em>: committer date, RFC2822 style
1160</p>
1161</li>
1162<li>
1163<p>
1164<em>%cr</em>: committer date, relative
1165</p>
1166</li>
1167<li>
1168<p>
1169<em>%ct</em>: committer date, UNIX timestamp
1170</p>
1171</li>
1172<li>
1173<p>
Junio C Hamano02f130b2007-07-14 08:26:561174<em>%ci</em>: committer date, ISO 8601 format
1175</p>
1176</li>
1177<li>
1178<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361179<em>%e</em>: encoding
1180</p>
1181</li>
1182<li>
1183<p>
1184<em>%s</em>: subject
1185</p>
1186</li>
1187<li>
1188<p>
1189<em>%b</em>: body
1190</p>
1191</li>
1192<li>
1193<p>
1194<em>%Cred</em>: switch color to red
1195</p>
1196</li>
1197<li>
1198<p>
1199<em>%Cgreen</em>: switch color to green
1200</p>
1201</li>
1202<li>
1203<p>
1204<em>%Cblue</em>: switch color to blue
1205</p>
1206</li>
1207<li>
1208<p>
1209<em>%Creset</em>: reset color
1210</p>
1211</li>
1212<li>
1213<p>
Junio C Hamanod9e0e5d2007-04-14 16:22:041214<em>%m</em>: left, right or boundary mark
1215</p>
1216</li>
1217<li>
1218<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361219<em>%n</em>: newline
1220</p>
Junio C Hamano0430e3a2007-05-15 03:13:171221</li>
Junio C Hamanob78d2592008-04-09 09:39:081222<li>
1223<p>
1224<em>%x00</em>: print a byte from a hex code
1225</p>
1226</li>
Junio C Hamano0430e3a2007-05-15 03:13:171227</ul>
Junio C Hamanoa3fd83c2007-03-02 10:34:361228</li>
1229</ul>
Junio C Hamano1a4e8412005-12-27 08:17:231230</div>
1231<h2>Limiting Output</h2>
1232<div class="sectionbody">
1233<p>If you're only interested in differences in a subset of files, for
1234example some architecture-specific files, you might do:</p>
1235<div class="literalblock">
1236<div class="content">
1237<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
1238</div></div>
1239<p>and it will only show you what changed in those two directories.</p>
1240<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
1241<div class="literalblock">
1242<div class="content">
1243<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
1244</div></div>
1245<p>and it will ignore all differences to other files.</p>
1246<p>The pattern is always the prefix, and is matched exactly. There are no
1247wildcards. Even stricter, it has to match a complete path component.
1248I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
1249so it can be used to name subdirectories.</p>
1250<p>An example of normal usage is:</p>
1251<div class="literalblock">
1252<div class="content">
1253<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
1254*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
1255</div></div>
1256<p>which tells you that the last commit changed just one file (it's from
1257this one:</p>
1258<div class="listingblock">
1259<div class="content">
1260<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1261tree 5319e4d609cdd282069cc4dce33c1db559539b03
1262parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1263author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1264committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1265
1266Make "git-fsck-objects" print out all the root commits it finds.
1267
1268Once I do the reference tracking, I'll also make it print out all the
1269HEAD commits it finds, which is even more interesting.</tt></pre>
1270</div></div>
1271<p>in case you care).</p>
1272</div>
1273<h2>Output format</h2>
1274<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461275<p>The output format from "git-diff-index", "git-diff-tree",
1276"git-diff-files" and "git diff --raw" are very similar.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231277<p>These commands all compare two sets of things; what is
1278compared differs:</p>
1279<dl>
1280<dt>
1281git-diff-index &lt;tree-ish&gt;
1282</dt>
1283<dd>
1284<p>
1285 compares the &lt;tree-ish&gt; and the files on the filesystem.
1286</p>
1287</dd>
1288<dt>
1289git-diff-index --cached &lt;tree-ish&gt;
1290</dt>
1291<dd>
1292<p>
1293 compares the &lt;tree-ish&gt; and the index.
1294</p>
1295</dd>
1296<dt>
1297git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1298</dt>
1299<dd>
1300<p>
1301 compares the trees named by the two arguments.
1302</p>
1303</dd>
1304<dt>
1305git-diff-files [&lt;pattern&gt;&#8230;]
1306</dt>
1307<dd>
1308<p>
1309 compares the index and the files on the filesystem.
1310</p>
1311</dd>
1312</dl>
1313<p>An output line is formatted this way:</p>
1314<div class="listingblock">
1315<div class="content">
1316<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1317copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1318rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1319create :000000 100644 0000000... 1234567... A file4
1320delete :100644 000000 1234567... 0000000... D file5
1321unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1322</div></div>
1323<p>That is, from the left to the right:</p>
1324<ol>
1325<li>
1326<p>
1327a colon.
1328</p>
1329</li>
1330<li>
1331<p>
1332mode for "src"; 000000 if creation or unmerged.
1333</p>
1334</li>
1335<li>
1336<p>
1337a space.
1338</p>
1339</li>
1340<li>
1341<p>
1342mode for "dst"; 000000 if deletion or unmerged.
1343</p>
1344</li>
1345<li>
1346<p>
1347a space.
1348</p>
1349</li>
1350<li>
1351<p>
1352sha1 for "src"; 0{40} if creation or unmerged.
1353</p>
1354</li>
1355<li>
1356<p>
1357a space.
1358</p>
1359</li>
1360<li>
1361<p>
1362sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1363</p>
1364</li>
1365<li>
1366<p>
1367a space.
1368</p>
1369</li>
1370<li>
1371<p>
1372status, followed by optional "score" number.
1373</p>
1374</li>
1375<li>
1376<p>
1377a tab or a NUL when <em>-z</em> option is used.
1378</p>
1379</li>
1380<li>
1381<p>
1382path for "src"
1383</p>
1384</li>
1385<li>
1386<p>
1387a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1388</p>
1389</li>
1390<li>
1391<p>
1392path for "dst"; only exists for C or R.
1393</p>
1394</li>
1395<li>
1396<p>
1397an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1398</p>
1399</li>
1400</ol>
1401<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1402and it is out of sync with the index.</p>
1403<p>Example:</p>
1404<div class="listingblock">
1405<div class="content">
1406<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1407</div></div>
1408<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1409in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1410respectively.</p>
1411</div>
Junio C Hamano67fad6d2007-05-06 08:53:121412<h2>diff format for merges</h2>
1413<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461414<p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1415can take <em>-c</em> or <em>--cc</em> option
Junio C Hamano67fad6d2007-05-06 08:53:121416to generate diff output also for merge commits. The output differs
1417from the format described above in the following way:</p>
1418<ol>
1419<li>
1420<p>
1421there is a colon for each parent
1422</p>
1423</li>
1424<li>
1425<p>
1426there are more "src" modes and "src" sha1
1427</p>
1428</li>
1429<li>
1430<p>
1431status is concatenated status characters for each parent
1432</p>
1433</li>
1434<li>
1435<p>
1436no optional "score" number
1437</p>
1438</li>
1439<li>
1440<p>
1441single path, only for "dst"
1442</p>
1443</li>
1444</ol>
1445<p>Example:</p>
1446<div class="listingblock">
1447<div class="content">
1448<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1449</div></div>
1450<p>Note that <em>combined diff</em> lists only files which were modified from
1451all parents.</p>
1452</div>
Junio C Hamano1a4e8412005-12-27 08:17:231453<h2>Generating patches with -p</h2>
1454<div class="sectionbody">
1455<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:491456with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1457"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:461458do not produce the output described above; instead they produce a
1459patch file. You can customize the creation of such patches via the
1460GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p>
Junio C Hamano1c437122006-11-28 02:22:251461<p>What the -p option produces is slightly different from the traditional
1462diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231463<ol>
1464<li>
1465<p>
Junio C Hamano235a91e2006-01-07 01:13:581466It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231467 this:
1468</p>
1469<div class="literalblock">
1470<div class="content">
1471<pre><tt>diff --git a/file1 b/file2</tt></pre>
1472</div></div>
1473<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1474involved. Especially, even for a creation or a deletion,
1475<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
1476<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1477name of the source file of the rename/copy and the name of
1478the file that rename/copy produces, respectively.</p>
1479</li>
1480<li>
1481<p>
1482It is followed by one or more extended header lines:
1483</p>
1484<div class="literalblock">
1485<div class="content">
1486<pre><tt>old mode &lt;mode&gt;
1487new mode &lt;mode&gt;
1488deleted file mode &lt;mode&gt;
1489new file mode &lt;mode&gt;
1490copy from &lt;path&gt;
1491copy to &lt;path&gt;
1492rename from &lt;path&gt;
1493rename to &lt;path&gt;
1494similarity index &lt;number&gt;
1495dissimilarity index &lt;number&gt;
1496index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1497</div></div>
1498</li>
1499<li>
1500<p>
Junio C Hamanoa053d542006-10-27 09:29:131501TAB, LF, double quote and backslash characters in pathnames
1502 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1503 If there is need for such substitution then the whole
1504 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231505</p>
1506</li>
1507</ol>
Junio C Hamanod526ba92007-07-02 00:17:421508<p>The similarity index is the percentage of unchanged lines, and
1509the dissimilarity index is the percentage of changed lines. It
1510is a rounded down integer, followed by a percent sign. The
1511similarity index value of 100% is thus reserved for two equal
1512files, while 100% dissimilarity means that no line from the old
1513file made it into the new one.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231514</div>
Junio C Hamanofb56a962006-01-28 10:38:191515<h2>combined diff format</h2>
1516<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461517<p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
Junio C Hamano00b8b632007-12-07 09:50:491518<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1519with "git log -p", this is the default format.
1520A <em>combined diff</em> format looks like this:</p>
Junio C Hamanofb56a962006-01-28 10:38:191521<div class="listingblock">
1522<div class="content">
1523<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291524index fabadb8,cc95eb0..4866510
1525--- a/describe.c
1526+++ b/describe.c
1527@@@ -98,20 -98,12 +98,20 @@@
1528 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191529 }
1530
1531- static void describe(char *arg)
1532 -static void describe(struct commit *cmit, int last_one)
1533++static void describe(char *arg, int last_one)
1534 {
Junio C Hamano29f14312006-10-26 08:47:291535 + unsigned char sha1[20];
1536 + struct commit *cmit;
1537 struct commit_list *list;
1538 static int initialized = 0;
1539 struct commit_name *n;
1540
1541 + if (get_sha1(arg, sha1) &lt; 0)
1542 + usage(describe_usage);
1543 + cmit = lookup_commit_reference(sha1);
1544 + if (!cmit)
1545 + usage(describe_usage);
1546 +
1547 if (!initialized) {
1548 initialized = 1;
1549 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191550</div></div>
Junio C Hamano29f14312006-10-26 08:47:291551<ol>
1552<li>
1553<p>
1554It is preceded with a "git diff" header, that looks like
1555 this (when <em>-c</em> option is used):
1556</p>
1557<div class="literalblock">
1558<div class="content">
1559<pre><tt>diff --combined file</tt></pre>
1560</div></div>
1561<p>or like this (when <em>--cc</em> option is used):</p>
1562<div class="literalblock">
1563<div class="content">
1564<pre><tt>diff --c file</tt></pre>
1565</div></div>
1566</li>
1567<li>
1568<p>
1569It is followed by one or more extended header lines
1570 (this example shows a merge with two parents):
1571</p>
1572<div class="literalblock">
1573<div class="content">
1574<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1575mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1576new file mode &lt;mode&gt;
1577deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1578</div></div>
1579<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:041580the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291581information about detected contents movement (renames and
1582copying detection) are designed to work with diff of two
1583&lt;tree-ish&gt; and are not used by combined diff format.</p>
1584</li>
1585<li>
1586<p>
1587It is followed by two-line from-file/to-file header
1588</p>
1589<div class="literalblock">
1590<div class="content">
1591<pre><tt>--- a/file
1592+++ b/file</tt></pre>
1593</div></div>
1594<p>Similar to two-line header for traditional <em>unified</em> diff
1595format, <tt>/dev/null</tt> is used to signal created or deleted
1596files.</p>
1597</li>
1598<li>
1599<p>
1600Chunk header format is modified to prevent people from
1601 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1602 was created for review of merge commit changes, and was not
1603 meant for apply. The change is similar to the change in the
1604 extended <em>index</em> header:
1605</p>
1606<div class="literalblock">
1607<div class="content">
1608<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1609</div></div>
1610<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1611header for combined diff format.</p>
1612</li>
1613</ol>
Junio C Hamanofb56a962006-01-28 10:38:191614<p>Unlike the traditional <em>unified</em> diff format, which shows two
1615files A and B with a single column that has <tt>-</tt> (minus &#8212;
1616appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291617added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191618compares two or more files file1, file2,&#8230; with one file X, and
1619shows how X differs from each of fileN. One column for each of
1620fileN is prepended to the output line to note how X's line is
1621different from it.</p>
1622<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291623fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191624in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291625and fileN does not have that line (in other words, the line was
1626added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191627<p>In the above example output, the function signature was changed
1628from both files (hence two <tt>-</tt> removals from both file1 and
1629file2, plus <tt>++</tt> to mean one line that was added does not appear
1630in either file1 nor file2). Also two other lines are the same
1631from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1632<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1633merge commit with the merge result (i.e. file1..fileN are the
1634parents). When shown by <tt>git diff-files -c</tt>, it compares the
1635two unresolved merge parents with the working tree file
1636(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1637"their version").</p>
1638</div>
Junio C Hamano3a702342007-12-12 21:34:021639<h2>other diff formats</h2>
1640<div class="sectionbody">
1641<p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1642copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1643output. These options can be combined with other options, such as
1644<tt>-p</tt>, and are meant for human consumption.</p>
1645<p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1646formats the pathnames compactly by combining common prefix and suffix of
1647the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1648<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p>
1649<div class="listingblock">
1650<div class="content">
1651<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1652</div></div>
1653<p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1654for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1655like this:</p>
1656<div class="listingblock">
1657<div class="content">
1658<pre><tt>1 2 README
16593 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1660</div></div>
1661<p>That is, from left to right:</p>
1662<ol>
1663<li>
1664<p>
1665the number of added lines;
1666</p>
1667</li>
1668<li>
1669<p>
1670a tab;
1671</p>
1672</li>
1673<li>
1674<p>
1675the number of deleted lines;
1676</p>
1677</li>
1678<li>
1679<p>
1680a tab;
1681</p>
1682</li>
1683<li>
1684<p>
1685pathname (possibly with rename/copy information);
1686</p>
1687</li>
1688<li>
1689<p>
1690a newline.
1691</p>
1692</li>
1693</ol>
1694<p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p>
1695<div class="listingblock">
1696<div class="content">
1697<pre><tt>1 2 README NUL
16983 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1699</div></div>
1700<p>That is:</p>
1701<ol>
1702<li>
1703<p>
1704the number of added lines;
1705</p>
1706</li>
1707<li>
1708<p>
1709a tab;
1710</p>
1711</li>
1712<li>
1713<p>
1714the number of deleted lines;
1715</p>
1716</li>
1717<li>
1718<p>
1719a tab;
1720</p>
1721</li>
1722<li>
1723<p>
1724a NUL (only exists if renamed/copied);
1725</p>
1726</li>
1727<li>
1728<p>
1729pathname in preimage;
1730</p>
1731</li>
1732<li>
1733<p>
1734a NUL (only exists if renamed/copied);
1735</p>
1736</li>
1737<li>
1738<p>
1739pathname in postimage (only exists if renamed/copied);
1740</p>
1741</li>
1742<li>
1743<p>
1744a NUL.
1745</p>
1746</li>
1747</ol>
1748<p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1749scripts that read the output to tell if the current record being read is
1750a single-path record or a rename/copy record without reading ahead.
1751After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1752the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p>
1753</div>
Junio C Hamano1a4e8412005-12-27 08:17:231754<h2>Author</h2>
1755<div class="sectionbody">
1756<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1757</div>
1758<h2>Documentation</h2>
1759<div class="sectionbody">
1760<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1761</div>
1762<h2>GIT</h2>
1763<div class="sectionbody">
1764<p>Part of the <a href="git.html">git(7)</a> suite</p>
1765</div>
1766<div id="footer">
1767<div id="footer-text">
Junio C Hamanoa9aee782008-04-23 16:09:201768Last updated 23-Apr-2008 16:08:35 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231769</div>
1770</div>
1771</body>
1772</html>