blob: f429f3b229a2426db1850d9ff09e0412da8cbd3d [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 Hamano6ec31b92006-02-10 05:52:016<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-files(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-diff-files(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-diff-files -
269 Compares files in the working tree and the index
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano9882a522007-04-27 08:22:22275<p><em>git-diff-files</em> [-q] [-0|-1|-2|-3|-c|--cc|--no-index] [&lt;common diff options&gt;] [&lt;path&gt;&#8230;]</p>
Junio C Hamano1a4e8412005-12-27 08:17:23276</div>
277<h2>DESCRIPTION</h2>
278<div class="sectionbody">
279<p>Compares the files in the working tree and the index. When paths
280are specified, compares only those named paths. Otherwise all
281entries in the index are compared. The output format is the
282same as "git-diff-index" and "git-diff-tree".</p>
283</div>
284<h2>OPTIONS</h2>
285<div class="sectionbody">
286<dl>
287<dt>
288-p
289</dt>
290<dd>
291<p>
292 Generate patch (see section on generating patches)
293</p>
294</dd>
295<dt>
296-u
297</dt>
298<dd>
299<p>
300 Synonym for "-p".
301</p>
302</dd>
303<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34304--raw
305</dt>
306<dd>
307<p>
308 Generate the raw format.
309</p>
310</dd>
311<dt>
Junio C Hamano54559c82006-04-13 07:45:12312--patch-with-raw
313</dt>
314<dd>
315<p>
Junio C Hamano9ae1a062006-07-10 08:12:34316 Synonym for "-p --raw".
Junio C Hamano54559c82006-04-13 07:45:12317</p>
318</dd>
319<dt>
Junio C Hamano4a9a76a2006-10-01 05:40:29320--stat[=width[,name-width]]
Junio C Hamanoba7c8d82006-04-15 06:17:42321</dt>
322<dd>
323<p>
Junio C Hamano4a9a76a2006-10-01 05:40:29324 Generate a diffstat. You can override the default
325 output width for 80-column terminal by "--stat=width".
326 The width of the filename part can be controlled by
327 giving another width to it separated by a comma.
Junio C Hamanoba7c8d82006-04-15 06:17:42328</p>
329</dd>
330<dt>
Junio C Hamanofbe00522006-10-19 05:58:48331--numstat
332</dt>
333<dd>
334<p>
335 Similar to --stat, but shows number of added and
336 deleted lines in decimal notation and pathname without
Junio C Hamanod793de52006-12-26 09:11:43337 abbreviation, to make it more machine friendly. For
338 binary files, outputs two <tt>-</tt> instead of saying
339 <tt>0 0</tt>.
Junio C Hamanofbe00522006-10-19 05:58:48340</p>
341</dd>
342<dt>
Junio C Hamano7d23f5e2006-12-16 07:44:04343--shortstat
344</dt>
345<dd>
346<p>
347 Output only the last line of the --stat format containing total
348 number of modified files, as well as number of added and deleted
349 lines.
350</p>
351</dd>
352<dt>
Junio C Hamano6959c6c2006-05-17 10:34:11353--summary
354</dt>
355<dd>
356<p>
357 Output a condensed summary of extended header information
358 such as creations, renames and mode changes.
359</p>
360</dd>
361<dt>
Junio C Hamanod1308c92006-04-16 11:01:09362--patch-with-stat
363</dt>
364<dd>
365<p>
Junio C Hamano9ae1a062006-07-10 08:12:34366 Synonym for "-p --stat".
Junio C Hamanod1308c92006-04-16 11:01:09367</p>
368</dd>
369<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23370-z
371</dt>
372<dd>
373<p>
374 \0 line termination on output
375</p>
376</dd>
377<dt>
378--name-only
379</dt>
380<dd>
381<p>
382 Show only names of changed files.
383</p>
384</dd>
385<dt>
386--name-status
387</dt>
388<dd>
389<p>
390 Show only names and status of changed files.
391</p>
392</dd>
393<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34394--color
395</dt>
396<dd>
397<p>
398 Show colored diff.
399</p>
400</dd>
401<dt>
402--no-color
403</dt>
404<dd>
405<p>
406 Turn off colored diff, even when the configuration file
407 gives the default to color output.
408</p>
409</dd>
410<dt>
Junio C Hamano85e45fa2006-08-13 07:47:41411--color-words
412</dt>
413<dd>
414<p>
415 Show colored word diff, i.e. color words which have changed.
416</p>
417</dd>
418<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34419--no-renames
420</dt>
421<dd>
422<p>
423 Turn off rename detection, even when the configuration
424 file gives the default to do so.
425</p>
426</dd>
427<dt>
Junio C Hamanoa890c4f2007-01-28 10:29:21428--check
429</dt>
430<dd>
431<p>
432 Warn if changes introduce trailing whitespace
433 or an indent that uses a space before a tab.
434</p>
435</dd>
436<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23437--full-index
438</dt>
439<dd>
440<p>
441 Instead of the first handful characters, show full
442 object name of pre- and post-image blob on the "index"
443 line when generating a patch format output.
444</p>
445</dd>
446<dt>
Junio C Hamano9ae1a062006-07-10 08:12:34447--binary
448</dt>
449<dd>
450<p>
451 In addition to --full-index, output "binary diff" that
452 can be applied with "git apply".
453</p>
454</dd>
455<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23456--abbrev[=&lt;n&gt;]
457</dt>
458<dd>
459<p>
460 Instead of showing the full 40-byte hexadecimal object
461 name in diff-raw format output and diff-tree header
Junio C Hamano235a91e2006-01-07 01:13:58462 lines, show only handful hexdigits prefix. This is
Junio C Hamano1a4e8412005-12-27 08:17:23463 independent of --full-index option above, which controls
464 the diff-patch output format. Non default number of
465 digits can be specified with --abbrev=&lt;n&gt;.
466</p>
467</dd>
468<dt>
469-B
470</dt>
471<dd>
472<p>
473 Break complete rewrite changes into pairs of delete and create.
474</p>
475</dd>
476<dt>
477-M
478</dt>
479<dd>
480<p>
481 Detect renames.
482</p>
483</dd>
484<dt>
485-C
486</dt>
487<dd>
488<p>
Junio C Hamano16f98872007-06-12 16:09:14489 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
Junio C Hamano1a4e8412005-12-27 08:17:23490</p>
491</dd>
492<dt>
Junio C Hamano6ec31b92006-02-10 05:52:01493--diff-filter=[ACDMRTUXB*]
494</dt>
495<dd>
496<p>
497 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
498 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
499 type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are
500 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
501 Any combination of the filter characters may be used.
502 When <tt>*</tt> (All-or-none) is added to the combination, all
503 paths are selected if there is any file that matches
504 other criteria in the comparison; if there is no file
505 that matches other criteria, nothing is selected.
506</p>
507</dd>
508<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23509--find-copies-harder
510</dt>
511<dd>
512<p>
Junio C Hamano16f98872007-06-12 16:09:14513 For performance reasons, by default, <tt>-C</tt> option finds copies only
Junio C Hamano1a4e8412005-12-27 08:17:23514 if the original file of the copy was modified in the same
515 changeset. This flag makes the command
516 inspect unmodified files as candidates for the source of
517 copy. This is a very expensive operation for large
Junio C Hamano16f98872007-06-12 16:09:14518 projects, so use it with caution. Giving more than one
519 <tt>-C</tt> option has the same effect.
Junio C Hamano1a4e8412005-12-27 08:17:23520</p>
521</dd>
522<dt>
523-l&lt;num&gt;
524</dt>
525<dd>
526<p>
527 -M and -C options require O(n^2) processing time where n
528 is the number of potential rename/copy targets. This
529 option prevents rename/copy detection from running if
530 the number of rename/copy targets exceeds the specified
531 number.
532</p>
533</dd>
534<dt>
535-S&lt;string&gt;
536</dt>
537<dd>
538<p>
539 Look for differences that contain the change in &lt;string&gt;.
540</p>
541</dd>
542<dt>
543--pickaxe-all
544</dt>
545<dd>
546<p>
547 When -S finds a change, show all the changes in that
548 changeset, not just the files that contain the change
549 in &lt;string&gt;.
550</p>
551</dd>
552<dt>
Junio C Hamanobfe9e752006-04-05 21:43:28553--pickaxe-regex
554</dt>
555<dd>
556<p>
557 Make the &lt;string&gt; not a plain string but an extended POSIX
558 regex to match.
559</p>
560</dd>
561<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23562-O&lt;orderfile&gt;
563</dt>
564<dd>
565<p>
566 Output the patch in the order specified in the
567 &lt;orderfile&gt;, which has one shell glob pattern per line.
568</p>
569</dd>
570<dt>
571-R
572</dt>
573<dd>
574<p>
575 Swap two inputs; that is, show differences from index or
576 on-disk file to tree contents.
577</p>
578</dd>
Junio C Hamanoc26f5482006-07-09 09:38:14579<dt>
580--text
581</dt>
582<dd>
583<p>
584 Treat all files as text.
585</p>
586</dd>
587<dt>
588-a
589</dt>
590<dd>
591<p>
592 Shorthand for "--text".
593</p>
594</dd>
Junio C Hamanod9c2d2f2006-12-06 08:59:07595<dt>
Junio C Hamanofd468962007-02-14 23:45:04596--ignore-space-at-eol
597</dt>
598<dd>
599<p>
600 Ignore changes in white spaces at EOL.
601</p>
602</dd>
603<dt>
Junio C Hamanod9c2d2f2006-12-06 08:59:07604--ignore-space-change
605</dt>
606<dd>
607<p>
608 Ignore changes in amount of white space. This ignores white
609 space at line end, and consider all other sequences of one or
610 more white space characters to be equivalent.
611</p>
612</dd>
613<dt>
614-b
615</dt>
616<dd>
617<p>
618 Shorthand for "--ignore-space-change".
619</p>
620</dd>
621<dt>
622--ignore-all-space
623</dt>
624<dd>
625<p>
626 Ignore white space when comparing lines. This ignores
627 difference even if one line has white space where the other
628 line has none.
629</p>
630</dd>
631<dt>
632-w
633</dt>
634<dd>
635<p>
636 Shorthand for "--ignore-all-space".
637</p>
638</dd>
Junio C Hamano48fd2f62007-03-19 02:02:30639<dt>
640--exit-code
641</dt>
642<dd>
643<p>
644 Make the program exit with codes similar to diff(1).
645 That is, it exits with 1 if there were differences and
646 0 means no differences.
647</p>
648</dd>
Junio C Hamano35e57552007-03-25 07:54:35649<dt>
650--quiet
651</dt>
652<dd>
653<p>
654 Disable all output of the program. Implies --exit-code.
655</p>
656</dd>
Junio C Hamanobb0f4042007-07-04 06:41:40657<dt>
658--ext-diff
659</dt>
660<dd>
661<p>
662 Allow an external diff helper to be executed. If you set an
663 external diff driver with gitlink:gitattributes(5), you need
664 to use this option with gitlink:git-log(1) and friends.
665</p>
666</dd>
667<dt>
668--no-ext-diff
669</dt>
670<dd>
671<p>
672 Disallow external diff drivers.
673</p>
674</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23675</dl>
676<p>For more detailed explanation on these common options, see also
677<a href="diffcore.html">diffcore documentation</a>.</p>
678<dl>
679<dt>
680-1 -2 -3 or --base --ours --theirs, and -0
681</dt>
682<dd>
683<p>
684 Diff against the "base" version, "our branch" or "their
685 branch" respectively. With these options, diffs for
686 merged entries are not shown.
687</p>
688<p>The default is to diff against our branch (-2) and the
689cleanly resolved paths. The option -0 can be given to
690omit diff output for unmerged entries and just show "Unmerged".</p>
691</dd>
692<dt>
Junio C Hamanofb56a962006-01-28 10:38:19693-c,--cc
694</dt>
695<dd>
696<p>
697 This compares stage 2 (our branch), stage 3 (their
698 branch) and the working tree file and outputs a combined
699 diff, similar to the way <em>diff-tree</em> shows a merge
700 commit with these flags.
701</p>
702</dd>
703<dt>
Junio C Hamano9882a522007-04-27 08:22:22704--no-index
Junio C Hamanodb911ee2007-02-28 08:13:52705</dt>
706<dd>
707<p>
708 Compare the two given files / directories.
709</p>
710</dd>
711<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23712-q
713</dt>
714<dd>
715<p>
Junio C Hamano51c2ab02006-07-09 20:38:54716 Remain silent even on nonexistent files
Junio C Hamano1a4e8412005-12-27 08:17:23717</p>
718</dd>
719</dl>
720</div>
721<h2>Output format</h2>
722<div class="sectionbody">
723<p>The output format from "git-diff-index", "git-diff-tree" and
724"git-diff-files" are very similar.</p>
725<p>These commands all compare two sets of things; what is
726compared differs:</p>
727<dl>
728<dt>
729git-diff-index &lt;tree-ish&gt;
730</dt>
731<dd>
732<p>
733 compares the &lt;tree-ish&gt; and the files on the filesystem.
734</p>
735</dd>
736<dt>
737git-diff-index --cached &lt;tree-ish&gt;
738</dt>
739<dd>
740<p>
741 compares the &lt;tree-ish&gt; and the index.
742</p>
743</dd>
744<dt>
745git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
746</dt>
747<dd>
748<p>
749 compares the trees named by the two arguments.
750</p>
751</dd>
752<dt>
753git-diff-files [&lt;pattern&gt;&#8230;]
754</dt>
755<dd>
756<p>
757 compares the index and the files on the filesystem.
758</p>
759</dd>
760</dl>
761<p>An output line is formatted this way:</p>
762<div class="listingblock">
763<div class="content">
764<pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
765copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
766rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
767create :000000 100644 0000000... 1234567... A file4
768delete :100644 000000 1234567... 0000000... D file5
769unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
770</div></div>
771<p>That is, from the left to the right:</p>
772<ol>
773<li>
774<p>
775a colon.
776</p>
777</li>
778<li>
779<p>
780mode for "src"; 000000 if creation or unmerged.
781</p>
782</li>
783<li>
784<p>
785a space.
786</p>
787</li>
788<li>
789<p>
790mode for "dst"; 000000 if deletion or unmerged.
791</p>
792</li>
793<li>
794<p>
795a space.
796</p>
797</li>
798<li>
799<p>
800sha1 for "src"; 0{40} if creation or unmerged.
801</p>
802</li>
803<li>
804<p>
805a space.
806</p>
807</li>
808<li>
809<p>
810sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
811</p>
812</li>
813<li>
814<p>
815a space.
816</p>
817</li>
818<li>
819<p>
820status, followed by optional "score" number.
821</p>
822</li>
823<li>
824<p>
825a tab or a NUL when <em>-z</em> option is used.
826</p>
827</li>
828<li>
829<p>
830path for "src"
831</p>
832</li>
833<li>
834<p>
835a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
836</p>
837</li>
838<li>
839<p>
840path for "dst"; only exists for C or R.
841</p>
842</li>
843<li>
844<p>
845an LF or a NUL when <em>-z</em> option is used, to terminate the record.
846</p>
847</li>
848</ol>
849<p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
850and it is out of sync with the index.</p>
851<p>Example:</p>
852<div class="listingblock">
853<div class="content">
854<pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
855</div></div>
856<p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
857in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
858respectively.</p>
859</div>
Junio C Hamano67fad6d2007-05-06 08:53:12860<h2>diff format for merges</h2>
861<div class="sectionbody">
862<p>"git-diff-tree" and "git-diff-files" can take <em>-c</em> or <em>--cc</em> option
863to generate diff output also for merge commits. The output differs
864from the format described above in the following way:</p>
865<ol>
866<li>
867<p>
868there is a colon for each parent
869</p>
870</li>
871<li>
872<p>
873there are more "src" modes and "src" sha1
874</p>
875</li>
876<li>
877<p>
878status is concatenated status characters for each parent
879</p>
880</li>
881<li>
882<p>
883no optional "score" number
884</p>
885</li>
886<li>
887<p>
888single path, only for "dst"
889</p>
890</li>
891</ol>
892<p>Example:</p>
893<div class="listingblock">
894<div class="content">
895<pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
896</div></div>
897<p>Note that <em>combined diff</em> lists only files which were modified from
898all parents.</p>
899</div>
Junio C Hamano1a4e8412005-12-27 08:17:23900<h2>Generating patches with -p</h2>
901<div class="sectionbody">
902<p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
903with a <em>-p</em> option, they do not produce the output described above;
Junio C Hamano1c437122006-11-28 02:22:25904instead they produce a patch file. You can customize the creation
905of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS
906environment variables.</p>
907<p>What the -p option produces is slightly different from the traditional
908diff format.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23909<ol>
910<li>
911<p>
Junio C Hamano235a91e2006-01-07 01:13:58912It is preceded with a "git diff" header, that looks like
Junio C Hamano1a4e8412005-12-27 08:17:23913 this:
914</p>
915<div class="literalblock">
916<div class="content">
917<pre><tt>diff --git a/file1 b/file2</tt></pre>
918</div></div>
919<p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
920involved. Especially, even for a creation or a deletion,
921<tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p>
922<p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
923name of the source file of the rename/copy and the name of
924the file that rename/copy produces, respectively.</p>
925</li>
926<li>
927<p>
928It is followed by one or more extended header lines:
929</p>
930<div class="literalblock">
931<div class="content">
932<pre><tt>old mode &lt;mode&gt;
933new mode &lt;mode&gt;
934deleted file mode &lt;mode&gt;
935new file mode &lt;mode&gt;
936copy from &lt;path&gt;
937copy to &lt;path&gt;
938rename from &lt;path&gt;
939rename to &lt;path&gt;
940similarity index &lt;number&gt;
941dissimilarity index &lt;number&gt;
942index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
943</div></div>
944</li>
945<li>
946<p>
Junio C Hamanoa053d542006-10-27 09:29:13947TAB, LF, double quote and backslash characters in pathnames
948 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
949 If there is need for such substitution then the whole
950 pathname is put in double quotes.
Junio C Hamano1a4e8412005-12-27 08:17:23951</p>
952</li>
953</ol>
Junio C Hamanod526ba92007-07-02 00:17:42954<p>The similarity index is the percentage of unchanged lines, and
955the dissimilarity index is the percentage of changed lines. It
956is a rounded down integer, followed by a percent sign. The
957similarity index value of 100% is thus reserved for two equal
958files, while 100% dissimilarity means that no line from the old
959file made it into the new one.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23960</div>
Junio C Hamanofb56a962006-01-28 10:38:19961<h2>combined diff format</h2>
962<div class="sectionbody">
963<p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option
964to produce <em>combined diff</em>, which looks like this:</p>
965<div class="listingblock">
966<div class="content">
967<pre><tt>diff --combined describe.c
Junio C Hamano29f14312006-10-26 08:47:29968index fabadb8,cc95eb0..4866510
969--- a/describe.c
970+++ b/describe.c
971@@@ -98,20 -98,12 +98,20 @@@
972 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Junio C Hamanofb56a962006-01-28 10:38:19973 }
974
975- static void describe(char *arg)
976 -static void describe(struct commit *cmit, int last_one)
977++static void describe(char *arg, int last_one)
978 {
Junio C Hamano29f14312006-10-26 08:47:29979 + unsigned char sha1[20];
980 + struct commit *cmit;
981 struct commit_list *list;
982 static int initialized = 0;
983 struct commit_name *n;
984
985 + if (get_sha1(arg, sha1) &lt; 0)
986 + usage(describe_usage);
987 + cmit = lookup_commit_reference(sha1);
988 + if (!cmit)
989 + usage(describe_usage);
990 +
991 if (!initialized) {
992 initialized = 1;
993 for_each_ref(get_name);</tt></pre>
Junio C Hamanofb56a962006-01-28 10:38:19994</div></div>
Junio C Hamano29f14312006-10-26 08:47:29995<ol>
996<li>
997<p>
998It is preceded with a "git diff" header, that looks like
999 this (when <em>-c</em> option is used):
1000</p>
1001<div class="literalblock">
1002<div class="content">
1003<pre><tt>diff --combined file</tt></pre>
1004</div></div>
1005<p>or like this (when <em>--cc</em> option is used):</p>
1006<div class="literalblock">
1007<div class="content">
1008<pre><tt>diff --c file</tt></pre>
1009</div></div>
1010</li>
1011<li>
1012<p>
1013It is followed by one or more extended header lines
1014 (this example shows a merge with two parents):
1015</p>
1016<div class="literalblock">
1017<div class="content">
1018<pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1019mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1020new file mode &lt;mode&gt;
1021deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1022</div></div>
1023<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:041024the &lt;mode&gt; is different from the rest. Extended headers with
Junio C Hamano29f14312006-10-26 08:47:291025information about detected contents movement (renames and
1026copying detection) are designed to work with diff of two
1027&lt;tree-ish&gt; and are not used by combined diff format.</p>
1028</li>
1029<li>
1030<p>
1031It is followed by two-line from-file/to-file header
1032</p>
1033<div class="literalblock">
1034<div class="content">
1035<pre><tt>--- a/file
1036+++ b/file</tt></pre>
1037</div></div>
1038<p>Similar to two-line header for traditional <em>unified</em> diff
1039format, <tt>/dev/null</tt> is used to signal created or deleted
1040files.</p>
1041</li>
1042<li>
1043<p>
1044Chunk header format is modified to prevent people from
1045 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1046 was created for review of merge commit changes, and was not
1047 meant for apply. The change is similar to the change in the
1048 extended <em>index</em> header:
1049</p>
1050<div class="literalblock">
1051<div class="content">
1052<pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1053</div></div>
1054<p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1055header for combined diff format.</p>
1056</li>
1057</ol>
Junio C Hamanofb56a962006-01-28 10:38:191058<p>Unlike the traditional <em>unified</em> diff format, which shows two
1059files A and B with a single column that has <tt>-</tt> (minus &#8212;
1060appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
Junio C Hamano29f14312006-10-26 08:47:291061added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
Junio C Hamanofb56a962006-01-28 10:38:191062compares two or more files file1, file2,&#8230; with one file X, and
1063shows how X differs from each of fileN. One column for each of
1064fileN is prepended to the output line to note how X's line is
1065different from it.</p>
1066<p>A <tt>-</tt> character in the column N means that the line appears in
Junio C Hamano29f14312006-10-26 08:47:291067fileN but it does not appear in the result. A <tt>+</tt> character
Junio C Hamanofb56a962006-01-28 10:38:191068in the column N means that the line appears in the last file,
Junio C Hamano29f14312006-10-26 08:47:291069and fileN does not have that line (in other words, the line was
1070added, from the point of view of that parent).</p>
Junio C Hamanofb56a962006-01-28 10:38:191071<p>In the above example output, the function signature was changed
1072from both files (hence two <tt>-</tt> removals from both file1 and
1073file2, plus <tt>++</tt> to mean one line that was added does not appear
1074in either file1 nor file2). Also two other lines are the same
1075from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p>
1076<p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1077merge commit with the merge result (i.e. file1..fileN are the
1078parents). When shown by <tt>git diff-files -c</tt>, it compares the
1079two unresolved merge parents with the working tree file
1080(i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1081"their version").</p>
1082</div>
Junio C Hamano1a4e8412005-12-27 08:17:231083<h2>Author</h2>
1084<div class="sectionbody">
1085<p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p>
1086</div>
1087<h2>Documentation</h2>
1088<div class="sectionbody">
1089<p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
1090</div>
1091<h2>GIT</h2>
1092<div class="sectionbody">
1093<p>Part of the <a href="git.html">git(7)</a> suite</p>
1094</div>
1095<div id="footer">
1096<div id="footer-text">
Junio C Hamanobb0f4042007-07-04 06:41:401097Last updated 04-Jul-2007 06:40:52 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231098</div>
1099</div>
1100</body>
1101</html>