blob: bab73a827f5aaf9403876804828fdf8003bbc017 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanod9d71c02006-02-08 00:52:336<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-diff-tree(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff-tree(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff-tree -
269 Compares the content and mode of blobs found via two tree objects
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano235a91e2006-01-07 01:13:58275<div class="verseblock">
Junio C Hamanofb56a962006-01-28 10:38:19276<div class="content"><em>git-diff-tree</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
277 [-t] [-r] [-c | --cc] [--root] [&lt;common diff options&gt;]
278 &lt;tree-ish&gt; [&lt;tree-ish&gt;] [&lt;path&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23279</div>
280<h2>DESCRIPTION</h2>
281<div class="sectionbody">
282<p>Compares the content and mode of the blobs found via two tree objects.</p>
283<p>If there is only one &lt;tree-ish&gt; given, the commit is compared with its parents
284(see --stdin below).</p>
285<p>Note that "git-diff-tree" can use the tree encapsulated in a commit object.</p>
286</div>
287<h2>OPTIONS</h2>
288<div class="sectionbody">
289<dl>
290<dt>
291-p
292</dt>
293<dd>
294<p>
295 Generate patch (see section on generating patches)
296</p>
297</dd>
298<dt>
299-u
300</dt>
301<dd>
302<p>
303 Synonym for "-p".
304</p>
305</dd>
306<dt>
Junio C Hamano54559c82006-04-13 07:45:12307--patch-with-raw
308</dt>
309<dd>
310<p>
311 Generate patch but keep also the default raw diff output.
312</p>
313</dd>
314<dt>
Junio C Hamanoba7c8d82006-04-15 06:17:42315--stat
316</dt>
317<dd>
318<p>
319 Generate a diffstat instead of a patch.
320</p>
321</dd>
322<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11323--summary
324</dt>
325<dd>
326<p>
327 Output a condensed summary of extended header information
328 such as creations, renames and mode changes.
329</p>
330</dd>
331<dt>
Junio C Hamanod1308c92006-04-16 11:01:09332--patch-with-stat
333</dt>
334<dd>
335<p>
336 Generate patch and prepend its diffstat.
337</p>
338</dd>
339<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23340-z
341</dt>
342<dd>
343<p>
344 \0 line termination on output
345</p>
346</dd>
347<dt>
348--name-only
349</dt>
350<dd>
351<p>
352 Show only names of changed files.
353</p>
354</dd>
355<dt>
356--name-status
357</dt>
358<dd>
359<p>
360 Show only names and status of changed files.
361</p>
362</dd>
363<dt>
364--full-index
365</dt>
366<dd>
367<p>
368 Instead of the first handful characters, show full
369 object name of pre- and post-image blob on the "index"
370 line when generating a patch format output.
371</p>
372</dd>
373<dt>
374--abbrev[=&lt;n&gt;]
375</dt>
376<dd>
377<p>
378 Instead of showing the full 40-byte hexadecimal object
379 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58380 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23381 independent of --full-index option above, which controls
382 the diff-patch output format. Non default number of
383 digits can be specified with --abbrev=&lt;n&gt;.
384</p>
385</dd>
386<dt>
387-B
388</dt>
389<dd>
390<p>
391 Break complete rewrite changes into pairs of delete and create.
392</p>
393</dd>
394<dt>
395-M
396</dt>
397<dd>
398<p>
399 Detect renames.
400</p>
401</dd>
402<dt>
403-C
404</dt>
405<dd>
406<p>
407 Detect copies as well as renames.
408</p>
409</dd>
410<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01411--diff-filter=[ACDMRTUXB*]
412</dt>
413<dd>
414<p>
415 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
416 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
417 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
418 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
419 Any combination of the filter characters may be used.
420 When <tt>*</tt> (All-or-none) is added to the combination, all
421 paths are selected if there is any file that matches
422 other criteria in the comparison; if there is no file
423 that matches other criteria, nothing is selected.
424</p>
425</dd>
426<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23427--find-copies-harder
428</dt>
429<dd>
430<p>
431 For performance reasons, by default, -C option finds copies only
432 if the original file of the copy was modified in the same
433 changeset. This flag makes the command
434 inspect unmodified files as candidates for the source of
435 copy. This is a very expensive operation for large
436 projects, so use it with caution.
437</p>
438</dd>
439<dt>
440-l&lt;num&gt;
441</dt>
442<dd>
443<p>
444 -M and -C options require O(n^2) processing time where n
445 is the number of potential rename/copy targets. This
446 option prevents rename/copy detection from running if
447 the number of rename/copy targets exceeds the specified
448 number.
449</p>
450</dd>
451<dt>
452-S&lt;string&gt;
453</dt>
454<dd>
455<p>
456 Look for differences that contain the change in &lt;string&gt;.
457</p>
458</dd>
459<dt>
460--pickaxe-all
461</dt>
462<dd>
463<p>
464 When -S finds a change, show all the changes in that
465 changeset, not just the files that contain the change
466 in &lt;string&gt;.
467</p>
468</dd>
469<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28470--pickaxe-regex
471</dt>
472<dd>
473<p>
474 Make the &lt;string&gt; not a plain string but an extended POSIX
475 regex to match.
476</p>
477</dd>
478<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23479-O&lt;orderfile&gt;
480</dt>
481<dd>
482<p>
483 Output the patch in the order specified in the
484 &lt;orderfile&gt;, which has one shell glob pattern per line.
485</p>
486</dd>
487<dt>
488-R
489</dt>
490<dd>
491<p>
492 Swap two inputs; that is, show differences from index or
493 on-disk file to tree contents.
494</p>
495</dd>
496</dl>
497<p>For more detailed explanation on these common options, see also
498<a href="diffcore.html">diffcore documentation</a>.</p>
499<dl>
500<dt>
501&lt;tree-ish&gt;
502</dt>
503<dd>
504<p>
505 The id of a tree object.
506</p>
507</dd>
508<dt>
509&lt;path&gt;&#8230;
510</dt>
511<dd>
512<p>
513 If provided, the results are limited to a subset of files
514 matching one of these prefix strings.
515 ie file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
516 Note that this parameter does not provide any wildcard or regexp
517 features.
518</p>
519</dd>
520<dt>
521-r
522</dt>
523<dd>
524<p>
525 recurse into sub-trees
526</p>
527</dd>
528<dt>
529-t
530</dt>
531<dd>
532<p>
533 show tree entry itself as well as subtrees. Implies -r.
534</p>
535</dd>
536<dt>
537--root
538</dt>
539<dd>
540<p>
541 When <em>--root</em> is specified the initial commit will be showed as a big
542 creation event. This is equivalent to a diff against the NULL tree.
543</p>
544</dd>
545<dt>
546--stdin
547</dt>
548<dd>
549<p>
550 When <em>--stdin</em> is specified, the command does not take
551 &lt;tree-ish&gt; arguments from the command line. Instead, it
552 reads either one &lt;commit&gt; or a pair of &lt;tree-ish&gt;
553 separated with a single space from its standard input.
554</p>
555<p>When a single commit is given on one line of such input, it compares
556the commit with its parents. The following flags further affects its
557behaviour. This does not apply to the case where two &lt;tree-ish&gt;
558separated with a single space are given.</p>
559</dd>
560<dt>
561-m
562</dt>
563<dd>
564<p>
565 By default, "git-diff-tree --stdin" does not show
566 differences for merge commits. With this flag, it shows
Junio C Hamanoa8adb1e2006-04-10 23:46:16567 differences to that commit from all of its parents. See
568 also <em>-c</em>.
Junio C Hamano1a4e8412005-12-27 08:17:23569</p>
570</dd>
571<dt>
572-s
573</dt>
574<dd>
575<p>
576 By default, "git-diff-tree --stdin" shows differences,
577 either in machine-readable form (without <em>-p</em>) or in patch
Junio C Hamano235a91e2006-01-07 01:13:58578 form (with <em>-p</em>). This output can be suppressed. It is
Junio C Hamano1a4e8412005-12-27 08:17:23579 only useful with <em>-v</em> flag.
580</p>
581</dd>
582<dt>
583-v
584</dt>
585<dd>
586<p>
587 This flag causes "git-diff-tree --stdin" to also show
588 the commit message before the differences.
589</p>
590</dd>
591<dt>
592--pretty[=(raw|medium|short)]
593</dt>
594<dd>
595<p>
596 This is used to control "pretty printing" format of the
597 commit message. Without "=&lt;style&gt;", it defaults to
598 medium.
599</p>
600</dd>
601<dt>
602--no-commit-id
603</dt>
604<dd>
605<p>
606 git-diff-tree outputs a line with the commit ID when
607 applicable. This flag suppressed the commit ID output.
608</p>
609</dd>
Junio C Hamanofb56a962006-01-28 10:38:19610<dt>
Junio C Hamanoa8adb1e2006-04-10 23:46:16611-c
Junio C Hamanofb56a962006-01-28 10:38:19612</dt>
613<dd>
614<p>
Junio C Hamanoa8adb1e2006-04-10 23:46:16615 This flag changes the way a merge commit is displayed
Junio C Hamanofb56a962006-01-28 10:38:19616 (which means it is useful only when the command is given
617 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
Junio C Hamanoa8adb1e2006-04-10 23:46:16618 from each of the parents to the merge result simultaneously
619 instead of showing pairwise diff between a parent and the
620 result one at a time (which is what the <em>-m</em> option does).
621 Furthermore, it lists only files which were modified
622 from all parents.
623</p>
624</dd>
625<dt>
Junio C Hamano46338f52006-05-04 00:46:44626--cc
Junio C Hamanoa8adb1e2006-04-10 23:46:16627</dt>
628<dd>
629<p>
630 This flag changes the way a merge commit patch is displayed,
631 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
632 and <em>-p</em> options and further compresses the patch output
633 by omitting hunks that show differences from only one
Junio C Hamanofb56a962006-01-28 10:38:19634 parent, or show the same change from all but one parent
635 for an Octopus merge. When this optimization makes all
636 hunks disappear, the commit itself and the commit log
Junio C Hamanoa8adb1e2006-04-10 23:46:16637 message is not shown, just like in any other "empty diff" case.
Junio C Hamanofb56a962006-01-28 10:38:19638</p>
639</dd>
Junio C Hamanod9d71c02006-02-08 00:52:33640<dt>
641--always
642</dt>
643<dd>
644<p>
645 Show the commit itself and the commit log message even
646 if the diff itself is empty.
647</p>
648</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23649</dl>
650</div>
651<h2>Limiting Output</h2>
652<div class="sectionbody">
653<p>If you're only interested in differences in a subset of files, for
654example some architecture-specific files, you might do:</p>
655<div class="literalblock">
656<div class="content">
657<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
658</div></div>
659<p>and it will only show you what changed in those two directories.</p>
660<p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p>
661<div class="literalblock">
662<div class="content">
663<pre><tt>git-diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
664</div></div>
665<p>and it will ignore all differences to other files.</p>
666<p>The pattern is always the prefix, and is matched exactly. There are no
667wildcards. Even stricter, it has to match a complete path component.
668I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
669so it can be used to name subdirectories.</p>
670<p>An example of normal usage is:</p>
671<div class="literalblock">
672<div class="content">
673<pre><tt>torvalds@ppc970:~/git&gt; git-diff-tree 5319e4......
674*100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
675</div></div>
676<p>which tells you that the last commit changed just one file (it's from
677this one:</p>
678<div class="listingblock">
679<div class="content">
680<pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
681tree 5319e4d609cdd282069cc4dce33c1db559539b03
682parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
683author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
684committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
685
686Make "git-fsck-objects" print out all the root commits it finds.
687
688Once I do the reference tracking, I'll also make it print out all the
689HEAD commits it finds, which is even more interesting.</tt></pre>
690</div></div>
691<p>in case you care).</p>
692</div>
693<h2>Output format</h2>
694<div class="sectionbody">
695<p>The output format from "git-diff-index", "git-diff-tree" and
696"git-diff-files" are very similar.</p>
697<p>These commands all compare two sets of things; what is
698compared differs:</p>
699<dl>
700<dt>
701git-diff-index &lt;tree-ish&gt;
702</dt>
703<dd>
704<p>
705 compares the &lt;tree-ish&gt; and the files on the filesystem.
706</p>
707</dd>
708<dt>
709git-diff-index --cached &lt;tree-ish&gt;
710</dt>
711<dd>
712<p>
713 compares the &lt;tree-ish&gt; and the index.
714</p>
715</dd>
716<dt>
717git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
718</dt>
719<dd>
720<p>
721 compares the trees named by the two arguments.
722</p>
723</dd>
724<dt>
725git-diff-files [&lt;pattern&gt;&#8230;]
726</dt>
727<dd>
728<p>
729 compares the index and the files on the filesystem.
730</p>
731</dd>
732</dl>
733<p>An output line is formatted this way:</p>
734<div class="listingblock">
735<div class="content">
736<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
737copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
738rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
739create :000000 100644 0000000... 1234567... A file4
740delete :100644 000000 1234567... 0000000... D file5
741unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
742</div></div>
743<p>That is, from the left to the right:</p>
744<ol>
745<li>
746<p>
747a colon.
748</p>
749</li>
750<li>
751<p>
752mode for "src"; 000000 if creation or unmerged.
753</p>
754</li>
755<li>
756<p>
757a space.
758</p>
759</li>
760<li>
761<p>
762mode for "dst"; 000000 if deletion or unmerged.
763</p>
764</li>
765<li>
766<p>
767a space.
768</p>
769</li>
770<li>
771<p>
772sha1 for "src"; 0{40} if creation or unmerged.
773</p>
774</li>
775<li>
776<p>
777a space.
778</p>
779</li>
780<li>
781<p>
782sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
783</p>
784</li>
785<li>
786<p>
787a space.
788</p>
789</li>
790<li>
791<p>
792status, followed by optional "score" number.
793</p>
794</li>
795<li>
796<p>
797a tab or a NUL when <em>-z</em> option is used.
798</p>
799</li>
800<li>
801<p>
802path for "src"
803</p>
804</li>
805<li>
806<p>
807a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
808</p>
809</li>
810<li>
811<p>
812path for "dst"; only exists for C or R.
813</p>
814</li>
815<li>
816<p>
817an LF or a NUL when <em>-z</em> option is used, to terminate the record.
818</p>
819</li>
820</ol>
821<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
822and it is out of sync with the index.</p>
823<p>Example:</p>
824<div class="listingblock">
825<div class="content">
826<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
827</div></div>
828<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
829in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
830respectively.</p>
831</div>
832<h2>Generating patches with -p</h2>
833<div class="sectionbody">
834<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
835with a <em>-p</em> option, they do not produce the output described above;
836instead they produce a patch file.</p>
837<p>The patch generation can be customized at two levels.</p>
838<ol>
839<li>
840<p>
841When the environment variable <em>GIT_EXTERNAL_DIFF</em> is not set,
842 these commands internally invoke "diff" like this:
843</p>
844<div class="literalblock">
845<div class="content">
846<pre><tt>diff -L a/&lt;path&gt; -L b/&lt;path&gt; -pu &lt;old&gt; &lt;new&gt;</tt></pre>
847</div></div>
848<p>For added files, <tt>/dev/null</tt> is used for &lt;old&gt;. For removed
849files, <tt>/dev/null</tt> is used for &lt;new&gt;</p>
850<p>The "diff" formatting options can be customized via the
851environment variable <em>GIT_DIFF_OPTS</em>. For example, if you
852prefer context diff:</p>
853<div class="literalblock">
854<div class="content">
855<pre><tt>GIT_DIFF_OPTS=-c git-diff-index -p HEAD</tt></pre>
856</div></div>
857</li>
858<li>
859<p>
860When the environment variable <em>GIT_EXTERNAL_DIFF</em> is set, the
861 program named by it is called, instead of the diff invocation
862 described above.
863</p>
864<p>For a path that is added, removed, or modified,
865<em>GIT_EXTERNAL_DIFF</em> is called with 7 parameters:</p>
866<div class="literalblock">
867<div class="content">
868<pre><tt>path old-file old-hex old-mode new-file new-hex new-mode</tt></pre>
869</div></div>
870<p>where:</p>
871<div class="hlist"><table>
872<tr>
873<td class="hlist1">
874&lt;old|new&gt;-file
875</td>
876<td class="hlist2">
877are files GIT_EXTERNAL_DIFF can use to read the
878 contents of &lt;old|new&gt;,
879</td>
880</tr>
881<tr>
882<td class="hlist1">
883&lt;old|new&gt;-hex
884</td>
885<td class="hlist2">
886are the 40-hexdigit SHA1 hashes,
887</td>
888</tr>
889<tr>
890<td class="hlist1">
891&lt;old|new&gt;-mode
892</td>
893<td class="hlist2">
894are the octal representation of the file modes.
895</td>
896</tr>
897</table></div>
898<p>The file parameters can point at the user's working file
899(e.g. <tt>new-file</tt> in "git-diff-files"), <tt>/dev/null</tt> (e.g. <tt>old-file</tt>
900when a new file is added), or a temporary file (e.g. <tt>old-file</tt> in the
901index). <em>GIT_EXTERNAL_DIFF</em> should not worry about unlinking the
902temporary file --- it is removed when <em>GIT_EXTERNAL_DIFF</em> exits.</p>
903</li>
904</ol>
905<p>For a path that is unmerged, <em>GIT_EXTERNAL_DIFF</em> is called with 1
906parameter, &lt;path&gt;.</p>
907</div>
908<h2>git specific extension to diff format</h2>
909<div class="sectionbody">
910<p>What -p option produces is slightly different from the
911traditional diff format.</p>
912<ol>
913<li>
914<p>
Junio C Hamano235a91e2006-01-07 01:13:58915It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:23916 this:
917</p>
918<div class="literalblock">
919<div class="content">
920<pre><tt>diff --git a/file1 b/file2</tt></pre>
921</div></div>
922<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
923involved. Especially, even for a creation or a deletion,
924<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
925<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
926name of the source file of the rename/copy and the name of
927the file that rename/copy produces, respectively.</p>
928</li>
929<li>
930<p>
931It is followed by one or more extended header lines:
932</p>
933<div class="literalblock">
934<div class="content">
935<pre><tt>old mode &lt;mode&gt;
936new mode &lt;mode&gt;
937deleted file mode &lt;mode&gt;
938new file mode &lt;mode&gt;
939copy from &lt;path&gt;
940copy to &lt;path&gt;
941rename from &lt;path&gt;
942rename to &lt;path&gt;
943similarity index &lt;number&gt;
944dissimilarity index &lt;number&gt;
945index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
946</div></div>
947</li>
948<li>
949<p>
950TAB, LF, and backslash characters in pathnames are
951 represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>, respectively.
952</p>
953</li>
954</ol>
955</div>
Junio C Hamanofb56a962006-01-28 10:38:19956<h2>combined diff format</h2>
957<div class="sectionbody">
958<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
959to produce <em>combined diff</em>, which looks like this:</p>
960<div class="listingblock">
961<div class="content">
962<pre><tt>diff --combined describe.c
963@@@ +98,7 @@@
964 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
965 }
966
967- static void describe(char *arg)
968 -static void describe(struct commit *cmit, int last_one)
969++static void describe(char *arg, int last_one)
970 {
971 + unsigned char sha1[20];
972 + struct commit *cmit;</tt></pre>
973</div></div>
974<p>Unlike the traditional <em>unified</em> diff format, which shows two
975files A and B with a single column that has <tt>-</tt> (minus &#8212;
976appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
977added to B), or <tt> </tt> (space &#8212; unchanged) prefix, this format
978compares two or more files file1, file2,&#8230; with one file X, and
979shows how X differs from each of fileN. One column for each of
980fileN is prepended to the output line to note how X's line is
981different from it.</p>
982<p>A <tt>-</tt> character in the column N means that the line appears in
983fileN but it does not appear in the last file. A <tt>+</tt> character
984in the column N means that the line appears in the last file,
985and fileN does not have that line.</p>
986<p>In the above example output, the function signature was changed
987from both files (hence two <tt>-</tt> removals from both file1 and
988file2, plus <tt>++</tt> to mean one line that was added does not appear
989in either file1 nor file2). Also two other lines are the same
990from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
991<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
992merge commit with the merge result (i.e. file1..fileN are the
993parents). When shown by <tt>git diff-files -c</tt>, it compares the
994two unresolved merge parents with the working tree file
995(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
996"their version").</p>
997</div>
Junio C Hamano1a4e8412005-12-27 08:17:23998<h2>Author</h2>
999<div class="sectionbody">
1000<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1001</div>
1002<h2>Documentation</h2>
1003<div class="sectionbody">
1004<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1005</div>
1006<h2>GIT</h2>
1007<div class="sectionbody">
1008<p>Part of the <a href="git.html">git(7)</a> suite</p>
1009</div>
1010<div id="footer">
1011<div id="footer-text">
Junio C Hamano6959c6c2006-05-17 10:34:111012Last updated 17-May-2006 10:34:02 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231013</div>
1014</div>
1015</body>
1016</html>