blob: 72daac467581a5d63d7cc53779b18474ccc72ce6 [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 Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
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
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano1a4e8412005-12-27 08:17:2326
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2348 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1a4e8412005-12-27 08:17:2359
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:2384}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano1a4e8412005-12-27 08:17:23155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1a4e8412005-12-27 08:17:23171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano1a4e8412005-12-27 08:17:23236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano1a4e8412005-12-27 08:17:23275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano1a4e8412005-12-27 08:17:23306</style>
307<title>git-diff-tree(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-diff-tree(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-diff-tree -
317 Compares the content and mode of blobs found via two tree objects
318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58323<div class="verseblock">
Junio C Hamanofce7c7e2008-07-02 03:06:38324<div class="content"><em>git diff-tree</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
Junio C Hamanofb56a962006-01-28 10:38:19325 [-t] [-r] [-c | --cc] [--root] [&lt;common diff options&gt;]
326 &lt;tree-ish&gt; [&lt;tree-ish&gt;] [&lt;path&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23327</div>
Junio C Hamanoba4b9282008-07-06 05:20:31328<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23329<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31330<div class="para"><p>Compares the content and mode of the blobs found via two tree objects.</p></div>
331<div class="para"><p>If there is only one &lt;tree-ish&gt; given, the commit is compared with its parents
332(see --stdin below).</p></div>
333<div class="para"><p>Note that <em>git-diff-tree</em> can use the tree encapsulated in a commit object.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23334</div>
Junio C Hamanoba4b9282008-07-06 05:20:31335<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23336<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31337<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23338<dt>
339-p
340</dt>
Junio C Hamanobbbb8652008-12-29 10:34:22341<dt>
342-u
343</dt>
Junio C Hamano1a4e8412005-12-27 08:17:23344<dd>
345<p>
Junio C Hamanoff979792007-11-16 10:11:30346 Generate patch (see section on generating patches).
347
Junio C Hamano1a4e8412005-12-27 08:17:23348</p>
349</dd>
350<dt>
Junio C Hamano69361562007-07-26 02:14:34351-U&lt;n&gt;
352</dt>
Junio C Hamano69361562007-07-26 02:14:34353<dt>
354--unified=&lt;n&gt;
355</dt>
356<dd>
357<p>
358 Generate diffs with &lt;n&gt; lines of context instead of
Junio C Hamano3b70d3c2009-11-21 17:37:37359 the usual three.
360 Implies <tt>-p</tt>.
Junio C Hamano69361562007-07-26 02:14:34361</p>
362</dd>
363<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34364--raw
365</dt>
366<dd>
367<p>
368 Generate the raw format.
Junio C Hamanoff979792007-11-16 10:11:30369 This is the default.
Junio C Hamano9ae1a062006-07-10 08:12:34370</p>
371</dd>
372<dt>
Junio C Hamano54559c82006-04-13 07:45:12373--patch-with-raw
374</dt>
375<dd>
376<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37377 Synonym for <tt>-p --raw</tt>.
Junio C Hamano54559c82006-04-13 07:45:12378</p>
379</dd>
Junio C Hamano20d47e32009-01-26 06:36:02380<dt>
381--patience
382</dt>
383<dd>
384<p>
385 Generate a diff using the "patience diff" algorithm.
386</p>
387</dd>
Junio C Hamano54559c82006-04-13 07:45:12388<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29389--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42390</dt>
391<dd>
392<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29393 Generate a diffstat. You can override the default
Junio C Hamano3b70d3c2009-11-21 17:37:37394 output width for 80-column terminal by <tt>--stat=width</tt>.
Junio C Hamano4a9a76a2006-10-01 05:40:29395 The width of the filename part can be controlled by
396 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42397</p>
398</dd>
399<dt>
Junio C Hamanofbe00522006-10-19 05:58:48400--numstat
401</dt>
402<dd>
403<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37404 Similar to <tt>--stat</tt>, but shows number of added and
Junio C Hamanofbe00522006-10-19 05:58:48405 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43406 abbreviation, to make it more machine friendly. For
407 binary files, outputs two <tt>-</tt> instead of saying
408 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48409</p>
410</dd>
411<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04412--shortstat
413</dt>
414<dd>
415<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37416 Output only the last line of the <tt>--stat</tt> format containing total
Junio C Hamano7d23f5e2006-12-16 07:44:04417 number of modified files, as well as number of added and deleted
418 lines.
419</p>
420</dd>
421<dt>
Junio C Hamano6a45be92008-04-22 08:19:03422--dirstat[=limit]
423</dt>
424<dd>
425<p>
Junio C Hamanoa2f46622008-09-03 05:20:31426 Output the distribution of relative amount of changes (number of lines added or
427 removed) for each sub-directory. Directories with changes below
428 a cut-off percent (3% by default) are not shown. The cut-off percent
Junio C Hamano3b70d3c2009-11-21 17:37:37429 can be set with <tt>--dirstat=limit</tt>. Changes in a child directory is not
430 counted for the parent directory, unless <tt>--cumulative</tt> is used.
Junio C Hamano6a45be92008-04-22 08:19:03431</p>
432</dd>
433<dt>
Junio C Hamanoa476efa2008-10-10 15:31:42434--dirstat-by-file[=limit]
435</dt>
436<dd>
437<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37438 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
Junio C Hamanoa476efa2008-10-10 15:31:42439</p>
440</dd>
441<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11442--summary
443</dt>
444<dd>
445<p>
446 Output a condensed summary of extended header information
447 such as creations, renames and mode changes.
448</p>
449</dd>
450<dt>
Junio C Hamanod1308c92006-04-16 11:01:09451--patch-with-stat
452</dt>
453<dd>
454<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37455 Synonym for <tt>-p --stat</tt>.
Junio C Hamanod1308c92006-04-16 11:01:09456</p>
457</dd>
458<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23459-z
460</dt>
461<dd>
462<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37463 NUL-line termination on output. This affects the <tt>--raw</tt>
Junio C Hamanob968dbb2007-07-27 07:26:40464 output field terminator. Also output from commands such
Junio C Hamano3b70d3c2009-11-21 17:37:37465 as <tt>git-log</tt> will be delimited with NUL between commits.
Junio C Hamano1a4e8412005-12-27 08:17:23466</p>
467</dd>
468<dt>
469--name-only
470</dt>
471<dd>
472<p>
473 Show only names of changed files.
474</p>
475</dd>
476<dt>
477--name-status
478</dt>
479<dd>
480<p>
Junio C Hamanoa9aee782008-04-23 16:09:20481 Show only names and status of changed files. See the description
482 of the <tt>--diff-filter</tt> option on what the status letters mean.
Junio C Hamano1a4e8412005-12-27 08:17:23483</p>
484</dd>
485<dt>
Junio C Hamanoc21ab052009-10-31 04:03:55486--submodule[=&lt;format&gt;]
487</dt>
488<dd>
489<p>
490 Chose the output format for submodule differences. &lt;format&gt; can be one of
491 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
492 is used when this option is not given. <em>log</em> is the default value for this
493 option and lists the commits in that commit range like the <em>summary</em>
494 option of <a href="git-submodule.html">git-submodule(1)</a> does.
495</p>
496</dd>
497<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34498--color
499</dt>
500<dd>
501<p>
502 Show colored diff.
503</p>
504</dd>
505<dt>
506--no-color
507</dt>
508<dd>
509<p>
510 Turn off colored diff, even when the configuration file
511 gives the default to color output.
512</p>
513</dd>
514<dt>
Junio C Hamano20d47e32009-01-26 06:36:02515--color-words[=&lt;regex&gt;]
Junio C Hamano85e45fa2006-08-13 07:47:41516</dt>
517<dd>
518<p>
Junio C Hamano20d47e32009-01-26 06:36:02519 Show colored word diff, i.e., color words which have changed.
520 By default, words are separated by whitespace.
Junio C Hamano85e45fa2006-08-13 07:47:41521</p>
Junio C Hamano20d47e32009-01-26 06:36:02522<div class="para"><p>When a &lt;regex&gt; is specified, every non-overlapping match of the
523&lt;regex&gt; is considered a word. Anything between these matches is
524considered whitespace and ignored(!) for the purposes of finding
525differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
526expression to make sure that it matches all non-whitespace characters.
527A match that contains a newline is silently truncated(!) at the
528newline.</p></div>
529<div class="para"><p>The regex can also be set via a diff driver or configuration option, see
530<a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
531overrides any diff driver or configuration setting. Diff drivers
532override configuration settings.</p></div>
Junio C Hamano85e45fa2006-08-13 07:47:41533</dd>
534<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34535--no-renames
536</dt>
537<dd>
538<p>
539 Turn off rename detection, even when the configuration
540 file gives the default to do so.
541</p>
542</dd>
543<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21544--check
545</dt>
546<dd>
547<p>
548 Warn if changes introduce trailing whitespace
Junio C Hamano3dac5042007-12-15 08:40:54549 or an indent that uses a space before a tab. Exits with
550 non-zero status if problems are found. Not compatible with
551 --exit-code.
Junio C Hamanoa890c4f2007-01-28 10:29:21552</p>
553</dd>
554<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23555--full-index
556</dt>
557<dd>
558<p>
Junio C Hamano5cf43ca2008-08-20 09:14:14559 Instead of the first handful of characters, show the full
560 pre- and post-image blob object names on the "index"
561 line when generating patch format output.
Junio C Hamano1a4e8412005-12-27 08:17:23562</p>
563</dd>
564<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34565--binary
566</dt>
567<dd>
568<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37569 In addition to <tt>--full-index</tt>, output a binary diff that
570 can be applied with <tt>git-apply</tt>.
Junio C Hamano9ae1a062006-07-10 08:12:34571</p>
572</dd>
573<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23574--abbrev[=&lt;n&gt;]
575</dt>
576<dd>
577<p>
578 Instead of showing the full 40-byte hexadecimal object
579 name in diff-raw format output and diff-tree header
Junio C Hamano6efe3022009-01-13 16:47:56580 lines, show only a partial prefix. This is
Junio C Hamano3b70d3c2009-11-21 17:37:37581 independent of the <tt>--full-index</tt> option above, which controls
Junio C Hamano1a4e8412005-12-27 08:17:23582 the diff-patch output format. Non default number of
Junio C Hamano3b70d3c2009-11-21 17:37:37583 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23584</p>
585</dd>
586<dt>
587-B
588</dt>
589<dd>
590<p>
591 Break complete rewrite changes into pairs of delete and create.
592</p>
593</dd>
594<dt>
595-M
596</dt>
597<dd>
598<p>
599 Detect renames.
600</p>
601</dd>
602<dt>
603-C
604</dt>
605<dd>
606<p>
Junio C Hamano16f98872007-06-12 16:09:14607 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23608</p>
609</dd>
610<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01611--diff-filter=[ACDMRTUXB*]
612</dt>
613<dd>
614<p>
615 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
616 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
Junio C Hamanoa2deec52008-10-18 18:58:09617 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
618 are Unmerged (<tt>U</tt>), are
Junio C Hamano6ec31b92006-02-10 05:52:01619 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
620 Any combination of the filter characters may be used.
621 When <tt>*</tt> (All-or-none) is added to the combination, all
622 paths are selected if there is any file that matches
623 other criteria in the comparison; if there is no file
624 that matches other criteria, nothing is selected.
625</p>
626</dd>
627<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23628--find-copies-harder
629</dt>
630<dd>
631<p>
Junio C Hamano16f98872007-06-12 16:09:14632 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano1a4e8412005-12-27 08:17:23633 if the original file of the copy was modified in the same
634 changeset. This flag makes the command
635 inspect unmodified files as candidates for the source of
636 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14637 projects, so use it with caution. Giving more than one
638 <tt>-C</tt> option has the same effect.
Junio C Hamano1a4e8412005-12-27 08:17:23639</p>
640</dd>
641<dt>
642-l&lt;num&gt;
643</dt>
644<dd>
645<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37646 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
Junio C Hamano1a4e8412005-12-27 08:17:23647 is the number of potential rename/copy targets. This
648 option prevents rename/copy detection from running if
649 the number of rename/copy targets exceeds the specified
650 number.
651</p>
652</dd>
653<dt>
654-S&lt;string&gt;
655</dt>
656<dd>
657<p>
Junio C Hamano5217a272009-03-21 00:39:33658 Look for differences that introduce or remove an instance of
659 &lt;string&gt;. Note that this is different than the string simply
660 appearing in diff output; see the <em>pickaxe</em> entry in
661 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
Junio C Hamano1a4e8412005-12-27 08:17:23662</p>
663</dd>
664<dt>
665--pickaxe-all
666</dt>
667<dd>
668<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37669 When <tt>-S</tt> finds a change, show all the changes in that
Junio C Hamano1a4e8412005-12-27 08:17:23670 changeset, not just the files that contain the change
671 in &lt;string&gt;.
672</p>
673</dd>
674<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28675--pickaxe-regex
676</dt>
677<dd>
678<p>
679 Make the &lt;string&gt; not a plain string but an extended POSIX
680 regex to match.
681</p>
682</dd>
683<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23684-O&lt;orderfile&gt;
685</dt>
686<dd>
687<p>
688 Output the patch in the order specified in the
689 &lt;orderfile&gt;, which has one shell glob pattern per line.
690</p>
691</dd>
692<dt>
693-R
694</dt>
695<dd>
696<p>
697 Swap two inputs; that is, show differences from index or
698 on-disk file to tree contents.
699</p>
700</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14701<dt>
Junio C Hamano24bc09a2008-02-28 00:27:44702--relative[=&lt;path&gt;]
703</dt>
704<dd>
705<p>
706 When run from a subdirectory of the project, it can be
707 told to exclude changes outside the directory and show
708 pathnames relative to it with this option. When you are
709 not in a subdirectory (e.g. in a bare repository), you
710 can name which subdirectory to make the output relative
711 to by giving a &lt;path&gt; as an argument.
712</p>
713</dd>
714<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22715-a
716</dt>
717<dt>
Junio C Hamanoc26f5482006-07-09 09:38:14718--text
719</dt>
720<dd>
721<p>
722 Treat all files as text.
723</p>
724</dd>
725<dt>
Junio C Hamanofd468962007-02-14 23:45:04726--ignore-space-at-eol
727</dt>
728<dd>
729<p>
Junio C Hamano3a702342007-12-12 21:34:02730 Ignore changes in whitespace at EOL.
Junio C Hamanofd468962007-02-14 23:45:04731</p>
732</dd>
733<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22734-b
735</dt>
736<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07737--ignore-space-change
738</dt>
739<dd>
740<p>
Junio C Hamano3a702342007-12-12 21:34:02741 Ignore changes in amount of whitespace. This ignores whitespace
742 at line end, and considers all other sequences of one or
743 more whitespace characters to be equivalent.
Junio C Hamanod9c2d2f2006-12-06 08:59:07744</p>
745</dd>
746<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22747-w
Junio C Hamanod9c2d2f2006-12-06 08:59:07748</dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07749<dt>
750--ignore-all-space
751</dt>
752<dd>
753<p>
Junio C Hamano3a702342007-12-12 21:34:02754 Ignore whitespace when comparing lines. This ignores
755 differences even if one line has whitespace where the other
Junio C Hamanod9c2d2f2006-12-06 08:59:07756 line has none.
757</p>
758</dd>
759<dt>
Junio C Hamano1d40ee82009-01-07 10:14:16760--inter-hunk-context=&lt;lines&gt;
761</dt>
762<dd>
763<p>
764 Show the context between diff hunks, up to the specified number
765 of lines, thereby fusing hunks that are close to each other.
766</p>
767</dd>
768<dt>
Junio C Hamano48fd2f62007-03-19 02:02:30769--exit-code
770</dt>
771<dd>
772<p>
773 Make the program exit with codes similar to diff(1).
774 That is, it exits with 1 if there were differences and
775 0 means no differences.
776</p>
777</dd>
Junio C Hamano35e57552007-03-25 07:54:35778<dt>
779--quiet
780</dt>
781<dd>
782<p>
Junio C Hamano3b70d3c2009-11-21 17:37:37783 Disable all output of the program. Implies <tt>--exit-code</tt>.
Junio C Hamano35e57552007-03-25 07:54:35784</p>
785</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40786<dt>
787--ext-diff
788</dt>
789<dd>
790<p>
791 Allow an external diff helper to be executed. If you set an
Junio C Hamano1b50ce92007-10-03 12:05:53792 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
793 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
Junio C Hamanobb0f4042007-07-04 06:41:40794</p>
795</dd>
796<dt>
797--no-ext-diff
798</dt>
799<dd>
800<p>
801 Disallow external diff drivers.
802</p>
803</dd>
Junio C Hamanoe27cbd22007-12-21 17:57:33804<dt>
Junio C Hamanodfccbb02008-05-26 01:16:14805--ignore-submodules
806</dt>
807<dd>
808<p>
809 Ignore changes to submodules in the diff generation.
810</p>
811</dd>
812<dt>
Junio C Hamanoe27cbd22007-12-21 17:57:33813--src-prefix=&lt;prefix&gt;
814</dt>
815<dd>
816<p>
817 Show the given source prefix instead of "a/".
818</p>
819</dd>
820<dt>
821--dst-prefix=&lt;prefix&gt;
822</dt>
823<dd>
824<p>
825 Show the given destination prefix instead of "b/".
826</p>
827</dd>
828<dt>
829--no-prefix
830</dt>
831<dd>
832<p>
833 Do not show any source or destination prefix.
834</p>
835</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31836</dl></div>
837<div class="para"><p>For more detailed explanation on these common options, see also
838<a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
839<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23840<dt>
841&lt;tree-ish&gt;
842</dt>
843<dd>
844<p>
845 The id of a tree object.
846</p>
847</dd>
848<dt>
849&lt;path&gt;&#8230;
850</dt>
851<dd>
852<p>
853 If provided, the results are limited to a subset of files
854 matching one of these prefix strings.
Junio C Hamano341071d2006-06-04 07:24:48855 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
Junio C Hamano1a4e8412005-12-27 08:17:23856 Note that this parameter does not provide any wildcard or regexp
857 features.
858</p>
859</dd>
860<dt>
861-r
862</dt>
863<dd>
864<p>
865 recurse into sub-trees
866</p>
867</dd>
868<dt>
869-t
870</dt>
871<dd>
872<p>
873 show tree entry itself as well as subtrees. Implies -r.
874</p>
875</dd>
876<dt>
877--root
878</dt>
879<dd>
880<p>
Junio C Hamano54bf1e22008-12-20 06:30:11881 When <em>--root</em> is specified the initial commit will be shown as a big
Junio C Hamano1a4e8412005-12-27 08:17:23882 creation event. This is equivalent to a diff against the NULL tree.
883</p>
884</dd>
885<dt>
886--stdin
887</dt>
888<dd>
889<p>
890 When <em>--stdin</em> is specified, the command does not take
891 &lt;tree-ish&gt; arguments from the command line. Instead, it
Junio C Hamano3f2f6e52008-08-21 10:34:22892 reads lines containing either two &lt;tree&gt;, one &lt;commit&gt;, or a
893 list of &lt;commit&gt; from its standard input. (Use a single space
894 as separator.)
Junio C Hamano1a4e8412005-12-27 08:17:23895</p>
Junio C Hamano3f2f6e52008-08-21 10:34:22896<div class="para"><p>When two trees are given, it compares the first tree with the second.
897When a single commit is given, it compares the commit with its
898parents. The remaining commits, when given, are used as if they are
Junio C Hamanob53db3c2008-08-07 00:17:52899parents of the first commit.</p></div>
Junio C Hamano3f2f6e52008-08-21 10:34:22900<div class="para"><p>When comparing two trees, the ID of both trees (separated by a space
901and terminated by a newline) is printed before the difference. When
902comparing commits, the ID of the first (or only) commit, followed by a
903newline, is printed.</p></div>
Junio C Hamano54bf1e22008-12-20 06:30:11904<div class="para"><p>The following flags further affect the behavior when comparing
Junio C Hamano3f2f6e52008-08-21 10:34:22905commits (but not trees).</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23906</dd>
907<dt>
908-m
909</dt>
910<dd>
911<p>
Junio C Hamanoba4b9282008-07-06 05:20:31912 By default, <em>git-diff-tree --stdin</em> does not show
Junio C Hamano1a4e8412005-12-27 08:17:23913 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16914 differences to that commit from all of its parents. See
915 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23916</p>
917</dd>
918<dt>
919-s
920</dt>
921<dd>
922<p>
Junio C Hamanoba4b9282008-07-06 05:20:31923 By default, <em>git-diff-tree --stdin</em> shows differences,
Junio C Hamano1a4e8412005-12-27 08:17:23924 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58925 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23926 only useful with <em>-v</em> flag.
927</p>
928</dd>
929<dt>
930-v
931</dt>
932<dd>
933<p>
Junio C Hamanoba4b9282008-07-06 05:20:31934 This flag causes <em>git-diff-tree --stdin</em> to also show
Junio C Hamano1a4e8412005-12-27 08:17:23935 the commit message before the differences.
936</p>
937</dd>
938<dt>
Junio C Hamanoa340aaa2006-11-23 02:47:33939--pretty[=<em>&lt;format&gt;</em>]
Junio C Hamano1a4e8412005-12-27 08:17:23940</dt>
Junio C Hamano0a235222009-03-06 08:21:09941<dt>
942--format[=<em>&lt;format&gt;</em>]
943</dt>
Junio C Hamano1a4e8412005-12-27 08:17:23944<dd>
945<p>
Junio C Hamanoa3770f92007-07-25 08:53:33946 Pretty-print the contents of the commit logs in a given format,
Junio C Hamano0430e3a2007-05-15 03:13:17947 where <em>&lt;format&gt;</em> can be one of <em>oneline</em>, <em>short</em>, <em>medium</em>,
948 <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:33949 When omitted, the format defaults to <em>medium</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23950</p>
Junio C Hamanoba4b9282008-07-06 05:20:31951<div class="para"><p>Note: you can specify the default pretty format in the repository
952configuration (see <a href="git-config.html">git-config(1)</a>).</p></div>
Junio C Hamano0430e3a2007-05-15 03:13:17953</dd>
954<dt>
Junio C Hamanoee695f22007-06-21 00:35:36955--abbrev-commit
956</dt>
957<dd>
958<p>
959 Instead of showing the full 40-byte hexadecimal commit object
Junio C Hamano6efe3022009-01-13 16:47:56960 name, show only a partial prefix. Non default number of
Junio C Hamanoee695f22007-06-21 00:35:36961 digits can be specified with "--abbrev=&lt;n&gt;" (which also modifies
962 diff output, if it is displayed).
963</p>
Junio C Hamanoba4b9282008-07-06 05:20:31964<div class="para"><p>This should make "--pretty=oneline" a whole lot more readable for
965people using 80-column terminals.</p></div>
Junio C Hamanoee695f22007-06-21 00:35:36966</dd>
967<dt>
Junio C Hamano0a235222009-03-06 08:21:09968--oneline
969</dt>
970<dd>
971<p>
972 This is a shorthand for "--pretty=oneline --abbrev-commit"
973 used together.
974</p>
975</dd>
976<dt>
Junio C Hamano0430e3a2007-05-15 03:13:17977--encoding[=&lt;encoding&gt;]
978</dt>
979<dd>
980<p>
981 The commit objects record the encoding used for the log message
982 in their encoding header; this option can be used to tell the
983 command to re-code the commit log message in the encoding
984 preferred by the user. For non plumbing commands this
985 defaults to UTF-8.
986</p>
987</dd>
988<dt>
989--no-commit-id
990</dt>
991<dd>
992<p>
Junio C Hamanoba4b9282008-07-06 05:20:31993 <em>git-diff-tree</em> outputs a line with the commit ID when
Junio C Hamano0430e3a2007-05-15 03:13:17994 applicable. This flag suppressed the commit ID output.
995</p>
996</dd>
997<dt>
998-c
999</dt>
1000<dd>
1001<p>
1002 This flag changes the way a merge commit is displayed
1003 (which means it is useful only when the command is given
1004 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
1005 from each of the parents to the merge result simultaneously
1006 instead of showing pairwise diff between a parent and the
1007 result one at a time (which is what the <em>-m</em> option does).
1008 Furthermore, it lists only files which were modified
1009 from all parents.
1010</p>
1011</dd>
1012<dt>
1013--cc
1014</dt>
1015<dd>
1016<p>
1017 This flag changes the way a merge commit patch is displayed,
1018 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
1019 and <em>-p</em> options and further compresses the patch output
Junio C Hamanoccc2f762008-07-24 04:03:331020 by omitting uninteresting hunks whose the contents in the parents
1021 have only two variants and the merge result picks one of them
1022 without modification. When all hunks are uninteresting, the commit
1023 itself and the commit log message is not shown, just like in any other
1024 "empty diff" case.
Junio C Hamano0430e3a2007-05-15 03:13:171025</p>
1026</dd>
1027<dt>
1028--always
1029</dt>
1030<dd>
1031<p>
1032 Show the commit itself and the commit log message even
1033 if the diff itself is empty.
1034</p>
1035</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311036</dl></div>
Junio C Hamano0430e3a2007-05-15 03:13:171037</div>
Junio C Hamanoba4b9282008-07-06 05:20:311038<h2 id="_pretty_formats">PRETTY FORMATS</h2>
Junio C Hamano0430e3a2007-05-15 03:13:171039<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311040<div class="para"><p>If the commit is a merge, and if the pretty-format
Junio C Hamano0430e3a2007-05-15 03:13:171041is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
1042inserted before the <em>Author:</em> line. This line begins with
1043"Merge: " and the sha1s of ancestral commits are printed,
1044separated by spaces. Note that the listed commits may not
1045necessarily be the list of the <strong>direct</strong> parent commits if you
1046have limited your view of history: for example, if you are
1047only interested in changes related to a certain directory or
Junio C Hamanoba4b9282008-07-06 05:20:311048file.</p></div>
1049<div class="para"><p>Here are some additional details for each format:</p></div>
1050<div class="ilist"><ul>
Junio C Hamanoa340aaa2006-11-23 02:47:331051<li>
1052<p>
1053<em>oneline</em>
1054</p>
1055<div class="literalblock">
1056<div class="content">
1057<pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
1058</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311059<div class="para"><p>This is designed to be as compact as possible.</p></div>
Junio C Hamanoa340aaa2006-11-23 02:47:331060</li>
1061<li>
1062<p>
1063<em>short</em>
1064</p>
1065<div class="literalblock">
1066<div class="content">
1067<pre><tt>commit &lt;sha1&gt;
1068Author: &lt;author&gt;</tt></pre>
1069</div></div>
1070<div class="literalblock">
1071<div class="content">
1072<pre><tt>&lt;title line&gt;</tt></pre>
1073</div></div>
1074</li>
1075<li>
1076<p>
1077<em>medium</em>
1078</p>
1079<div class="literalblock">
1080<div class="content">
1081<pre><tt>commit &lt;sha1&gt;
1082Author: &lt;author&gt;
Junio C Hamano6a3c8272008-12-19 21:38:181083Date: &lt;author date&gt;</tt></pre>
Junio C Hamanoa340aaa2006-11-23 02:47:331084</div></div>
1085<div class="literalblock">
1086<div class="content">
1087<pre><tt>&lt;title line&gt;</tt></pre>
1088</div></div>
1089<div class="literalblock">
1090<div class="content">
1091<pre><tt>&lt;full commit message&gt;</tt></pre>
1092</div></div>
1093</li>
1094<li>
1095<p>
1096<em>full</em>
1097</p>
1098<div class="literalblock">
1099<div class="content">
1100<pre><tt>commit &lt;sha1&gt;
1101Author: &lt;author&gt;
1102Commit: &lt;committer&gt;</tt></pre>
1103</div></div>
1104<div class="literalblock">
1105<div class="content">
1106<pre><tt>&lt;title line&gt;</tt></pre>
1107</div></div>
1108<div class="literalblock">
1109<div class="content">
1110<pre><tt>&lt;full commit message&gt;</tt></pre>
1111</div></div>
1112</li>
1113<li>
1114<p>
1115<em>fuller</em>
1116</p>
1117<div class="literalblock">
1118<div class="content">
1119<pre><tt>commit &lt;sha1&gt;
Junio C Hamano6a3c8272008-12-19 21:38:181120Author: &lt;author&gt;
Junio C Hamanoba4b9282008-07-06 05:20:311121AuthorDate: &lt;author date&gt;
Junio C Hamano6a3c8272008-12-19 21:38:181122Commit: &lt;committer&gt;
Junio C Hamanoba4b9282008-07-06 05:20:311123CommitDate: &lt;committer date&gt;</tt></pre>
Junio C Hamanoa340aaa2006-11-23 02:47:331124</div></div>
1125<div class="literalblock">
1126<div class="content">
1127<pre><tt>&lt;title line&gt;</tt></pre>
1128</div></div>
1129<div class="literalblock">
1130<div class="content">
1131<pre><tt>&lt;full commit message&gt;</tt></pre>
1132</div></div>
1133</li>
1134<li>
1135<p>
1136<em>email</em>
1137</p>
1138<div class="literalblock">
1139<div class="content">
1140<pre><tt>From &lt;sha1&gt; &lt;date&gt;
1141From: &lt;author&gt;
Junio C Hamanoba4b9282008-07-06 05:20:311142Date: &lt;author date&gt;
Junio C Hamanoa340aaa2006-11-23 02:47:331143Subject: [PATCH] &lt;title line&gt;</tt></pre>
1144</div></div>
1145<div class="literalblock">
1146<div class="content">
Junio C Hamano0430e3a2007-05-15 03:13:171147<pre><tt>&lt;full commit message&gt;</tt></pre>
Junio C Hamanoa340aaa2006-11-23 02:47:331148</div></div>
1149</li>
1150<li>
1151<p>
1152<em>raw</em>
1153</p>
Junio C Hamanoba4b9282008-07-06 05:20:311154<div class="para"><p>The <em>raw</em> format shows the entire commit exactly as
Junio C Hamanoa340aaa2006-11-23 02:47:331155stored in the commit object. Notably, the SHA1s are
1156displayed in full, regardless of whether --abbrev or
1157--no-abbrev are used, and <em>parents</em> information show the
1158true parent commits, without taking grafts nor history
Junio C Hamanoba4b9282008-07-06 05:20:311159simplification into account.</p></div>
Junio C Hamanoa340aaa2006-11-23 02:47:331160</li>
Junio C Hamanoa3fd83c2007-03-02 10:34:361161<li>
1162<p>
1163<em>format:</em>
1164</p>
Junio C Hamanoba4b9282008-07-06 05:20:311165<div class="para"><p>The <em>format:</em> format allows you to specify which information
Junio C Hamanoa3fd83c2007-03-02 10:34:361166you want to show. It works a little bit like printf format,
1167with the notable exception that you get a newline with <em>%n</em>
Junio C Hamanoba4b9282008-07-06 05:20:311168instead of <em>\n</em>.</p></div>
1169<div class="para"><p>E.g, <em>format:"The author of %h was %an, %ar%nThe title was &gt;&gt;%s&lt;&lt;%n"</em>
1170would show something like this:</p></div>
Junio C Hamano0430e3a2007-05-15 03:13:171171<div class="listingblock">
1172<div class="content">
1173<pre><tt>The author of fe6e0ee was Junio C Hamano, 23 hours ago
1174The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;
1175</tt></pre>
1176</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311177<div class="para"><p>The placeholders are:</p></div>
1178<div class="ilist"><ul>
Junio C Hamanoa3fd83c2007-03-02 10:34:361179<li>
1180<p>
1181<em>%H</em>: commit hash
1182</p>
1183</li>
1184<li>
1185<p>
1186<em>%h</em>: abbreviated commit hash
1187</p>
1188</li>
1189<li>
1190<p>
1191<em>%T</em>: tree hash
1192</p>
1193</li>
1194<li>
1195<p>
1196<em>%t</em>: abbreviated tree hash
1197</p>
1198</li>
1199<li>
1200<p>
1201<em>%P</em>: parent hashes
1202</p>
1203</li>
1204<li>
1205<p>
1206<em>%p</em>: abbreviated parent hashes
1207</p>
1208</li>
1209<li>
1210<p>
1211<em>%an</em>: author name
1212</p>
1213</li>
1214<li>
1215<p>
Junio C Hamano8bc410e2009-02-15 10:38:191216<em>%aN</em>: author name (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
Junio C Hamanof5a93622008-07-16 03:23:571217</p>
1218</li>
1219<li>
1220<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361221<em>%ae</em>: author email
1222</p>
1223</li>
1224<li>
1225<p>
Junio C Hamano8bc410e2009-02-15 10:38:191226<em>%aE</em>: author email (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
1227</p>
1228</li>
1229<li>
1230<p>
Junio C Hamanoa387df32008-08-29 08:56:581231<em>%ad</em>: author date (format respects --date= option)
Junio C Hamanoa3fd83c2007-03-02 10:34:361232</p>
1233</li>
1234<li>
1235<p>
1236<em>%aD</em>: author date, RFC2822 style
1237</p>
1238</li>
1239<li>
1240<p>
1241<em>%ar</em>: author date, relative
1242</p>
1243</li>
1244<li>
1245<p>
1246<em>%at</em>: author date, UNIX timestamp
1247</p>
1248</li>
1249<li>
1250<p>
Junio C Hamano02f130b2007-07-14 08:26:561251<em>%ai</em>: author date, ISO 8601 format
1252</p>
1253</li>
1254<li>
1255<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361256<em>%cn</em>: committer name
1257</p>
1258</li>
1259<li>
1260<p>
Junio C Hamano8bc410e2009-02-15 10:38:191261<em>%cN</em>: committer name (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
Junio C Hamanof5a93622008-07-16 03:23:571262</p>
1263</li>
1264<li>
1265<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361266<em>%ce</em>: committer email
1267</p>
1268</li>
1269<li>
1270<p>
Junio C Hamano8bc410e2009-02-15 10:38:191271<em>%cE</em>: committer email (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
1272</p>
1273</li>
1274<li>
1275<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361276<em>%cd</em>: committer date
1277</p>
1278</li>
1279<li>
1280<p>
1281<em>%cD</em>: committer date, RFC2822 style
1282</p>
1283</li>
1284<li>
1285<p>
1286<em>%cr</em>: committer date, relative
1287</p>
1288</li>
1289<li>
1290<p>
1291<em>%ct</em>: committer date, UNIX timestamp
1292</p>
1293</li>
1294<li>
1295<p>
Junio C Hamano02f130b2007-07-14 08:26:561296<em>%ci</em>: committer date, ISO 8601 format
1297</p>
1298</li>
1299<li>
1300<p>
Junio C Hamano5e4d8de2008-09-19 06:27:021301<em>%d</em>: ref names, like the --decorate option of <a href="git-log.html">git-log(1)</a>
1302</p>
1303</li>
1304<li>
1305<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361306<em>%e</em>: encoding
1307</p>
1308</li>
1309<li>
1310<p>
1311<em>%s</em>: subject
1312</p>
1313</li>
1314<li>
1315<p>
Junio C Hamano5f9a6f02009-04-06 08:26:561316<em>%f</em>: sanitized subject line, suitable for a filename
1317</p>
1318</li>
1319<li>
1320<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361321<em>%b</em>: body
1322</p>
1323</li>
1324<li>
1325<p>
Junio C Hamano3b70d3c2009-11-21 17:37:371326<em>%N</em>: commit notes
1327</p>
1328</li>
1329<li>
1330<p>
Junio C Hamanoc21ab052009-10-31 04:03:551331<em>%gD</em>: reflog selector, e.g., <tt>refs/stash@{1}</tt>
1332</p>
1333</li>
1334<li>
1335<p>
1336<em>%gd</em>: shortened reflog selector, e.g., <tt>stash@{1}</tt>
1337</p>
1338</li>
1339<li>
1340<p>
1341<em>%gs</em>: reflog subject
1342</p>
1343</li>
1344<li>
1345<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361346<em>%Cred</em>: switch color to red
1347</p>
1348</li>
1349<li>
1350<p>
1351<em>%Cgreen</em>: switch color to green
1352</p>
1353</li>
1354<li>
1355<p>
1356<em>%Cblue</em>: switch color to blue
1357</p>
1358</li>
1359<li>
1360<p>
1361<em>%Creset</em>: reset color
1362</p>
1363</li>
1364<li>
1365<p>
Junio C Hamanocc0cb312009-01-22 03:38:501366<em>%C(&#8230;)</em>: color specification, as described in color.branch.* config option
1367</p>
1368</li>
1369<li>
1370<p>
Junio C Hamanod9e0e5d2007-04-14 16:22:041371<em>%m</em>: left, right or boundary mark
1372</p>
1373</li>
1374<li>
1375<p>
Junio C Hamanoa3fd83c2007-03-02 10:34:361376<em>%n</em>: newline
1377</p>
Junio C Hamano0430e3a2007-05-15 03:13:171378</li>
Junio C Hamanob78d2592008-04-09 09:39:081379<li>
1380<p>
1381<em>%x00</em>: print a byte from a hex code
1382</p>
1383</li>
Junio C Hamanoba4b9282008-07-06 05:20:311384</ul></div>
Junio C Hamanoa3fd83c2007-03-02 10:34:361385</li>
Junio C Hamanoc21ab052009-10-31 04:03:551386</ul></div>
1387<div class="admonitionblock">
1388<table><tr>
1389<td class="icon">
1390<div class="title">Note</div>
1391</td>
1392<td class="content">Some placeholders may depend on other options given to the
1393revision traversal engine. For example, the <tt>%g*</tt> reflog options will
1394insert an empty string unless we are traversing reflog entries (e.g., by
1395<tt>git log -g</tt>). The <tt>%d</tt> placeholder will use the "short" decoration
1396format if <tt>--decorate</tt> was not already provided on the command line.</td>
1397</tr></table>
1398</div>
1399<div class="ilist"><ul>
Junio C Hamano6fb124c2008-06-13 10:04:011400<li>
1401<p>
1402<em>tformat:</em>
1403</p>
Junio C Hamanoba4b9282008-07-06 05:20:311404<div class="para"><p>The <em>tformat:</em> format works exactly like <em>format:</em>, except that it
Junio C Hamano6fb124c2008-06-13 10:04:011405provides "terminator" semantics instead of "separator" semantics. In
1406other words, each commit has the message terminator character (usually a
1407newline) appended, rather than a separator placed between entries.
1408This means that the final entry of a single-line format will be properly
1409terminated with a new line, just as the "oneline" format does.
Junio C Hamanoba4b9282008-07-06 05:20:311410For example:</p></div>
Junio C Hamano6fb124c2008-06-13 10:04:011411<div class="listingblock">
1412<div class="content">
1413<pre><tt>$ git log -2 --pretty=format:%h 4da45bef \
1414 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
14154da45be
14167134973 -- NO NEWLINE
1417
1418$ git log -2 --pretty=tformat:%h 4da45bef \
1419 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
14204da45be
14217134973</tt></pre>
1422</div></div>
Junio C Hamano0a235222009-03-06 08:21:091423<div class="para"><p>In addition, any unrecognized string that has a <tt>%</tt> in it is interpreted
1424as if it has <tt>tformat:</tt> in front of it. For example, these two are
1425equivalent:</p></div>
1426<div class="listingblock">
1427<div class="content">
1428<pre><tt>$ git log -2 --pretty=tformat:%h 4da45bef
1429$ git log -2 --pretty=%h 4da45bef</tt></pre>
1430</div></div>
Junio C Hamano6fb124c2008-06-13 10:04:011431</li>
Junio C Hamanoba4b9282008-07-06 05:20:311432</ul></div>
Junio C Hamano1a4e8412005-12-27 08:17:231433</div>
Junio C Hamanoba4b9282008-07-06 05:20:311434<h2 id="_limiting_output">Limiting Output</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231435<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311436<div class="para"><p>If you're only interested in differences in a subset of files, for
1437example some architecture-specific files, you might do:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231438<div class="literalblock">
1439<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:381440<pre><tt>git diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231441</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311442<div class="para"><p>and it will only show you what changed in those two directories.</p></div>
1443<div class="para"><p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231444<div class="literalblock">
1445<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:381446<pre><tt>git diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231447</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311448<div class="para"><p>and it will ignore all differences to other files.</p></div>
1449<div class="para"><p>The pattern is always the prefix, and is matched exactly. There are no
Junio C Hamano1a4e8412005-12-27 08:17:231450wildcards. Even stricter, it has to match a complete path component.
1451I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
Junio C Hamanoba4b9282008-07-06 05:20:311452so it can be used to name subdirectories.</p></div>
1453<div class="para"><p>An example of normal usage is:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231454<div class="literalblock">
1455<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:381456<pre><tt>torvalds@ppc970:~/git&gt; git diff-tree 5319e4......
Junio C Hamano1a4e8412005-12-27 08:17:231457*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
1458</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311459<div class="para"><p>which tells you that the last commit changed just one file (it's from
1460this one:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231461<div class="listingblock">
1462<div class="content">
1463<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1464tree 5319e4d609cdd282069cc4dce33c1db559539b03
1465parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1466author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1467committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1468
1469Make "git-fsck-objects" print out all the root commits it finds.
1470
1471Once I do the reference tracking, I'll also make it print out all the
1472HEAD commits it finds, which is even more interesting.</tt></pre>
1473</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311474<div class="para"><p>in case you care).</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231475</div>
Junio C Hamano543f8d62009-07-29 08:35:211476<h2 id="_raw_output_format">Raw output format</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231477<div class="sectionbody">
Junio C Hamano543f8d62009-07-29 08:35:211478<div class="para"><p>The raw output format from "git-diff-index", "git-diff-tree",
Junio C Hamanoba4b9282008-07-06 05:20:311479"git-diff-files" and "git diff --raw" are very similar.</p></div>
1480<div class="para"><p>These commands all compare two sets of things; what is
1481compared differs:</p></div>
1482<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:231483<dt>
1484git-diff-index &lt;tree-ish&gt;
1485</dt>
1486<dd>
1487<p>
1488 compares the &lt;tree-ish&gt; and the files on the filesystem.
1489</p>
1490</dd>
1491<dt>
1492git-diff-index --cached &lt;tree-ish&gt;
1493</dt>
1494<dd>
1495<p>
1496 compares the &lt;tree-ish&gt; and the index.
1497</p>
1498</dd>
1499<dt>
1500git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1501</dt>
1502<dd>
1503<p>
1504 compares the trees named by the two arguments.
1505</p>
1506</dd>
1507<dt>
1508git-diff-files [&lt;pattern&gt;&#8230;]
1509</dt>
1510<dd>
1511<p>
1512 compares the index and the files on the filesystem.
1513</p>
1514</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311515</dl></div>
Junio C Hamano543f8d62009-07-29 08:35:211516<div class="para"><p>The "git-diff-tree" command begins its ouput by printing the hash of
1517what is being compared. After that, all the commands print one output
1518line per changed file.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311519<div class="para"><p>An output line is formatted this way:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231520<div class="listingblock">
1521<div class="content">
1522<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1523copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1524rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1525create :000000 100644 0000000... 1234567... A file4
1526delete :100644 000000 1234567... 0000000... D file5
1527unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1528</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311529<div class="para"><p>That is, from the left to the right:</p></div>
1530<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:231531<li>
1532<p>
1533a colon.
1534</p>
1535</li>
1536<li>
1537<p>
1538mode for "src"; 000000 if creation or unmerged.
1539</p>
1540</li>
1541<li>
1542<p>
1543a space.
1544</p>
1545</li>
1546<li>
1547<p>
1548mode for "dst"; 000000 if deletion or unmerged.
1549</p>
1550</li>
1551<li>
1552<p>
1553a space.
1554</p>
1555</li>
1556<li>
1557<p>
1558sha1 for "src"; 0{40} if creation or unmerged.
1559</p>
1560</li>
1561<li>
1562<p>
1563a space.
1564</p>
1565</li>
1566<li>
1567<p>
1568sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1569</p>
1570</li>
1571<li>
1572<p>
1573a space.
1574</p>
1575</li>
1576<li>
1577<p>
1578status, followed by optional "score" number.
1579</p>
1580</li>
1581<li>
1582<p>
1583a tab or a NUL when <em>-z</em> option is used.
1584</p>
1585</li>
1586<li>
1587<p>
1588path for "src"
1589</p>
1590</li>
1591<li>
1592<p>
1593a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1594</p>
1595</li>
1596<li>
1597<p>
1598path for "dst"; only exists for C or R.
1599</p>
1600</li>
1601<li>
1602<p>
1603an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1604</p>
1605</li>
Junio C Hamanoba4b9282008-07-06 05:20:311606</ol></div>
Junio C Hamanoaa17c7c2008-11-03 04:36:581607<div class="para"><p>Possible status letters are:</p></div>
1608<div class="ilist"><ul>
1609<li>
1610<p>
1611A: addition of a file
1612</p>
1613</li>
1614<li>
1615<p>
1616C: copy of a file into a new one
1617</p>
1618</li>
1619<li>
1620<p>
1621D: deletion of a file
1622</p>
1623</li>
1624<li>
1625<p>
1626M: modification of the contents or mode of a file
1627</p>
1628</li>
1629<li>
1630<p>
1631R: renaming of a file
1632</p>
1633</li>
1634<li>
1635<p>
1636T: change in the type of the file
1637</p>
1638</li>
1639<li>
1640<p>
1641U: file is unmerged (you must complete the merge before it can
1642be committed)
1643</p>
1644</li>
1645<li>
1646<p>
1647X: "unknown" change type (most probably a bug, please report it)
1648</p>
1649</li>
1650</ul></div>
Junio C Hamano54bf1e22008-12-20 06:30:111651<div class="para"><p>Status letters C and R are always followed by a score (denoting the
Junio C Hamanoaa17c7c2008-11-03 04:36:581652percentage of similarity between the source and target of the move or
1653copy), and are the only ones to be so.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311654<div class="para"><p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1655and it is out of sync with the index.</p></div>
1656<div class="para"><p>Example:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231657<div class="listingblock">
1658<div class="content">
1659<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1660</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311661<div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
Junio C Hamano1a4e8412005-12-27 08:17:231662in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
Junio C Hamanoba4b9282008-07-06 05:20:311663respectively.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231664</div>
Junio C Hamanoba4b9282008-07-06 05:20:311665<h2 id="_diff_format_for_merges">diff format for merges</h2>
Junio C Hamano67fad6d2007-05-06 08:53:121666<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311667<div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
Junio C Hamano7ae0ab22007-11-03 02:46:461668can take <em>-c</em> or <em>--cc</em> option
Junio C Hamano67fad6d2007-05-06 08:53:121669to generate diff output also for merge commits. The output differs
Junio C Hamanoba4b9282008-07-06 05:20:311670from the format described above in the following way:</p></div>
1671<div class="olist"><ol>
Junio C Hamano67fad6d2007-05-06 08:53:121672<li>
1673<p>
1674there is a colon for each parent
1675</p>
1676</li>
1677<li>
1678<p>
1679there are more "src" modes and "src" sha1
1680</p>
1681</li>
1682<li>
1683<p>
1684status is concatenated status characters for each parent
1685</p>
1686</li>
1687<li>
1688<p>
1689no optional "score" number
1690</p>
1691</li>
1692<li>
1693<p>
1694single path, only for "dst"
1695</p>
1696</li>
Junio C Hamanoba4b9282008-07-06 05:20:311697</ol></div>
1698<div class="para"><p>Example:</p></div>
Junio C Hamano67fad6d2007-05-06 08:53:121699<div class="listingblock">
1700<div class="content">
1701<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1702</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311703<div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from
1704all parents.</p></div>
Junio C Hamano67fad6d2007-05-06 08:53:121705</div>
Junio C Hamanoba4b9282008-07-06 05:20:311706<h2 id="_generating_patches_with_p">Generating patches with -p</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231707<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311708<div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
Junio C Hamano00b8b632007-12-07 09:50:491709with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1710"git log" with the "-p" option, they
Junio C Hamano7ae0ab22007-11-03 02:46:461711do not produce the output described above; instead they produce a
1712patch file. You can customize the creation of such patches via the
Junio C Hamanoba4b9282008-07-06 05:20:311713GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1714<div class="para"><p>What the -p option produces is slightly different from the traditional
1715diff format.</p></div>
1716<div class="olist"><ol>
Junio C Hamano1a4e8412005-12-27 08:17:231717<li>
1718<p>
Junio C Hamano235a91e2006-01-07 01:13:581719It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:231720 this:
1721</p>
1722<div class="literalblock">
1723<div class="content">
1724<pre><tt>diff --git a/file1 b/file2</tt></pre>
1725</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311726<div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
Junio C Hamano1a4e8412005-12-27 08:17:231727involved. Especially, even for a creation or a deletion,
Junio C Hamanoe1b26832009-11-15 10:02:561728<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311729<div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
Junio C Hamano1a4e8412005-12-27 08:17:231730name of the source file of the rename/copy and the name of
Junio C Hamanoba4b9282008-07-06 05:20:311731the file that rename/copy produces, respectively.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231732</li>
1733<li>
1734<p>
1735It is followed by one or more extended header lines:
1736</p>
1737<div class="literalblock">
1738<div class="content">
1739<pre><tt>old mode &lt;mode&gt;
1740new mode &lt;mode&gt;
1741deleted file mode &lt;mode&gt;
1742new file mode &lt;mode&gt;
1743copy from &lt;path&gt;
1744copy to &lt;path&gt;
1745rename from &lt;path&gt;
1746rename to &lt;path&gt;
1747similarity index &lt;number&gt;
1748dissimilarity index &lt;number&gt;
1749index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1750</div></div>
1751</li>
1752<li>
1753<p>
Junio C Hamanoa053d542006-10-27 09:29:131754TAB, LF, double quote and backslash characters in pathnames
1755 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1756 If there is need for such substitution then the whole
1757 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:231758</p>
1759</li>
Junio C Hamanoba4b9282008-07-06 05:20:311760</ol></div>
1761<div class="para"><p>The similarity index is the percentage of unchanged lines, and
Junio C Hamanod526ba92007-07-02 00:17:421762the dissimilarity index is the percentage of changed lines. It
1763is a rounded down integer, followed by a percent sign. The
1764similarity index value of 100% is thus reserved for two equal
1765files, while 100% dissimilarity means that no line from the old
Junio C Hamanoba4b9282008-07-06 05:20:311766file made it into the new one.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231767</div>
Junio C Hamanoba4b9282008-07-06 05:20:311768<h2 id="_combined_diff_format">combined diff format</h2>
Junio C Hamanofb56a962006-01-28 10:38:191769<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311770<div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
Junio C Hamano00b8b632007-12-07 09:50:491771<em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1772with "git log -p", this is the default format.
Junio C Hamanoba4b9282008-07-06 05:20:311773A <em>combined diff</em> format looks like this:</p></div>
Junio C Hamanofb56a962006-01-28 10:38:191774<div class="listingblock">
1775<div class="content">
1776<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:291777index fabadb8,cc95eb0..4866510
1778--- a/describe.c
1779+++ b/describe.c
1780@@@ -98,20 -98,12 +98,20 @@@
1781 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:191782 }
1783
1784- static void describe(char *arg)
1785 -static void describe(struct commit *cmit, int last_one)
1786++static void describe(char *arg, int last_one)
1787 {
Junio C Hamano29f14312006-10-26 08:47:291788 + unsigned char sha1[20];
1789 + struct commit *cmit;
1790 struct commit_list *list;
1791 static int initialized = 0;
1792 struct commit_name *n;
1793
1794 + if (get_sha1(arg, sha1) &lt; 0)
1795 + usage(describe_usage);
1796 + cmit = lookup_commit_reference(sha1);
1797 + if (!cmit)
1798 + usage(describe_usage);
1799 +
1800 if (!initialized) {
1801 initialized = 1;
1802 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:191803</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311804<div class="olist"><ol>
Junio C Hamano29f14312006-10-26 08:47:291805<li>
1806<p>
1807It is preceded with a "git diff" header, that looks like
1808 this (when <em>-c</em> option is used):
1809</p>
1810<div class="literalblock">
1811<div class="content">
1812<pre><tt>diff --combined file</tt></pre>
1813</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311814<div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div>
Junio C Hamano29f14312006-10-26 08:47:291815<div class="literalblock">
1816<div class="content">
Junio C Hamano0868a302008-07-22 09:20:441817<pre><tt>diff --cc file</tt></pre>
Junio C Hamano29f14312006-10-26 08:47:291818</div></div>
1819</li>
1820<li>
1821<p>
1822It is followed by one or more extended header lines
1823 (this example shows a merge with two parents):
1824</p>
1825<div class="literalblock">
1826<div class="content">
1827<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1828mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1829new file mode &lt;mode&gt;
1830deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1831</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311832<div class="para"><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:041833the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291834information about detected contents movement (renames and
1835copying detection) are designed to work with diff of two
Junio C Hamanoba4b9282008-07-06 05:20:311836&lt;tree-ish&gt; and are not used by combined diff format.</p></div>
Junio C Hamano29f14312006-10-26 08:47:291837</li>
1838<li>
1839<p>
1840It is followed by two-line from-file/to-file header
1841</p>
1842<div class="literalblock">
1843<div class="content">
1844<pre><tt>--- a/file
1845+++ b/file</tt></pre>
1846</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311847<div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff
Junio C Hamano29f14312006-10-26 08:47:291848format, <tt>/dev/null</tt> is used to signal created or deleted
Junio C Hamanoba4b9282008-07-06 05:20:311849files.</p></div>
Junio C Hamano29f14312006-10-26 08:47:291850</li>
1851<li>
1852<p>
1853Chunk header format is modified to prevent people from
1854 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1855 was created for review of merge commit changes, and was not
1856 meant for apply. The change is similar to the change in the
1857 extended <em>index</em> header:
1858</p>
1859<div class="literalblock">
1860<div class="content">
1861<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1862</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311863<div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1864header for combined diff format.</p></div>
Junio C Hamano29f14312006-10-26 08:47:291865</li>
Junio C Hamanoba4b9282008-07-06 05:20:311866</ol></div>
1867<div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two
Junio C Hamanofb56a962006-01-28 10:38:191868files A and B with a single column that has <tt>-</tt> (minus &#8212;
1869appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291870added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191871compares two or more files file1, file2,&#8230; with one file X, and
1872shows how X differs from each of fileN. One column for each of
1873fileN is prepended to the output line to note how X's line is
Junio C Hamanoba4b9282008-07-06 05:20:311874different from it.</p></div>
1875<div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291876fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamano54bf1e22008-12-20 06:30:111877in the column N means that the line appears in the result,
Junio C Hamano29f14312006-10-26 08:47:291878and fileN does not have that line (in other words, the line was
Junio C Hamanoba4b9282008-07-06 05:20:311879added, from the point of view of that parent).</p></div>
1880<div class="para"><p>In the above example output, the function signature was changed
Junio C Hamanofb56a962006-01-28 10:38:191881from both files (hence two <tt>-</tt> removals from both file1 and
Junio C Hamano5e4d8de2008-09-19 06:27:021882file2, plus <tt>++</tt> to mean one line that was added does not appear
Junio C Hamano54bf1e22008-12-20 06:30:111883in either file1 nor file2). Also eight other lines are the same
1884from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:311885<div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
Junio C Hamanofb56a962006-01-28 10:38:191886merge commit with the merge result (i.e. file1..fileN are the
1887parents). When shown by <tt>git diff-files -c</tt>, it compares the
1888two unresolved merge parents with the working tree file
1889(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
Junio C Hamanoba4b9282008-07-06 05:20:311890"their version").</p></div>
Junio C Hamanofb56a962006-01-28 10:38:191891</div>
Junio C Hamanoba4b9282008-07-06 05:20:311892<h2 id="_other_diff_formats">other diff formats</h2>
Junio C Hamano3a702342007-12-12 21:34:021893<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311894<div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
Junio C Hamano3a702342007-12-12 21:34:021895copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1896output. These options can be combined with other options, such as
Junio C Hamanoba4b9282008-07-06 05:20:311897<tt>-p</tt>, and are meant for human consumption.</p></div>
1898<div class="para"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
Junio C Hamano3a702342007-12-12 21:34:021899formats the pathnames compactly by combining common prefix and suffix of
1900the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
Junio C Hamanoba4b9282008-07-06 05:20:311901<tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021902<div class="listingblock">
1903<div class="content">
1904<pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1905</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311906<div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
Junio C Hamano3a702342007-12-12 21:34:021907for easier machine consumption. An entry in <tt>--numstat</tt> output looks
Junio C Hamanoba4b9282008-07-06 05:20:311908like this:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021909<div class="listingblock">
1910<div class="content">
1911<pre><tt>1 2 README
19123 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1913</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311914<div class="para"><p>That is, from left to right:</p></div>
1915<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021916<li>
1917<p>
1918the number of added lines;
1919</p>
1920</li>
1921<li>
1922<p>
1923a tab;
1924</p>
1925</li>
1926<li>
1927<p>
1928the number of deleted lines;
1929</p>
1930</li>
1931<li>
1932<p>
1933a tab;
1934</p>
1935</li>
1936<li>
1937<p>
1938pathname (possibly with rename/copy information);
1939</p>
1940</li>
1941<li>
1942<p>
1943a newline.
1944</p>
1945</li>
Junio C Hamanoba4b9282008-07-06 05:20:311946</ol></div>
1947<div class="para"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
Junio C Hamano3a702342007-12-12 21:34:021948<div class="listingblock">
1949<div class="content">
1950<pre><tt>1 2 README NUL
19513 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1952</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:311953<div class="para"><p>That is:</p></div>
1954<div class="olist"><ol>
Junio C Hamano3a702342007-12-12 21:34:021955<li>
1956<p>
1957the number of added lines;
1958</p>
1959</li>
1960<li>
1961<p>
1962a tab;
1963</p>
1964</li>
1965<li>
1966<p>
1967the number of deleted lines;
1968</p>
1969</li>
1970<li>
1971<p>
1972a tab;
1973</p>
1974</li>
1975<li>
1976<p>
1977a NUL (only exists if renamed/copied);
1978</p>
1979</li>
1980<li>
1981<p>
1982pathname in preimage;
1983</p>
1984</li>
1985<li>
1986<p>
1987a NUL (only exists if renamed/copied);
1988</p>
1989</li>
1990<li>
1991<p>
1992pathname in postimage (only exists if renamed/copied);
1993</p>
1994</li>
1995<li>
1996<p>
1997a NUL.
1998</p>
1999</li>
Junio C Hamanoba4b9282008-07-06 05:20:312000</ol></div>
2001<div class="para"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
Junio C Hamano3a702342007-12-12 21:34:022002scripts that read the output to tell if the current record being read is
2003a single-path record or a rename/copy record without reading ahead.
2004After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
Junio C Hamanoba4b9282008-07-06 05:20:312005the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
Junio C Hamano3a702342007-12-12 21:34:022006</div>
Junio C Hamanoba4b9282008-07-06 05:20:312007<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:232008<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:312009<div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:232010</div>
Junio C Hamanoba4b9282008-07-06 05:20:312011<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:232012<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:312013<div class="para"><p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:232014</div>
Junio C Hamanoba4b9282008-07-06 05:20:312015<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:232016<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:312017<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:232018</div>
2019<div id="footer">
2020<div id="footer-text">
Junio C Hamano3b70d3c2009-11-21 17:37:372021Last updated 2009-11-21 17:36:54 UTC
Junio C Hamano1a4e8412005-12-27 08:17:232022</div>
2023</div>
2024</body>
2025</html>