Autogenerated HTML docs for v1.7.6-345-g5c2f8
[git/jnareb-git.git] / git-diff-index.html
blobb46400976d03b6888eb041a39db2618d4442abf7
1 <!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" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>git-diff-index(1)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 git-diff-index(1) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>git-diff-index -
411 Compares content and mode of blobs between the index and repository
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content"><em>git diff-index</em> [-m] [--cached] [&lt;common diff options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</div>
419 <div class="verseblock-attribution">
420 </div></div>
421 </div>
422 <h2 id="_description">DESCRIPTION</h2>
423 <div class="sectionbody">
424 <div class="paragraph"><p>Compares the content and mode of the blobs found via a tree
425 object with the content of the current index and, optionally
426 ignoring the stat state of the file on disk. When paths are
427 specified, compares only those named paths. Otherwise all
428 entries in the index are compared.</p></div>
429 </div>
430 <h2 id="_options">OPTIONS</h2>
431 <div class="sectionbody">
432 <div class="dlist"><dl>
433 <dt class="hdlist1">
435 </dt>
436 <dt class="hdlist1">
438 </dt>
439 <dt class="hdlist1">
440 --patch
441 </dt>
442 <dd>
444 Generate patch (see section on generating patches).
446 </p>
447 </dd>
448 <dt class="hdlist1">
449 -U&lt;n&gt;
450 </dt>
451 <dt class="hdlist1">
452 --unified=&lt;n&gt;
453 </dt>
454 <dd>
456 Generate diffs with &lt;n&gt; lines of context instead of
457 the usual three.
458 Implies <tt>-p</tt>.
459 </p>
460 </dd>
461 <dt class="hdlist1">
462 --raw
463 </dt>
464 <dd>
466 Generate the raw format.
467 This is the default.
468 </p>
469 </dd>
470 <dt class="hdlist1">
471 --patch-with-raw
472 </dt>
473 <dd>
475 Synonym for <tt>-p --raw</tt>.
476 </p>
477 </dd>
478 <dt class="hdlist1">
479 --patience
480 </dt>
481 <dd>
483 Generate a diff using the "patience diff" algorithm.
484 </p>
485 </dd>
486 <dt class="hdlist1">
487 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]
488 </dt>
489 <dd>
491 Generate a diffstat. You can override the default
492 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
493 The width of the filename part can be controlled by
494 giving another width to it separated by a comma.
495 By giving a third parameter <tt>&lt;count&gt;</tt>, you can limit the
496 output to the first <tt>&lt;count&gt;</tt> lines, followed by
497 <tt>&#8230;</tt> if there are more.
498 </p>
499 <div class="paragraph"><p>These parameters can also be set individually with <tt>--stat-width=&lt;width&gt;</tt>,
500 <tt>--stat-name-width=&lt;name-width&gt;</tt> and <tt>--stat-count=&lt;count&gt;</tt>.</p></div>
501 </dd>
502 <dt class="hdlist1">
503 --numstat
504 </dt>
505 <dd>
507 Similar to <tt>--stat</tt>, but shows number of added and
508 deleted lines in decimal notation and pathname without
509 abbreviation, to make it more machine friendly. For
510 binary files, outputs two <tt>-</tt> instead of saying
511 <tt>0 0</tt>.
512 </p>
513 </dd>
514 <dt class="hdlist1">
515 --shortstat
516 </dt>
517 <dd>
519 Output only the last line of the <tt>--stat</tt> format containing total
520 number of modified files, as well as number of added and deleted
521 lines.
522 </p>
523 </dd>
524 <dt class="hdlist1">
525 --dirstat[=&lt;param1,param2,&#8230;&gt;]
526 </dt>
527 <dd>
529 Output the distribution of relative amount of changes for each
530 sub-directory. The behavior of <tt>--dirstat</tt> can be customized by
531 passing it a comma separated list of parameters.
532 The defaults are controlled by the <tt>diff.dirstat</tt> configuration
533 variable (see <a href="git-config.html">git-config(1)</a>).
534 The following parameters are available:
535 </p>
536 <div class="dlist"><dl>
537 <dt class="hdlist1">
538 <tt>changes</tt>
539 </dt>
540 <dd>
542 Compute the dirstat numbers by counting the lines that have been
543 removed from the source, or added to the destination. This ignores
544 the amount of pure code movements within a file. In other words,
545 rearranging lines in a file is not counted as much as other changes.
546 This is the default behavior when no parameter is given.
547 </p>
548 </dd>
549 <dt class="hdlist1">
550 <tt>lines</tt>
551 </dt>
552 <dd>
554 Compute the dirstat numbers by doing the regular line-based diff
555 analysis, and summing the removed/added line counts. (For binary
556 files, count 64-byte chunks instead, since binary files have no
557 natural concept of lines). This is a more expensive <tt>--dirstat</tt>
558 behavior than the <tt>changes</tt> behavior, but it does count rearranged
559 lines within a file as much as other changes. The resulting output
560 is consistent with what you get from the other <tt>--*stat</tt> options.
561 </p>
562 </dd>
563 <dt class="hdlist1">
564 <tt>files</tt>
565 </dt>
566 <dd>
568 Compute the dirstat numbers by counting the number of files changed.
569 Each changed file counts equally in the dirstat analysis. This is
570 the computationally cheapest <tt>--dirstat</tt> behavior, since it does
571 not have to look at the file contents at all.
572 </p>
573 </dd>
574 <dt class="hdlist1">
575 <tt>cumulative</tt>
576 </dt>
577 <dd>
579 Count changes in a child directory for the parent directory as well.
580 Note that when using <tt>cumulative</tt>, the sum of the percentages
581 reported may exceed 100%. The default (non-cumulative) behavior can
582 be specified with the <tt>noncumulative</tt> parameter.
583 </p>
584 </dd>
585 <dt class="hdlist1">
586 &lt;limit&gt;
587 </dt>
588 <dd>
590 An integer parameter specifies a cut-off percent (3% by default).
591 Directories contributing less than this percentage of the changes
592 are not shown in the output.
593 </p>
594 </dd>
595 </dl></div>
596 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
597 directories with less than 10% of the total amount of changed files,
598 and accumulating child directory counts in the parent directories:
599 <tt>--dirstat=files,10,cumulative</tt>.</p></div>
600 </dd>
601 <dt class="hdlist1">
602 --summary
603 </dt>
604 <dd>
606 Output a condensed summary of extended header information
607 such as creations, renames and mode changes.
608 </p>
609 </dd>
610 <dt class="hdlist1">
611 --patch-with-stat
612 </dt>
613 <dd>
615 Synonym for <tt>-p --stat</tt>.
616 </p>
617 </dd>
618 <dt class="hdlist1">
620 </dt>
621 <dd>
623 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
624 given, do not munge pathnames and use NULs as output field terminators.
625 </p>
626 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
627 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
628 respectively, and the pathname will be enclosed in double quotes if
629 any of those replacements occurred.</p></div>
630 </dd>
631 <dt class="hdlist1">
632 --name-only
633 </dt>
634 <dd>
636 Show only names of changed files.
637 </p>
638 </dd>
639 <dt class="hdlist1">
640 --name-status
641 </dt>
642 <dd>
644 Show only names and status of changed files. See the description
645 of the <tt>--diff-filter</tt> option on what the status letters mean.
646 </p>
647 </dd>
648 <dt class="hdlist1">
649 --submodule[=&lt;format&gt;]
650 </dt>
651 <dd>
653 Chose the output format for submodule differences. &lt;format&gt; can be one of
654 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
655 is used when this option is not given. <em>log</em> is the default value for this
656 option and lists the commits in that commit range like the <em>summary</em>
657 option of <a href="git-submodule.html">git-submodule(1)</a> does.
658 </p>
659 </dd>
660 <dt class="hdlist1">
661 --color[=&lt;when&gt;]
662 </dt>
663 <dd>
665 Show colored diff.
666 The value must be <tt>always</tt> (the default for <tt>&lt;when&gt;</tt>), <tt>never</tt>, or <tt>auto</tt>.
667 The default value is <tt>never</tt>.
668 </p>
669 </dd>
670 <dt class="hdlist1">
671 --no-color
672 </dt>
673 <dd>
675 Turn off colored diff.
676 It is the same as <tt>--color=never</tt>.
677 </p>
678 </dd>
679 <dt class="hdlist1">
680 --word-diff[=&lt;mode&gt;]
681 </dt>
682 <dd>
684 Show a word diff, using the &lt;mode&gt; to delimit changed words.
685 By default, words are delimited by whitespace; see
686 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
687 must be one of:
688 </p>
689 <div class="dlist"><dl>
690 <dt class="hdlist1">
691 color
692 </dt>
693 <dd>
695 Highlight changed words using only colors. Implies <tt>--color</tt>.
696 </p>
697 </dd>
698 <dt class="hdlist1">
699 plain
700 </dt>
701 <dd>
703 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
704 attempts to escape the delimiters if they appear in the input,
705 so the output may be ambiguous.
706 </p>
707 </dd>
708 <dt class="hdlist1">
709 porcelain
710 </dt>
711 <dd>
713 Use a special line-based format intended for script
714 consumption. Added/removed/unchanged runs are printed in the
715 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
716 character at the beginning of the line and extending to the
717 end of the line. Newlines in the input are represented by a
718 tilde <tt>~</tt> on a line of its own.
719 </p>
720 </dd>
721 <dt class="hdlist1">
722 none
723 </dt>
724 <dd>
726 Disable word diff again.
727 </p>
728 </dd>
729 </dl></div>
730 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
731 highlight the changed parts in all modes if enabled.</p></div>
732 </dd>
733 <dt class="hdlist1">
734 --word-diff-regex=&lt;regex&gt;
735 </dt>
736 <dd>
738 Use &lt;regex&gt; to decide what a word is, instead of considering
739 runs of non-whitespace to be a word. Also implies
740 <tt>--word-diff</tt> unless it was already enabled.
741 </p>
742 <div class="paragraph"><p>Every non-overlapping match of the
743 &lt;regex&gt; is considered a word. Anything between these matches is
744 considered whitespace and ignored(!) for the purposes of finding
745 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
746 expression to make sure that it matches all non-whitespace characters.
747 A match that contains a newline is silently truncated(!) at the
748 newline.</p></div>
749 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
750 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
751 overrides any diff driver or configuration setting. Diff drivers
752 override configuration settings.</p></div>
753 </dd>
754 <dt class="hdlist1">
755 --color-words[=&lt;regex&gt;]
756 </dt>
757 <dd>
759 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
760 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
761 </p>
762 </dd>
763 <dt class="hdlist1">
764 --no-renames
765 </dt>
766 <dd>
768 Turn off rename detection, even when the configuration
769 file gives the default to do so.
770 </p>
771 </dd>
772 <dt class="hdlist1">
773 --check
774 </dt>
775 <dd>
777 Warn if changes introduce whitespace errors. What are
778 considered whitespace errors is controlled by <tt>core.whitespace</tt>
779 configuration. By default, trailing whitespaces (including
780 lines that solely consist of whitespaces) and a space character
781 that is immediately followed by a tab character inside the
782 initial indent of the line are considered whitespace errors.
783 Exits with non-zero status if problems are found. Not compatible
784 with --exit-code.
785 </p>
786 </dd>
787 <dt class="hdlist1">
788 --full-index
789 </dt>
790 <dd>
792 Instead of the first handful of characters, show the full
793 pre- and post-image blob object names on the "index"
794 line when generating patch format output.
795 </p>
796 </dd>
797 <dt class="hdlist1">
798 --binary
799 </dt>
800 <dd>
802 In addition to <tt>--full-index</tt>, output a binary diff that
803 can be applied with <tt>git-apply</tt>.
804 </p>
805 </dd>
806 <dt class="hdlist1">
807 --abbrev[=&lt;n&gt;]
808 </dt>
809 <dd>
811 Instead of showing the full 40-byte hexadecimal object
812 name in diff-raw format output and diff-tree header
813 lines, show only a partial prefix. This is
814 independent of the <tt>--full-index</tt> option above, which controls
815 the diff-patch output format. Non default number of
816 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
817 </p>
818 </dd>
819 <dt class="hdlist1">
820 -B[&lt;n&gt;][/&lt;m&gt;]
821 </dt>
822 <dt class="hdlist1">
823 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
824 </dt>
825 <dd>
827 Break complete rewrite changes into pairs of delete and
828 create. This serves two purposes:
829 </p>
830 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
831 not as a series of deletion and insertion mixed together with a very
832 few lines that happen to match textually as the context, but as a
833 single deletion of everything old followed by a single insertion of
834 everything new, and the number <tt>m</tt> controls this aspect of the -B
835 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
836 original should remain in the result for git to consider it a total
837 rewrite (i.e. otherwise the resulting patch will be a series of
838 deletion and insertion mixed together with context lines).</p></div>
839 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
840 source of a rename (usually -M only considers a file that disappeared
841 as the source of a rename), and the number <tt>n</tt> controls this aspect of
842 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
843 addition and deletion compared to 20% or more of the file&#8217;s size are
844 eligible for being picked up as a possible source of a rename to
845 another file.</p></div>
846 </dd>
847 <dt class="hdlist1">
848 -M[&lt;n&gt;]
849 </dt>
850 <dt class="hdlist1">
851 --find-renames[=&lt;n&gt;]
852 </dt>
853 <dd>
855 Detect renames.
856 If <tt>n</tt> is specified, it is a threshold on the similarity
857 index (i.e. amount of addition/deletions compared to the
858 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
859 delete/add pair to be a rename if more than 90% of the file
860 hasn&#8217;t changed.
861 </p>
862 </dd>
863 <dt class="hdlist1">
864 -C[&lt;n&gt;]
865 </dt>
866 <dt class="hdlist1">
867 --find-copies[=&lt;n&gt;]
868 </dt>
869 <dd>
871 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
872 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
873 </p>
874 </dd>
875 <dt class="hdlist1">
876 --find-copies-harder
877 </dt>
878 <dd>
880 For performance reasons, by default, <tt>-C</tt> option finds copies only
881 if the original file of the copy was modified in the same
882 changeset. This flag makes the command
883 inspect unmodified files as candidates for the source of
884 copy. This is a very expensive operation for large
885 projects, so use it with caution. Giving more than one
886 <tt>-C</tt> option has the same effect.
887 </p>
888 </dd>
889 <dt class="hdlist1">
891 </dt>
892 <dt class="hdlist1">
893 --irreversible-delete
894 </dt>
895 <dd>
897 Omit the preimage for deletes, i.e. print only the header but not
898 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
899 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
900 solely for people who want to just concentrate on reviewing the
901 text after the change. In addition, the output obviously lack
902 enough information to apply such a patch in reverse, even manually,
903 hence the name of the option.
904 </p>
905 <div class="paragraph"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
906 of a delete/create pair.</p></div>
907 </dd>
908 <dt class="hdlist1">
909 -l&lt;num&gt;
910 </dt>
911 <dd>
913 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
914 is the number of potential rename/copy targets. This
915 option prevents rename/copy detection from running if
916 the number of rename/copy targets exceeds the specified
917 number.
918 </p>
919 </dd>
920 <dt class="hdlist1">
921 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
922 </dt>
923 <dd>
925 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
926 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
927 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
928 are Unmerged (<tt>U</tt>), are
929 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
930 Any combination of the filter characters (including none) can be used.
931 When <tt>*</tt> (All-or-none) is added to the combination, all
932 paths are selected if there is any file that matches
933 other criteria in the comparison; if there is no file
934 that matches other criteria, nothing is selected.
935 </p>
936 </dd>
937 <dt class="hdlist1">
938 -S&lt;string&gt;
939 </dt>
940 <dd>
942 Look for differences that introduce or remove an instance of
943 &lt;string&gt;. Note that this is different than the string simply
944 appearing in diff output; see the <em>pickaxe</em> entry in
945 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
946 </p>
947 </dd>
948 <dt class="hdlist1">
949 -G&lt;regex&gt;
950 </dt>
951 <dd>
953 Look for differences whose added or removed line matches
954 the given &lt;regex&gt;.
955 </p>
956 </dd>
957 <dt class="hdlist1">
958 --pickaxe-all
959 </dt>
960 <dd>
962 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
963 changeset, not just the files that contain the change
964 in &lt;string&gt;.
965 </p>
966 </dd>
967 <dt class="hdlist1">
968 --pickaxe-regex
969 </dt>
970 <dd>
972 Make the &lt;string&gt; not a plain string but an extended POSIX
973 regex to match.
974 </p>
975 </dd>
976 <dt class="hdlist1">
977 -O&lt;orderfile&gt;
978 </dt>
979 <dd>
981 Output the patch in the order specified in the
982 &lt;orderfile&gt;, which has one shell glob pattern per line.
983 </p>
984 </dd>
985 <dt class="hdlist1">
987 </dt>
988 <dd>
990 Swap two inputs; that is, show differences from index or
991 on-disk file to tree contents.
992 </p>
993 </dd>
994 <dt class="hdlist1">
995 --relative[=&lt;path&gt;]
996 </dt>
997 <dd>
999 When run from a subdirectory of the project, it can be
1000 told to exclude changes outside the directory and show
1001 pathnames relative to it with this option. When you are
1002 not in a subdirectory (e.g. in a bare repository), you
1003 can name which subdirectory to make the output relative
1004 to by giving a &lt;path&gt; as an argument.
1005 </p>
1006 </dd>
1007 <dt class="hdlist1">
1009 </dt>
1010 <dt class="hdlist1">
1011 --text
1012 </dt>
1013 <dd>
1015 Treat all files as text.
1016 </p>
1017 </dd>
1018 <dt class="hdlist1">
1019 --ignore-space-at-eol
1020 </dt>
1021 <dd>
1023 Ignore changes in whitespace at EOL.
1024 </p>
1025 </dd>
1026 <dt class="hdlist1">
1028 </dt>
1029 <dt class="hdlist1">
1030 --ignore-space-change
1031 </dt>
1032 <dd>
1034 Ignore changes in amount of whitespace. This ignores whitespace
1035 at line end, and considers all other sequences of one or
1036 more whitespace characters to be equivalent.
1037 </p>
1038 </dd>
1039 <dt class="hdlist1">
1041 </dt>
1042 <dt class="hdlist1">
1043 --ignore-all-space
1044 </dt>
1045 <dd>
1047 Ignore whitespace when comparing lines. This ignores
1048 differences even if one line has whitespace where the other
1049 line has none.
1050 </p>
1051 </dd>
1052 <dt class="hdlist1">
1053 --inter-hunk-context=&lt;lines&gt;
1054 </dt>
1055 <dd>
1057 Show the context between diff hunks, up to the specified number
1058 of lines, thereby fusing hunks that are close to each other.
1059 </p>
1060 </dd>
1061 <dt class="hdlist1">
1062 --exit-code
1063 </dt>
1064 <dd>
1066 Make the program exit with codes similar to diff(1).
1067 That is, it exits with 1 if there were differences and
1068 0 means no differences.
1069 </p>
1070 </dd>
1071 <dt class="hdlist1">
1072 --quiet
1073 </dt>
1074 <dd>
1076 Disable all output of the program. Implies <tt>--exit-code</tt>.
1077 </p>
1078 </dd>
1079 <dt class="hdlist1">
1080 --ext-diff
1081 </dt>
1082 <dd>
1084 Allow an external diff helper to be executed. If you set an
1085 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1086 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1087 </p>
1088 </dd>
1089 <dt class="hdlist1">
1090 --no-ext-diff
1091 </dt>
1092 <dd>
1094 Disallow external diff drivers.
1095 </p>
1096 </dd>
1097 <dt class="hdlist1">
1098 --textconv
1099 </dt>
1100 <dt class="hdlist1">
1101 --no-textconv
1102 </dt>
1103 <dd>
1105 Allow (or disallow) external text conversion filters to be run
1106 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1107 details. Because textconv filters are typically a one-way
1108 conversion, the resulting diff is suitable for human
1109 consumption, but cannot be applied. For this reason, textconv
1110 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1111 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1112 diff plumbing commands.
1113 </p>
1114 </dd>
1115 <dt class="hdlist1">
1116 --ignore-submodules[=&lt;when&gt;]
1117 </dt>
1118 <dd>
1120 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1121 either "none", "untracked", "dirty" or "all", which is the default
1122 Using "none" will consider the submodule modified when it either contains
1123 untracked or modified files or its HEAD differs from the commit recorded
1124 in the superproject and can be used to override any settings of the
1125 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1126 "untracked" is used submodules are not considered dirty when they only
1127 contain untracked content (but they are still scanned for modified
1128 content). Using "dirty" ignores all changes to the work tree of submodules,
1129 only changes to the commits stored in the superproject are shown (this was
1130 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1131 </p>
1132 </dd>
1133 <dt class="hdlist1">
1134 --src-prefix=&lt;prefix&gt;
1135 </dt>
1136 <dd>
1138 Show the given source prefix instead of "a/".
1139 </p>
1140 </dd>
1141 <dt class="hdlist1">
1142 --dst-prefix=&lt;prefix&gt;
1143 </dt>
1144 <dd>
1146 Show the given destination prefix instead of "b/".
1147 </p>
1148 </dd>
1149 <dt class="hdlist1">
1150 --no-prefix
1151 </dt>
1152 <dd>
1154 Do not show any source or destination prefix.
1155 </p>
1156 </dd>
1157 </dl></div>
1158 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1159 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1160 <div class="dlist"><dl>
1161 <dt class="hdlist1">
1162 &lt;tree-ish&gt;
1163 </dt>
1164 <dd>
1166 The id of a tree object to diff against.
1167 </p>
1168 </dd>
1169 <dt class="hdlist1">
1170 --cached
1171 </dt>
1172 <dd>
1174 do not consider the on-disk file at all
1175 </p>
1176 </dd>
1177 <dt class="hdlist1">
1179 </dt>
1180 <dd>
1182 By default, files recorded in the index but not checked
1183 out are reported as deleted. This flag makes
1184 <em>git diff-index</em> say that all non-checked-out files are up
1185 to date.
1186 </p>
1187 </dd>
1188 </dl></div>
1189 </div>
1190 <h2 id="_raw_output_format">Raw output format</h2>
1191 <div class="sectionbody">
1192 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1193 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1194 <div class="paragraph"><p>These commands all compare two sets of things; what is
1195 compared differs:</p></div>
1196 <div class="dlist"><dl>
1197 <dt class="hdlist1">
1198 git-diff-index &lt;tree-ish&gt;
1199 </dt>
1200 <dd>
1202 compares the &lt;tree-ish&gt; and the files on the filesystem.
1203 </p>
1204 </dd>
1205 <dt class="hdlist1">
1206 git-diff-index --cached &lt;tree-ish&gt;
1207 </dt>
1208 <dd>
1210 compares the &lt;tree-ish&gt; and the index.
1211 </p>
1212 </dd>
1213 <dt class="hdlist1">
1214 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1215 </dt>
1216 <dd>
1218 compares the trees named by the two arguments.
1219 </p>
1220 </dd>
1221 <dt class="hdlist1">
1222 git-diff-files [&lt;pattern&gt;&#8230;]
1223 </dt>
1224 <dd>
1226 compares the index and the files on the filesystem.
1227 </p>
1228 </dd>
1229 </dl></div>
1230 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1231 what is being compared. After that, all the commands print one output
1232 line per changed file.</p></div>
1233 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1234 <div class="listingblock">
1235 <div class="content">
1236 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1237 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1238 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1239 create :000000 100644 0000000... 1234567... A file4
1240 delete :100644 000000 1234567... 0000000... D file5
1241 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1242 </div></div>
1243 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1244 <div class="olist arabic"><ol class="arabic">
1245 <li>
1247 a colon.
1248 </p>
1249 </li>
1250 <li>
1252 mode for "src"; 000000 if creation or unmerged.
1253 </p>
1254 </li>
1255 <li>
1257 a space.
1258 </p>
1259 </li>
1260 <li>
1262 mode for "dst"; 000000 if deletion or unmerged.
1263 </p>
1264 </li>
1265 <li>
1267 a space.
1268 </p>
1269 </li>
1270 <li>
1272 sha1 for "src"; 0{40} if creation or unmerged.
1273 </p>
1274 </li>
1275 <li>
1277 a space.
1278 </p>
1279 </li>
1280 <li>
1282 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1283 </p>
1284 </li>
1285 <li>
1287 a space.
1288 </p>
1289 </li>
1290 <li>
1292 status, followed by optional "score" number.
1293 </p>
1294 </li>
1295 <li>
1297 a tab or a NUL when <em>-z</em> option is used.
1298 </p>
1299 </li>
1300 <li>
1302 path for "src"
1303 </p>
1304 </li>
1305 <li>
1307 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1308 </p>
1309 </li>
1310 <li>
1312 path for "dst"; only exists for C or R.
1313 </p>
1314 </li>
1315 <li>
1317 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1318 </p>
1319 </li>
1320 </ol></div>
1321 <div class="paragraph"><p>Possible status letters are:</p></div>
1322 <div class="ulist"><ul>
1323 <li>
1325 A: addition of a file
1326 </p>
1327 </li>
1328 <li>
1330 C: copy of a file into a new one
1331 </p>
1332 </li>
1333 <li>
1335 D: deletion of a file
1336 </p>
1337 </li>
1338 <li>
1340 M: modification of the contents or mode of a file
1341 </p>
1342 </li>
1343 <li>
1345 R: renaming of a file
1346 </p>
1347 </li>
1348 <li>
1350 T: change in the type of the file
1351 </p>
1352 </li>
1353 <li>
1355 U: file is unmerged (you must complete the merge before it can
1356 be committed)
1357 </p>
1358 </li>
1359 <li>
1361 X: "unknown" change type (most probably a bug, please report it)
1362 </p>
1363 </li>
1364 </ul></div>
1365 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1366 percentage of similarity between the source and target of the move or
1367 copy), and are the only ones to be so.</p></div>
1368 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1369 and it is out of sync with the index.</p></div>
1370 <div class="paragraph"><p>Example:</p></div>
1371 <div class="listingblock">
1372 <div class="content">
1373 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1374 </div></div>
1375 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1376 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1377 respectively.</p></div>
1378 </div>
1379 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1380 <div class="sectionbody">
1381 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1382 can take <em>-c</em> or <em>--cc</em> option
1383 to generate diff output also for merge commits. The output differs
1384 from the format described above in the following way:</p></div>
1385 <div class="olist arabic"><ol class="arabic">
1386 <li>
1388 there is a colon for each parent
1389 </p>
1390 </li>
1391 <li>
1393 there are more "src" modes and "src" sha1
1394 </p>
1395 </li>
1396 <li>
1398 status is concatenated status characters for each parent
1399 </p>
1400 </li>
1401 <li>
1403 no optional "score" number
1404 </p>
1405 </li>
1406 <li>
1408 single path, only for "dst"
1409 </p>
1410 </li>
1411 </ol></div>
1412 <div class="paragraph"><p>Example:</p></div>
1413 <div class="listingblock">
1414 <div class="content">
1415 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1416 </div></div>
1417 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1418 all parents.</p></div>
1419 </div>
1420 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1421 <div class="sectionbody">
1422 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1423 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1424 "git log" with the "-p" option, they
1425 do not produce the output described above; instead they produce a
1426 patch file. You can customize the creation of such patches via the
1427 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1428 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1429 diff format:</p></div>
1430 <div class="olist arabic"><ol class="arabic">
1431 <li>
1433 It is preceded with a "git diff" header that looks like this:
1434 </p>
1435 <div class="literalblock">
1436 <div class="content">
1437 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1438 </div></div>
1439 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1440 involved. Especially, even for a creation or a deletion,
1441 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1442 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1443 name of the source file of the rename/copy and the name of
1444 the file that rename/copy produces, respectively.</p></div>
1445 </li>
1446 <li>
1448 It is followed by one or more extended header lines:
1449 </p>
1450 <div class="literalblock">
1451 <div class="content">
1452 <pre><tt>old mode &lt;mode&gt;
1453 new mode &lt;mode&gt;
1454 deleted file mode &lt;mode&gt;
1455 new file mode &lt;mode&gt;
1456 copy from &lt;path&gt;
1457 copy to &lt;path&gt;
1458 rename from &lt;path&gt;
1459 rename to &lt;path&gt;
1460 similarity index &lt;number&gt;
1461 dissimilarity index &lt;number&gt;
1462 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1463 </div></div>
1464 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1465 and file permission bits.</p></div>
1466 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1467 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1468 the dissimilarity index is the percentage of changed lines. It
1469 is a rounded down integer, followed by a percent sign. The
1470 similarity index value of 100% is thus reserved for two equal
1471 files, while 100% dissimilarity means that no line from the old
1472 file made it into the new one.</p></div>
1473 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1474 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1475 separate lines indicate the old and the new mode.</p></div>
1476 </li>
1477 <li>
1479 TAB, LF, double quote and backslash characters in pathnames
1480 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1481 If there is need for such substitution then the whole
1482 pathname is put in double quotes.
1483 </p>
1484 </li>
1485 <li>
1487 All the <tt>file1</tt> files in the output refer to files before the
1488 commit, and all the <tt>file2</tt> files refer to files after the commit.
1489 It is incorrect to apply each change to each file sequentially. For
1490 example, this patch will swap a and b:
1491 </p>
1492 <div class="literalblock">
1493 <div class="content">
1494 <pre><tt>diff --git a/a b/b
1495 rename from a
1496 rename to b
1497 diff --git a/b b/a
1498 rename from b
1499 rename to a</tt></pre>
1500 </div></div>
1501 </li>
1502 </ol></div>
1503 </div>
1504 <h2 id="_combined_diff_format">combined diff format</h2>
1505 <div class="sectionbody">
1506 <div class="paragraph"><p>Any diff-generating command can take the &#8216;-c` or <tt>--cc</tt> option to
1507 produce a <em>combined diff</em> when showing a merge. This is the default
1508 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
1509 <a href="git-show.html">git-show(1)</a>. Note also that you can give the `-m&#8217; option to any
1510 of these commands to force generation of diffs with individual parents
1511 of a merge.</p></div>
1512 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
1513 <div class="listingblock">
1514 <div class="content">
1515 <pre><tt>diff --combined describe.c
1516 index fabadb8,cc95eb0..4866510
1517 --- a/describe.c
1518 +++ b/describe.c
1519 @@@ -98,20 -98,12 +98,20 @@@
1520 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1523 - static void describe(char *arg)
1524 -static void describe(struct commit *cmit, int last_one)
1525 ++static void describe(char *arg, int last_one)
1527 + unsigned char sha1[20];
1528 + struct commit *cmit;
1529 struct commit_list *list;
1530 static int initialized = 0;
1531 struct commit_name *n;
1533 + if (get_sha1(arg, sha1) &lt; 0)
1534 + usage(describe_usage);
1535 + cmit = lookup_commit_reference(sha1);
1536 + if (!cmit)
1537 + usage(describe_usage);
1539 if (!initialized) {
1540 initialized = 1;
1541 for_each_ref(get_name);</tt></pre>
1542 </div></div>
1543 <div class="olist arabic"><ol class="arabic">
1544 <li>
1546 It is preceded with a "git diff" header, that looks like
1547 this (when <em>-c</em> option is used):
1548 </p>
1549 <div class="literalblock">
1550 <div class="content">
1551 <pre><tt>diff --combined file</tt></pre>
1552 </div></div>
1553 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1554 <div class="literalblock">
1555 <div class="content">
1556 <pre><tt>diff --cc file</tt></pre>
1557 </div></div>
1558 </li>
1559 <li>
1561 It is followed by one or more extended header lines
1562 (this example shows a merge with two parents):
1563 </p>
1564 <div class="literalblock">
1565 <div class="content">
1566 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1567 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1568 new file mode &lt;mode&gt;
1569 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1570 </div></div>
1571 <div class="paragraph"><p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
1572 the &lt;mode&gt; is different from the rest. Extended headers with
1573 information about detected contents movement (renames and
1574 copying detection) are designed to work with diff of two
1575 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1576 </li>
1577 <li>
1579 It is followed by two-line from-file/to-file header
1580 </p>
1581 <div class="literalblock">
1582 <div class="content">
1583 <pre><tt>--- a/file
1584 +++ b/file</tt></pre>
1585 </div></div>
1586 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1587 format, <tt>/dev/null</tt> is used to signal created or deleted
1588 files.</p></div>
1589 </li>
1590 <li>
1592 Chunk header format is modified to prevent people from
1593 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1594 was created for review of merge commit changes, and was not
1595 meant for apply. The change is similar to the change in the
1596 extended <em>index</em> header:
1597 </p>
1598 <div class="literalblock">
1599 <div class="content">
1600 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1601 </div></div>
1602 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1603 header for combined diff format.</p></div>
1604 </li>
1605 </ol></div>
1606 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1607 files A and B with a single column that has <tt>-</tt> (minus&#8201;&#8212;&#8201;appears in A but removed in B), <tt>+</tt> (plus&#8201;&#8212;&#8201;missing in A but
1608 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1609 compares two or more files file1, file2,&#8230; with one file X, and
1610 shows how X differs from each of fileN. One column for each of
1611 fileN is prepended to the output line to note how X&#8217;s line is
1612 different from it.</p></div>
1613 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1614 fileN but it does not appear in the result. A <tt>+</tt> character
1615 in the column N means that the line appears in the result,
1616 and fileN does not have that line (in other words, the line was
1617 added, from the point of view of that parent).</p></div>
1618 <div class="paragraph"><p>In the above example output, the function signature was changed
1619 from both files (hence two <tt>-</tt> removals from both file1 and
1620 file2, plus <tt>++</tt> to mean one line that was added does not appear
1621 in either file1 nor file2). Also eight other lines are the same
1622 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1623 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1624 merge commit with the merge result (i.e. file1..fileN are the
1625 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1626 two unresolved merge parents with the working tree file
1627 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1628 "their version").</p></div>
1629 </div>
1630 <h2 id="_other_diff_formats">other diff formats</h2>
1631 <div class="sectionbody">
1632 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1633 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1634 output. These options can be combined with other options, such as
1635 <tt>-p</tt>, and are meant for human consumption.</p></div>
1636 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1637 formats the pathnames compactly by combining common prefix and suffix of
1638 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1639 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1640 <div class="listingblock">
1641 <div class="content">
1642 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1643 </div></div>
1644 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1645 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1646 like this:</p></div>
1647 <div class="listingblock">
1648 <div class="content">
1649 <pre><tt>1 2 README
1650 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1651 </div></div>
1652 <div class="paragraph"><p>That is, from left to right:</p></div>
1653 <div class="olist arabic"><ol class="arabic">
1654 <li>
1656 the number of added lines;
1657 </p>
1658 </li>
1659 <li>
1661 a tab;
1662 </p>
1663 </li>
1664 <li>
1666 the number of deleted lines;
1667 </p>
1668 </li>
1669 <li>
1671 a tab;
1672 </p>
1673 </li>
1674 <li>
1676 pathname (possibly with rename/copy information);
1677 </p>
1678 </li>
1679 <li>
1681 a newline.
1682 </p>
1683 </li>
1684 </ol></div>
1685 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1686 <div class="listingblock">
1687 <div class="content">
1688 <pre><tt>1 2 README NUL
1689 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1690 </div></div>
1691 <div class="paragraph"><p>That is:</p></div>
1692 <div class="olist arabic"><ol class="arabic">
1693 <li>
1695 the number of added lines;
1696 </p>
1697 </li>
1698 <li>
1700 a tab;
1701 </p>
1702 </li>
1703 <li>
1705 the number of deleted lines;
1706 </p>
1707 </li>
1708 <li>
1710 a tab;
1711 </p>
1712 </li>
1713 <li>
1715 a NUL (only exists if renamed/copied);
1716 </p>
1717 </li>
1718 <li>
1720 pathname in preimage;
1721 </p>
1722 </li>
1723 <li>
1725 a NUL (only exists if renamed/copied);
1726 </p>
1727 </li>
1728 <li>
1730 pathname in postimage (only exists if renamed/copied);
1731 </p>
1732 </li>
1733 <li>
1735 a NUL.
1736 </p>
1737 </li>
1738 </ol></div>
1739 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1740 scripts that read the output to tell if the current record being read is
1741 a single-path record or a rename/copy record without reading ahead.
1742 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1743 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1744 </div>
1745 <h2 id="_operating_modes">Operating Modes</h2>
1746 <div class="sectionbody">
1747 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
1748 (using the <em>--cached</em> flag) or ask the diff logic to show any files
1749 that don&#8217;t match the stat state as being "tentatively changed". Both
1750 of these operations are very useful indeed.</p></div>
1751 </div>
1752 <h2 id="_cached_mode">Cached Mode</h2>
1753 <div class="sectionbody">
1754 <div class="paragraph"><p>If <em>--cached</em> is specified, it allows you to ask:</p></div>
1755 <div class="literalblock">
1756 <div class="content">
1757 <pre><tt>show me the differences between HEAD and the current index
1758 contents (the ones I'd write using 'git write-tree')</tt></pre>
1759 </div></div>
1760 <div class="paragraph"><p>For example, let&#8217;s say that you have worked on your working directory, updated
1761 some files in the index and are ready to commit. You want to see exactly
1762 <strong>what</strong> you are going to commit, without having to write a new tree
1763 object and compare it that way, and to do that, you just do</p></div>
1764 <div class="literalblock">
1765 <div class="content">
1766 <pre><tt>git diff-index --cached HEAD</tt></pre>
1767 </div></div>
1768 <div class="paragraph"><p>Example: let&#8217;s say I had renamed <tt>commit.c</tt> to <tt>git-commit.c</tt>, and I had
1769 done an <tt>update-index</tt> to make that effective in the index file.
1770 <tt>git diff-files</tt> wouldn&#8217;t show anything at all, since the index file
1771 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
1772 <div class="literalblock">
1773 <div class="content">
1774 <pre><tt>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
1775 -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
1776 +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre>
1777 </div></div>
1778 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
1779 <div class="paragraph"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to
1780 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
1781 nicer for the case where you just want to check where you are.</p></div>
1782 <div class="paragraph"><p>So doing a <tt>git diff-index --cached</tt> is basically very useful when you are
1783 asking yourself "what have I already marked for being committed, and
1784 what&#8217;s the difference to a previous tree".</p></div>
1785 </div>
1786 <h2 id="_non_cached_mode">Non-cached Mode</h2>
1787 <div class="sectionbody">
1788 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
1789 the more useful of the two in that what it does can&#8217;t be emulated with
1790 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that&#8217;s the default mode.
1791 The non-cached version asks the question:</p></div>
1792 <div class="literalblock">
1793 <div class="content">
1794 <pre><tt>show me the differences between HEAD and the currently checked out
1795 tree - index contents _and_ files that aren't up-to-date</tt></pre>
1796 </div></div>
1797 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
1798 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
1799 output to a tee, but with a twist.</p></div>
1800 <div class="paragraph"><p>The twist is that if some file doesn&#8217;t match the index, we don&#8217;t have
1801 a backing store thing for it, and we use the magic "all-zero" sha1 to
1802 show that. So let&#8217;s say that you have edited <tt>kernel/sched.c</tt>, but
1803 have not actually done a <em>git update-index</em> on it yet - there is no
1804 "object" associated with the new state, and you get:</p></div>
1805 <div class="literalblock">
1806 <div class="content">
1807 <pre><tt>torvalds@ppc970:~/v2.6/linux&gt; git diff-index --abbrev HEAD
1808 :100644 100664 7476bb... 000000... kernel/sched.c</tt></pre>
1809 </div></div>
1810 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <tt>kernel/sched.c</tt> has is
1811 not up-to-date and may contain new stuff. The all-zero sha1 means that to
1812 get the real diff, you need to look at the object in the working directory
1813 directly rather than do an object-to-object diff.</p></div>
1814 <div class="admonitionblock">
1815 <table><tr>
1816 <td class="icon">
1817 <div class="title">Note</div>
1818 </td>
1819 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
1820 actually look at the contents of the file at all. So maybe
1821 <tt>kernel/sched.c</tt> hasn&#8217;t actually changed, and it&#8217;s just that you
1822 touched it. In either case, it&#8217;s a note that you need to
1823 <em>git update-index</em> it to make the index be in sync.</td>
1824 </tr></table>
1825 </div>
1826 <div class="admonitionblock">
1827 <table><tr>
1828 <td class="icon">
1829 <div class="title">Note</div>
1830 </td>
1831 <td class="content">You can have a mixture of files show up as "has been updated"
1832 and "is still dirty in the working directory" together. You can always
1833 tell which file is in which state, since the "has been updated" ones
1834 show a valid sha1, and the "not in sync with the index" ones will
1835 always have the special all-zero sha1.</td>
1836 </tr></table>
1837 </div>
1838 </div>
1839 <h2 id="_git">GIT</h2>
1840 <div class="sectionbody">
1841 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1842 </div>
1843 <div id="footer">
1844 <div id="footer-text">
1845 Last updated 2011-07-23 00:49:30 UTC
1846 </div>
1847 </div>
1848 </body>
1849 </html>