blob: 053b7dbf140871630eba1ce01aa2ad9fae2c2071 [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 Hamano6959c6c2006-05-17 10:34:11375--summary
376</dt>
377<dd>
378<p>
379 Output a condensed summary of extended header information
380 such as creations, renames and mode changes.
381</p>
382</dd>
383<dt>
Junio C Hamanod1308c92006-04-16 11:01:09384--patch-with-stat
385</dt>
386<dd>
387<p>
Junio C Hamano9ae1a062006-07-10 08:12:34388 Synonym for "-p --stat".
Junio C Hamanoff979792007-11-16 10:11:30389
Junio C Hamanod1308c92006-04-16 11:01:09390</p>
391</dd>
392<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23393-z
394</dt>
395<dd>
396<p>
Junio C Hamanob968dbb2007-07-27 07:26:40397 NUL-line termination on output. This affects the --raw
398 output field terminator. Also output from commands such
399 as "git-log" will be delimited with NUL between commits.
Junio C Hamano1a4e8412005-12-27 08:17:23400</p>
401</dd>
402<dt>
403--name-only
404</dt>
405<dd>
406<p>
407 Show only names of changed files.
408</p>
409</dd>
410<dt>
411--name-status
412</dt>
413<dd>
414<p>
415 Show only names and status of changed files.
416</p>
417</dd>
418<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34419--color
420</dt>
421<dd>
422<p>
423 Show colored diff.
424</p>
425</dd>
426<dt>
427--no-color
428</dt>
429<dd>
430<p>
431 Turn off colored diff, even when the configuration file
432 gives the default to color output.
433</p>
434</dd>
435<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41436--color-words
437</dt>
438<dd>
439<p>
440 Show colored word diff, i.e. color words which have changed.
441</p>
442</dd>
443<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34444--no-renames
445</dt>
446<dd>
447<p>
448 Turn off rename detection, even when the configuration
449 file gives the default to do so.
450</p>
451</dd>
452<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21453--check
454</dt>
455<dd>
456<p>
457 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54458 or an indent that uses a space before a tab. Exits with
459 non-zero status if problems are found. Not compatible with
460 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21461</p>
462</dd>
463<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23464--full-index
465</dt>
466<dd>
467<p>
468 Instead of the first handful characters, show full
469 object name of pre- and post-image blob on the "index"
470 line when generating a patch format output.
471</p>
472</dd>
473<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34474--binary
475</dt>
476<dd>
477<p>
478 In addition to --full-index, output "binary diff" that
479 can be applied with "git apply".
480</p>
481</dd>
482<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23483--abbrev[=&lt;n&gt;]
484</dt>
485<dd>
486<p>
487 Instead of showing the full 40-byte hexadecimal object
488 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58489 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23490 independent of --full-index option above, which controls
491 the diff-patch output format. Non default number of
492 digits can be specified with --abbrev=&lt;n&gt;.
493</p>
494</dd>
495<dt>
496-B
497</dt>
498<dd>
499<p>
500 Break complete rewrite changes into pairs of delete and create.
501</p>
502</dd>
503<dt>
504-M
505</dt>
506<dd>
507<p>
508 Detect renames.
509</p>
510</dd>
511<dt>
512-C
513</dt>
514<dd>
515<p>
Junio C Hamano16f98872007-06-12 16:09:14516 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23517</p>
518</dd>
519<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01520--diff-filter=[ACDMRTUXB*]
521</dt>
522<dd>
523<p>
524 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
525 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
526 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
527 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
528 Any combination of the filter characters may be used.
529 When <tt>*</tt> (All-or-none) is added to the combination, all
530 paths are selected if there is any file that matches
531 other criteria in the comparison; if there is no file
532 that matches other criteria, nothing is selected.
533</p>
534</dd>
535<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23536--find-copies-harder
537</dt>
538<dd>
539<p>
Junio C Hamano16f98872007-06-12 16:09:14540 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano1a4e8412005-12-27 08:17:23541 if the original file of the copy was modified in the same
542 changeset. This flag makes the command
543 inspect unmodified files as candidates for the source of
544 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14545 projects, so use it with caution. Giving more than one
546 <tt>-C</tt> option has the same effect.
Junio C Hamano1a4e8412005-12-27 08:17:23547</p>
548</dd>
549<dt>
550-l&lt;num&gt;
551</dt>
552<dd>
553<p>
554 -M and -C options require O(n^2) processing time where n
555 is the number of potential rename/copy targets. This
556 option prevents rename/copy detection from running if
557 the number of rename/copy targets exceeds the specified
558 number.
559</p>
560</dd>
561<dt>
562-S&lt;string&gt;
563</dt>
564<dd>
565<p>
566 Look for differences that contain the change in &lt;string&gt;.
567</p>
568</dd>
569<dt>
570--pickaxe-all
571</dt>
572<dd>
573<p>
574 When -S finds a change, show all the changes in that
575 changeset, not just the files that contain the change
576 in &lt;string&gt;.
577</p>
578</dd>
579<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28580--pickaxe-regex
581</dt>
582<dd>
583<p>
584 Make the &lt;string&gt; not a plain string but an extended POSIX
585 regex to match.
586</p>
587</dd>
588<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23589-O&lt;orderfile&gt;
590</dt>
591<dd>
592<p>
593 Output the patch in the order specified in the
594 &lt;orderfile&gt;, which has one shell glob pattern per line.
595</p>
596</dd>
597<dt>
598-R
599</dt>
600<dd>
601<p>
602 Swap two inputs; that is, show differences from index or
603 on-disk file to tree contents.
604</p>
605</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14606<dt>
Junio C Hamano24bc09a2008-02-28 00:27:44607--relative[=&lt;path&gt;]
608</dt>
609<dd>
610<p>
611 When run from a subdirectory of the project, it can be
612 told to exclude changes outside the directory and show
613 pathnames relative to it with this option. When you are
614 not in a subdirectory (e.g. in a bare repository), you
615 can name which subdirectory to make the output relative
616 to by giving a &lt;path&gt; as an argument.
617</p>
618</dd>
619<dt>
Junio C Hamanoc26f5482006-07-09 09:38:14620--text
621</dt>
622<dd>
623<p>
624 Treat all files as text.
625</p>
626</dd>
627<dt>
628-a
629</dt>
630<dd>
631<p>
632 Shorthand for "--text".
633</p>
634</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07635<dt>
Junio C Hamanofd468962007-02-14 23:45:04636--ignore-space-at-eol
637</dt>
638<dd>
639<p>
Junio C Hamano3a702342007-12-12 21:34:02640 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04641</p>
642</dd>
643<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07644--ignore-space-change
645</dt>
646<dd>
647<p>
Junio C Hamano3a702342007-12-12 21:34:02648 Ignore changes in amount of whitespace. This ignores whitespace
649 at line end, and considers all other sequences of one or
650 more whitespace characters to be equivalent.
Junio C Hamanod9c2d2f2006-12-06 08:59:07651</p>
652</dd>
653<dt>
654-b
655</dt>
656<dd>
657<p>
658 Shorthand for "--ignore-space-change".
659</p>
660</dd>
661<dt>
662--ignore-all-space
663</dt>
664<dd>
665<p>
Junio C Hamano3a702342007-12-12 21:34:02666 Ignore whitespace when comparing lines. This ignores
667 differences even if one line has whitespace where the other
Junio C Hamanod9c2d2f2006-12-06 08:59:07668 line has none.
669</p>
670</dd>
671<dt>
672-w
673</dt>
674<dd>
675<p>
676 Shorthand for "--ignore-all-space".
677</p>
678</dd>
Junio C Hamano48fd2f62007-03-19 02:02:30679<dt>
680--exit-code
681</dt>
682<dd>
683<p>
684 Make the program exit with codes similar to diff(1).
685 That is, it exits with 1 if there were differences and
686 0 means no differences.
687</p>
688</dd>
Junio C Hamano35e57552007-03-25 07:54:35689<dt>
690--quiet
691</dt>
692<dd>
693<p>
694 Disable all output of the program. Implies --exit-code.
695</p>
696</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40697<dt>
698--ext-diff
699</dt>
700<dd>
701<p>
702 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53703 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
704 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40705</p>
706</dd>
707<dt>
708--no-ext-diff
709</dt>
710<dd>
711<p>
712 Disallow external diff drivers.
713</p>
714</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33715<dt>
716--src-prefix=&lt;prefix&gt;
717</dt>
718<dd>
719<p>
720 Show the given source prefix instead of "a/".
721</p>
722</dd>
723<dt>
724--dst-prefix=&lt;prefix&gt;
725</dt>
726<dd>
727<p>
728 Show the given destination prefix instead of "b/".
729</p>
730</dd>
731<dt>
732--no-prefix
733</dt>
734<dd>
735<p>
736 Do not show any source or destination prefix.
737</p>
738</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23739</dl>
740<p>For more detailed explanation on these common options, see also
741<a href="diffcore.html">diffcore documentation</a>.</p>
742<dl>
743<dt>
744&lt;tree-ish&gt;
745</dt>
746<dd>
747<p>
748 The id of a tree object.
749</p>
750</dd>
751<dt>
752&lt;path&gt;&#8230;
753</dt>
754<dd>
755<p>
756 If provided, the results are limited to a subset of files
757 matching one of these prefix strings.
Junio C Hamano341071d2006-06-04 07:24:48758 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
Junio C Hamano1a4e8412005-12-27 08:17:23759 Note that this parameter does not provide any wildcard or regexp
760 features.
761</p>
762</dd>
763<dt>
764-r
765</dt>
766<dd>
767<p>
768 recurse into sub-trees
769</p>
770</dd>
771<dt>
772-t
773</dt>
774<dd>
775<p>
776 show tree entry itself as well as subtrees. Implies -r.
777</p>
778</dd>
779<dt>
780--root
781</dt>
782<dd>
783<p>
784 When <em>--root</em> is specified the initial commit will be showed as a big
785 creation event. This is equivalent to a diff against the NULL tree.
786</p>
787</dd>
788<dt>
789--stdin
790</dt>
791<dd>
792<p>
793 When <em>--stdin</em> is specified, the command does not take
794 &lt;tree-ish&gt; arguments from the command line. Instead, it
795 reads either one &lt;commit&gt; or a pair of &lt;tree-ish&gt;
796 separated with a single space from its standard input.
797</p>
798<p>When a single commit is given on one line of such input, it compares
799the commit with its parents. The following flags further affects its
Junio C Hamano341071d2006-06-04 07:24:48800behavior. This does not apply to the case where two &lt;tree-ish&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23801separated with a single space are given.</p>
802</dd>
803<dt>
804-m
805</dt>
806<dd>
807<p>
808 By default, "git-diff-tree --stdin" does not show
809 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16810 differences to that commit from all of its parents. See
811 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23812</p>
813</dd>
814<dt>
815-s
816</dt>
817<dd>
818<p>
819 By default, "git-diff-tree --stdin" shows differences,
820 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58821 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23822 only useful with <em>-v</em> flag.
823</p>
824</dd>
825<dt>
826-v
827</dt>
828<dd>
829<p>
830 This flag causes "git-diff-tree --stdin" to also show
831 the commit message before the differences.
832</p>
833</dd>
834<dt>
Junio C Hamanoa340aaa2006-11-23 02:47:33835--pretty[=<em>&lt;format&gt;</em>]
Junio C Hamano1a4e8412005-12-27 08:17:23836</dt>
837<dd>
838<p>
Junio C Hamanoa3770f92007-07-25 08:53:33839 Pretty-print the contents of the commit logs in a given format,
Junio C Hamano0430e3a2007-05-15 03:13:17840 where <em>&lt;format&gt;</em> can be one of <em>oneline</em>, <em>short</em>, <em>medium</em>,
841 <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:33842 When omitted, the format defaults to <em>medium</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23843</p>
Junio C Hamano0430e3a2007-05-15 03:13:17844</dd>
845<dt>
Junio C Hamanoee695f22007-06-21 00:35:36846--abbrev-commit
847</dt>
848<dd>
849<p>
850 Instead of showing the full 40-byte hexadecimal commit object
851 name, show only handful hexdigits prefix. Non default number of
852 digits can be specified with "--abbrev=&lt;n&gt;" (which also modifies
853 diff output, if it is displayed).
854</p>
855<p>This should make "--pretty=oneline" a whole lot more readable for
856people using 80-column terminals.</p>
857</dd>
858<dt>
Junio C Hamano0430e3a2007-05-15 03:13:17859--encoding[=&lt;encoding&gt;]
860</dt>
861<dd>
862<p>
863 The commit objects record the encoding used for the log message
864 in their encoding header; this option can be used to tell the
865 command to re-code the commit log message in the encoding
866 preferred by the user. For non plumbing commands this
867 defaults to UTF-8.
868</p>
869</dd>
870<dt>
871--no-commit-id
872</dt>
873<dd>
874<p>
875 git-diff-tree outputs a line with the commit ID when
876 applicable. This flag suppressed the commit ID output.
877</p>
878</dd>
879<dt>
880-c
881</dt>
882<dd>
883<p>
884 This flag changes the way a merge commit is displayed
885 (which means it is useful only when the command is given
886 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
887 from each of the parents to the merge result simultaneously
888 instead of showing pairwise diff between a parent and the
889 result one at a time (which is what the <em>-m</em> option does).
890 Furthermore, it lists only files which were modified
891 from all parents.
892</p>
893</dd>
894<dt>
895--cc
896</dt>
897<dd>
898<p>
899 This flag changes the way a merge commit patch is displayed,
900 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
901 and <em>-p</em> options and further compresses the patch output
902 by omitting hunks that show differences from only one
903 parent, or show the same change from all but one parent
904 for an Octopus merge. When this optimization makes all
905 hunks disappear, the commit itself and the commit log
906 message is not shown, just like in any other "empty diff" case.
907</p>
908</dd>
909<dt>
910--always
911</dt>
912<dd>
913<p>
914 Show the commit itself and the commit log message even
915 if the diff itself is empty.
916</p>
917</dd>
918</dl>
919</div>
920<h2>PRETTY FORMATS</h2>
921<div class="sectionbody">
922<p>If the commit is a merge, and if the pretty-format
923is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
924inserted before the <em>Author:</em> line. This line begins with
925"Merge: " and the sha1s of ancestral commits are printed,
926separated by spaces. Note that the listed commits may not
927necessarily be the list of the <strong>direct</strong> parent commits if you
928have limited your view of history: for example, if you are
929only interested in changes related to a certain directory or
930file.</p>
931<p>Here are some additional details for each format:</p>
Junio C Hamanoa340aaa2006-11-23 02:47:33932<ul>
933<li>
934<p>
935<em>oneline</em>
936</p>
937<div class="literalblock">
938<div class="content">
939<pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
940</div></div>
941<p>This is designed to be as compact as possible.</p>
942</li>
943<li>
944<p>
945<em>short</em>
946</p>
947<div class="literalblock">
948<div class="content">
949<pre><tt>commit &lt;sha1&gt;
950Author: &lt;author&gt;</tt></pre>
951</div></div>
952<div class="literalblock">
953<div class="content">
954<pre><tt>&lt;title line&gt;</tt></pre>
955</div></div>
956</li>
957<li>
958<p>
959<em>medium</em>
960</p>
961<div class="literalblock">
962<div class="content">
963<pre><tt>commit &lt;sha1&gt;
964Author: &lt;author&gt;
965Date: &lt;date&gt;</tt></pre>
966</div></div>
967<div class="literalblock">
968<div class="content">
969<pre><tt>&lt;title line&gt;</tt></pre>
970</div></div>
971<div class="literalblock">
972<div class="content">
973<pre><tt>&lt;full commit message&gt;</tt></pre>
974</div></div>
975</li>
976<li>
977<p>
978<em>full</em>
979</p>
980<div class="literalblock">
981<div class="content">
982<pre><tt>commit &lt;sha1&gt;
983Author: &lt;author&gt;
984Commit: &lt;committer&gt;</tt></pre>
985</div></div>
986<div class="literalblock">
987<div class="content">
988<pre><tt>&lt;title line&gt;</tt></pre>
989</div></div>
990<div class="literalblock">
991<div class="content">
992<pre><tt>&lt;full commit message&gt;</tt></pre>
993</div></div>
994</li>
995<li>
996<p>
997<em>fuller</em>
998</p>
999<div class="literalblock">
1000<div class="content">
1001<pre><tt>commit &lt;sha1&gt;
1002Author: &lt;author&gt;
1003AuthorDate: &lt;date &amp; time&gt;
1004Commit: &lt;committer&gt;
1005CommitDate: &lt;date &amp; time&gt;</tt></pre>
1006</div></div>
1007<div class="literalblock">
1008<div class="content">
1009<pre><tt>&lt;title line&gt;</tt></pre>
1010</div></div>
1011<div class="literalblock">
1012<div class="content">
1013<pre><tt>&lt;full commit message&gt;</tt></pre>
1014</div></div>
1015</li>
1016<li>
1017<p>
1018<em>email</em>
1019</p>
1020<div class="literalblock">
1021<div class="content">
1022<pre><tt>From &lt;sha1&gt; &lt;date&gt;
1023From: &lt;author&gt;
1024Date: &lt;date &amp; time&gt;
1025Subject: [PATCH] &lt;title line&gt;</tt></pre>
1026</div></div>
1027<div class="literalblock">
1028<div class="content">
Junio C Hamano0430e3a2007-05-15 03:13:171029<pre><tt>&lt;full commit message&gt;</tt></pre>
Junio C Hamanoa340aaa2006-11-23 02:47:331030</div></div>
1031</li>
1032<li>
1033<p>
1034<em>raw</em>
1035</p>
1036<p>The <em>raw</em> format shows the entire commit exactly as
1037stored in the commit object. Notably, the SHA1s are
1038displayed in full, regardless of whether --abbrev or
1039--no-abbrev are used, and <em>parents</em> information show the
1040true parent commits, without taking grafts nor history
1041simplification into account.</p>
1042</li>
Junio C Hamanoa3fd83c2007-03-02 10:34:361043<li>
1044<p>
1045<em>format:</em>
1046</p>
1047<p>The <em>format:</em> format allows you to specify which information
1048you want to show. It works a little bit like printf format,
1049with the notable exception that you get a newline with <em>%n</em>
1050instead of <em>\n</em>.</p>
Junio C Hamano0430e3a2007-05-15 03:13:171051<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:361052would show something like this:</p>
Junio C Hamano0430e3a2007-05-15 03:13:171053<div class="listingblock">
1054<div class="content">
1055<pre><tt>The author of fe6e0ee was Junio C Hamano, 23 hours ago
1056The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;
1057</tt></pre>
1058</div></div>
Junio C Hamanoa3fd83c2007-03-02 10:34:361059<p>The placeholders are:</p>
1060<ul>
1061<li>
1062<p>
1063<em>%H</em>: commit hash
1064</p>
1065</li>
1066<li>
1067<p>
1068<em>%h</em>: abbreviated commit hash
1069</p>
1070</li>
1071<li>
1072<p>
1073<em>%T</em>: tree hash
1074</p>
1075</li>
1076<li>
1077<p>
1078<em>%t</em>: abbreviated tree hash
1079</p>
1080</li>
1081<li>
1082<p>
1083<em>%P</em>: parent hashes
1084</p>
1085</li>
1086<li>
1087<p>
1088<em>%p</em>: abbreviated parent hashes
1089</p>
1090</li>
1091<li>
1092<p>
1093<em>%an</em>: author name
1094</p>
1095</li>
1096<li>
1097<p>
1098<em>%ae</em>: author email
1099</p>
1100</li>
1101<li>
1102<p>
1103<em>%ad</em>: author date
1104</p>
1105</li>
1106<li>
1107<p>
1108<em>%aD</em>: author date, RFC2822 style
1109</p>
1110</li>
1111<li>
1112<p>
1113<em>%ar</em>: author date, relative
1114</p>
1115</li>
1116<li>
1117<p>
1118<em>%at</em>: author date, UNIX timestamp
1119</p>
1120</li>
1121<li>
1122<p>
Junio C Hamano02f130b2007-07-14 08:26:561123<em>%ai</em>: author date, ISO 8601 format
1124</p>
1125</li>
1126<li>
1127<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361128<em>%cn</em>: committer name
1129</p>
1130</li>
1131<li>
1132<p>
1133<em>%ce</em>: committer email
1134</p>
1135</li>
1136<li>
1137<p>
1138<em>%cd</em>: committer date
1139</p>
1140</li>
1141<li>
1142<p>
1143<em>%cD</em>: committer date, RFC2822 style
1144</p>
1145</li>
1146<li>
1147<p>
1148<em>%cr</em>: committer date, relative
1149</p>
1150</li>
1151<li>
1152<p>
1153<em>%ct</em>: committer date, UNIX timestamp
1154</p>
1155</li>
1156<li>
1157<p>
Junio C Hamano02f130b2007-07-14 08:26:561158<em>%ci</em>: committer date, ISO 8601 format
1159</p>
1160</li>
1161<li>
1162<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361163<em>%e</em>: encoding
1164</p>
1165</li>
1166<li>
1167<p>
1168<em>%s</em>: subject
1169</p>
1170</li>
1171<li>
1172<p>
1173<em>%b</em>: body
1174</p>
1175</li>
1176<li>
1177<p>
1178<em>%Cred</em>: switch color to red
1179</p>
1180</li>
1181<li>
1182<p>
1183<em>%Cgreen</em>: switch color to green
1184</p>
1185</li>
1186<li>
1187<p>
1188<em>%Cblue</em>: switch color to blue
1189</p>
1190</li>
1191<li>
1192<p>
1193<em>%Creset</em>: reset color
1194</p>
1195</li>
1196<li>
1197<p>
Junio C Hamanod9e0e5d2007-04-14 16:22:041198<em>%m</em>: left, right or boundary mark
1199</p>
1200</li>
1201<li>
1202<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361203<em>%n</em>: newline
1204</p>
Junio C Hamano0430e3a2007-05-15 03:13:171205</li>
1206</ul>
Junio C Hamanoa3fd83c2007-03-02 10:34:361207</li>
1208</ul>
Junio C Hamano1a4e8412005-12-27 08:17:231209</div>
1210<h2>Limiting Output</h2>
1211<div class="sectionbody">
1212<p>If you're only interested in differences in a subset of files, for
1213example some architecture-specific files, you might do:</p>
1214<div class="literalblock">
1215<div class="content">
1216<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
1217</div></div>
1218<p>and it will only show you what changed in those two directories.</p>
1219<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
1220<div class="literalblock">
1221<div class="content">
1222<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
1223</div></div>
1224<p>and it will ignore all differences to other files.</p>
1225<p>The pattern is always the prefix, and is matched exactly. There are no
1226wildcards. Even stricter, it has to match a complete path component.
1227I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
1228so it can be used to name subdirectories.</p>
1229<p>An example of normal usage is:</p>
1230<div class="literalblock">
1231<div class="content">
1232<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
1233*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
1234</div></div>
1235<p>which tells you that the last commit changed just one file (it's from
1236this one:</p>
1237<div class="listingblock">
1238<div class="content">
1239<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1240tree 5319e4d609cdd282069cc4dce33c1db559539b03
1241parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1242author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1243committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1244
1245Make "git-fsck-objects" print out all the root commits it finds.
1246
1247Once I do the reference tracking, I'll also make it print out all the
1248HEAD commits it finds, which is even more interesting.</tt></pre>
1249</div></div>
1250<p>in case you care).</p>
1251</div>
1252<h2>Output format</h2>
1253<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461254<p>The output format from "git-diff-index", "git-diff-tree",
1255"git-diff-files" and "git diff --raw" are very similar.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231256<p>These commands all compare two sets of things; what is
1257compared differs:</p>
1258<dl>
1259<dt>
1260git-diff-index &lt;tree-ish&gt;
1261</dt>
1262<dd>
1263<p>
1264 compares the &lt;tree-ish&gt; and the files on the filesystem.
1265</p>
1266</dd>
1267<dt>
1268git-diff-index --cached &lt;tree-ish&gt;
1269</dt>
1270<dd>
1271<p>
1272 compares the &lt;tree-ish&gt; and the index.
1273</p>
1274</dd>
1275<dt>
1276git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1277</dt>
1278<dd>
1279<p>
1280 compares the trees named by the two arguments.
1281</p>
1282</dd>
1283<dt>
1284git-diff-files [&lt;pattern&gt;&#8230;]
1285</dt>
1286<dd>
1287<p>
1288 compares the index and the files on the filesystem.
1289</p>
1290</dd>
1291</dl>
1292<p>An output line is formatted this way:</p>
1293<div class="listingblock">
1294<div class="content">
1295<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1296copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1297rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1298create :000000 100644 0000000... 1234567... A file4
1299delete :100644 000000 1234567... 0000000... D file5
1300unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1301</div></div>
1302<p>That is, from the left to the right:</p>
1303<ol>
1304<li>
1305<p>
1306a colon.
1307</p>
1308</li>
1309<li>
1310<p>
1311mode for "src"; 000000 if creation or unmerged.
1312</p>
1313</li>
1314<li>
1315<p>
1316a space.
1317</p>
1318</li>
1319<li>
1320<p>
1321mode for "dst"; 000000 if deletion or unmerged.
1322</p>
1323</li>
1324<li>
1325<p>
1326a space.
1327</p>
1328</li>
1329<li>
1330<p>
1331sha1 for "src"; 0{40} if creation or unmerged.
1332</p>
1333</li>
1334<li>
1335<p>
1336a space.
1337</p>
1338</li>
1339<li>
1340<p>
1341sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1342</p>
1343</li>
1344<li>
1345<p>
1346a space.
1347</p>
1348</li>
1349<li>
1350<p>
1351status, followed by optional "score" number.
1352</p>
1353</li>
1354<li>
1355<p>
1356a tab or a NUL when <em>-z</em> option is used.
1357</p>
1358</li>
1359<li>
1360<p>
1361path for "src"
1362</p>
1363</li>
1364<li>
1365<p>
1366a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1367</p>
1368</li>
1369<li>
1370<p>
1371path for "dst"; only exists for C or R.
1372</p>
1373</li>
1374<li>
1375<p>
1376an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1377</p>
1378</li>
1379</ol>
1380<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1381and it is out of sync with the index.</p>
1382<p>Example:</p>
1383<div class="listingblock">
1384<div class="content">
1385<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1386</div></div>
1387<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1388in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1389respectively.</p>
1390</div>
Junio C Hamano67fad6d2007-05-06 08:53:121391<h2>diff format for merges</h2>
1392<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461393<p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1394can take <em>-c</em> or <em>--cc</em> option
Junio C Hamano67fad6d2007-05-06 08:53:121395to generate diff output also for merge commits. The output differs
1396from the format described above in the following way:</p>
1397<ol>
1398<li>
1399<p>
1400there is a colon for each parent
1401</p>
1402</li>
1403<li>
1404<p>
1405there are more "src" modes and "src" sha1
1406</p>
1407</li>
1408<li>
1409<p>
1410status is concatenated status characters for each parent
1411</p>
1412</li>
1413<li>
1414<p>
1415no optional "score" number
1416</p>
1417</li>
1418<li>
1419<p>
1420single path, only for "dst"
1421</p>
1422</li>
1423</ol>
1424<p>Example:</p>
1425<div class="listingblock">
1426<div class="content">
1427<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1428</div></div>
1429<p>Note that <em>combined diff</em> lists only files which were modified from
1430all parents.</p>
1431</div>
Junio C Hamano1a4e8412005-12-27 08:17:231432<h2>Generating patches with -p</h2>
1433<div class="sectionbody">
1434<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:491435with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1436"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:461437do not produce the output described above; instead they produce a
1438patch file. You can customize the creation of such patches via the
1439GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p>
Junio C Hamano1c437122006-11-28 02:22:251440<p>What the -p option produces is slightly different from the traditional
1441diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231442<ol>
1443<li>
1444<p>
Junio C Hamano235a91e2006-01-07 01:13:581445It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231446 this:
1447</p>
1448<div class="literalblock">
1449<div class="content">
1450<pre><tt>diff --git a/file1 b/file2</tt></pre>
1451</div></div>
1452<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1453involved. Especially, even for a creation or a deletion,
1454<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
1455<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1456name of the source file of the rename/copy and the name of
1457the file that rename/copy produces, respectively.</p>
1458</li>
1459<li>
1460<p>
1461It is followed by one or more extended header lines:
1462</p>
1463<div class="literalblock">
1464<div class="content">
1465<pre><tt>old mode &lt;mode&gt;
1466new mode &lt;mode&gt;
1467deleted file mode &lt;mode&gt;
1468new file mode &lt;mode&gt;
1469copy from &lt;path&gt;
1470copy to &lt;path&gt;
1471rename from &lt;path&gt;
1472rename to &lt;path&gt;
1473similarity index &lt;number&gt;
1474dissimilarity index &lt;number&gt;
1475index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1476</div></div>
1477</li>
1478<li>
1479<p>
Junio C Hamanoa053d542006-10-27 09:29:131480TAB, LF, double quote and backslash characters in pathnames
1481 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1482 If there is need for such substitution then the whole
1483 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231484</p>
1485</li>
1486</ol>
Junio C Hamanod526ba92007-07-02 00:17:421487<p>The similarity index is the percentage of unchanged lines, and
1488the dissimilarity index is the percentage of changed lines. It
1489is a rounded down integer, followed by a percent sign. The
1490similarity index value of 100% is thus reserved for two equal
1491files, while 100% dissimilarity means that no line from the old
1492file made it into the new one.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231493</div>
Junio C Hamanofb56a962006-01-28 10:38:191494<h2>combined diff format</h2>
1495<div class="sectionbody">
Junio C Hamano7ae0ab22007-11-03 02:46:461496<p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
Junio C Hamano00b8b632007-12-07 09:50:491497<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1498with "git log -p", this is the default format.
1499A <em>combined diff</em> format looks like this:</p>
Junio C Hamanofb56a962006-01-28 10:38:191500<div class="listingblock">
1501<div class="content">
1502<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291503index fabadb8,cc95eb0..4866510
1504--- a/describe.c
1505+++ b/describe.c
1506@@@ -98,20 -98,12 +98,20 @@@
1507 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191508 }
1509
1510- static void describe(char *arg)
1511 -static void describe(struct commit *cmit, int last_one)
1512++static void describe(char *arg, int last_one)
1513 {
Junio C Hamano29f14312006-10-26 08:47:291514 + unsigned char sha1[20];
1515 + struct commit *cmit;
1516 struct commit_list *list;
1517 static int initialized = 0;
1518 struct commit_name *n;
1519
1520 + if (get_sha1(arg, sha1) &lt; 0)
1521 + usage(describe_usage);
1522 + cmit = lookup_commit_reference(sha1);
1523 + if (!cmit)
1524 + usage(describe_usage);
1525 +
1526 if (!initialized) {
1527 initialized = 1;
1528 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191529</div></div>
Junio C Hamano29f14312006-10-26 08:47:291530<ol>
1531<li>
1532<p>
1533It is preceded with a "git diff" header, that looks like
1534 this (when <em>-c</em> option is used):
1535</p>
1536<div class="literalblock">
1537<div class="content">
1538<pre><tt>diff --combined file</tt></pre>
1539</div></div>
1540<p>or like this (when <em>--cc</em> option is used):</p>
1541<div class="literalblock">
1542<div class="content">
1543<pre><tt>diff --c file</tt></pre>
1544</div></div>
1545</li>
1546<li>
1547<p>
1548It is followed by one or more extended header lines
1549 (this example shows a merge with two parents):
1550</p>
1551<div class="literalblock">
1552<div class="content">
1553<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1554mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1555new file mode &lt;mode&gt;
1556deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1557</div></div>
1558<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:041559the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291560information about detected contents movement (renames and
1561copying detection) are designed to work with diff of two
1562&lt;tree-ish&gt; and are not used by combined diff format.</p>
1563</li>
1564<li>
1565<p>
1566It is followed by two-line from-file/to-file header
1567</p>
1568<div class="literalblock">
1569<div class="content">
1570<pre><tt>--- a/file
1571+++ b/file</tt></pre>
1572</div></div>
1573<p>Similar to two-line header for traditional <em>unified</em> diff
1574format, <tt>/dev/null</tt> is used to signal created or deleted
1575files.</p>
1576</li>
1577<li>
1578<p>
1579Chunk header format is modified to prevent people from
1580 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1581 was created for review of merge commit changes, and was not
1582 meant for apply. The change is similar to the change in the
1583 extended <em>index</em> header:
1584</p>
1585<div class="literalblock">
1586<div class="content">
1587<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1588</div></div>
1589<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1590header for combined diff format.</p>
1591</li>
1592</ol>
Junio C Hamanofb56a962006-01-28 10:38:191593<p>Unlike the traditional <em>unified</em> diff format, which shows two
1594files A and B with a single column that has <tt>-</tt> (minus &#8212;
1595appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291596added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191597compares two or more files file1, file2,&#8230; with one file X, and
1598shows how X differs from each of fileN. One column for each of
1599fileN is prepended to the output line to note how X's line is
1600different from it.</p>
1601<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291602fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191603in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291604and fileN does not have that line (in other words, the line was
1605added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191606<p>In the above example output, the function signature was changed
1607from both files (hence two <tt>-</tt> removals from both file1 and
1608file2, plus <tt>++</tt> to mean one line that was added does not appear
1609in either file1 nor file2). Also two other lines are the same
1610from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1611<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1612merge commit with the merge result (i.e. file1..fileN are the
1613parents). When shown by <tt>git diff-files -c</tt>, it compares the
1614two unresolved merge parents with the working tree file
1615(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1616"their version").</p>
1617</div>
Junio C Hamano3a702342007-12-12 21:34:021618<h2>other diff formats</h2>
1619<div class="sectionbody">
1620<p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1621copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1622output. These options can be combined with other options, such as
1623<tt>-p</tt>, and are meant for human consumption.</p>
1624<p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1625formats the pathnames compactly by combining common prefix and suffix of
1626the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1627<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p>
1628<div class="listingblock">
1629<div class="content">
1630<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1631</div></div>
1632<p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1633for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1634like this:</p>
1635<div class="listingblock">
1636<div class="content">
1637<pre><tt>1 2 README
16383 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1639</div></div>
1640<p>That is, from left to right:</p>
1641<ol>
1642<li>
1643<p>
1644the number of added lines;
1645</p>
1646</li>
1647<li>
1648<p>
1649a tab;
1650</p>
1651</li>
1652<li>
1653<p>
1654the number of deleted lines;
1655</p>
1656</li>
1657<li>
1658<p>
1659a tab;
1660</p>
1661</li>
1662<li>
1663<p>
1664pathname (possibly with rename/copy information);
1665</p>
1666</li>
1667<li>
1668<p>
1669a newline.
1670</p>
1671</li>
1672</ol>
1673<p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p>
1674<div class="listingblock">
1675<div class="content">
1676<pre><tt>1 2 README NUL
16773 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1678</div></div>
1679<p>That is:</p>
1680<ol>
1681<li>
1682<p>
1683the number of added lines;
1684</p>
1685</li>
1686<li>
1687<p>
1688a tab;
1689</p>
1690</li>
1691<li>
1692<p>
1693the number of deleted lines;
1694</p>
1695</li>
1696<li>
1697<p>
1698a tab;
1699</p>
1700</li>
1701<li>
1702<p>
1703a NUL (only exists if renamed/copied);
1704</p>
1705</li>
1706<li>
1707<p>
1708pathname in preimage;
1709</p>
1710</li>
1711<li>
1712<p>
1713a NUL (only exists if renamed/copied);
1714</p>
1715</li>
1716<li>
1717<p>
1718pathname in postimage (only exists if renamed/copied);
1719</p>
1720</li>
1721<li>
1722<p>
1723a NUL.
1724</p>
1725</li>
1726</ol>
1727<p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1728scripts that read the output to tell if the current record being read is
1729a single-path record or a rename/copy record without reading ahead.
1730After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1731the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p>
1732</div>
Junio C Hamano1a4e8412005-12-27 08:17:231733<h2>Author</h2>
1734<div class="sectionbody">
1735<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1736</div>
1737<h2>Documentation</h2>
1738<div class="sectionbody">
1739<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1740</div>
1741<h2>GIT</h2>
1742<div class="sectionbody">
1743<p>Part of the <a href="git.html">git(7)</a> suite</p>
1744</div>
1745<div id="footer">
1746<div id="footer-text">
Junio C Hamano24bc09a2008-02-28 00:27:441747Last updated 28-Feb-2008 00:25:39 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231748</div>
1749</div>
1750</body>
1751</html>