Autogenerated HTML docs for v1.7.4-rc2-20-g8c0db6
[git/jnareb-git.git] / git-diff-index.html
blob0e316015f77bb2905f460e46fdce9554abcc567e
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="paragraph"><p><em>git diff-index</em> [-m] [--cached] [&lt;common diff options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</p></div>
418 </div>
419 <h2 id="_description">DESCRIPTION</h2>
420 <div class="sectionbody">
421 <div class="paragraph"><p>Compares the content and mode of the blobs found via a tree
422 object with the content of the current index and, optionally
423 ignoring the stat state of the file on disk. When paths are
424 specified, compares only those named paths. Otherwise all
425 entries in the index are compared.</p></div>
426 </div>
427 <h2 id="_options">OPTIONS</h2>
428 <div class="sectionbody">
429 <div class="dlist"><dl>
430 <dt class="hdlist1">
432 </dt>
433 <dt class="hdlist1">
435 </dt>
436 <dt class="hdlist1">
437 --patch
438 </dt>
439 <dd>
441 Generate patch (see section on generating patches).
443 </p>
444 </dd>
445 <dt class="hdlist1">
446 -U&lt;n&gt;
447 </dt>
448 <dt class="hdlist1">
449 --unified=&lt;n&gt;
450 </dt>
451 <dd>
453 Generate diffs with &lt;n&gt; lines of context instead of
454 the usual three.
455 Implies <tt>-p</tt>.
456 </p>
457 </dd>
458 <dt class="hdlist1">
459 --raw
460 </dt>
461 <dd>
463 Generate the raw format.
464 This is the default.
465 </p>
466 </dd>
467 <dt class="hdlist1">
468 --patch-with-raw
469 </dt>
470 <dd>
472 Synonym for <tt>-p --raw</tt>.
473 </p>
474 </dd>
475 <dt class="hdlist1">
476 --patience
477 </dt>
478 <dd>
480 Generate a diff using the "patience diff" algorithm.
481 </p>
482 </dd>
483 <dt class="hdlist1">
484 --stat[=&lt;width&gt;[,&lt;name-width&gt;]]
485 </dt>
486 <dd>
488 Generate a diffstat. You can override the default
489 output width for 80-column terminal by <tt>--stat=&lt;width&gt;</tt>.
490 The width of the filename part can be controlled by
491 giving another width to it separated by a comma.
492 </p>
493 </dd>
494 <dt class="hdlist1">
495 --numstat
496 </dt>
497 <dd>
499 Similar to <tt>--stat</tt>, but shows number of added and
500 deleted lines in decimal notation and pathname without
501 abbreviation, to make it more machine friendly. For
502 binary files, outputs two <tt>-</tt> instead of saying
503 <tt>0 0</tt>.
504 </p>
505 </dd>
506 <dt class="hdlist1">
507 --shortstat
508 </dt>
509 <dd>
511 Output only the last line of the <tt>--stat</tt> format containing total
512 number of modified files, as well as number of added and deleted
513 lines.
514 </p>
515 </dd>
516 <dt class="hdlist1">
517 --dirstat[=&lt;limit&gt;]
518 </dt>
519 <dd>
521 Output the distribution of relative amount of changes (number of lines added or
522 removed) for each sub-directory. Directories with changes below
523 a cut-off percent (3% by default) are not shown. The cut-off percent
524 can be set with <tt>--dirstat=&lt;limit&gt;</tt>. Changes in a child directory are not
525 counted for the parent directory, unless <tt>--cumulative</tt> is used.
526 </p>
527 </dd>
528 <dt class="hdlist1">
529 --dirstat-by-file[=&lt;limit&gt;]
530 </dt>
531 <dd>
533 Same as <tt>--dirstat</tt>, but counts changed files instead of lines.
534 </p>
535 </dd>
536 <dt class="hdlist1">
537 --summary
538 </dt>
539 <dd>
541 Output a condensed summary of extended header information
542 such as creations, renames and mode changes.
543 </p>
544 </dd>
545 <dt class="hdlist1">
546 --patch-with-stat
547 </dt>
548 <dd>
550 Synonym for <tt>-p --stat</tt>.
551 </p>
552 </dd>
553 <dt class="hdlist1">
555 </dt>
556 <dd>
558 When <tt>--raw</tt>, <tt>--numstat</tt>, <tt>--name-only</tt> or <tt>--name-status</tt> has been
559 given, do not munge pathnames and use NULs as output field terminators.
560 </p>
561 <div class="paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
562 and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>,
563 respectively, and the pathname will be enclosed in double quotes if
564 any of those replacements occurred.</p></div>
565 </dd>
566 <dt class="hdlist1">
567 --name-only
568 </dt>
569 <dd>
571 Show only names of changed files.
572 </p>
573 </dd>
574 <dt class="hdlist1">
575 --name-status
576 </dt>
577 <dd>
579 Show only names and status of changed files. See the description
580 of the <tt>--diff-filter</tt> option on what the status letters mean.
581 </p>
582 </dd>
583 <dt class="hdlist1">
584 --submodule[=&lt;format&gt;]
585 </dt>
586 <dd>
588 Chose the output format for submodule differences. &lt;format&gt; can be one of
589 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
590 is used when this option is not given. <em>log</em> is the default value for this
591 option and lists the commits in that commit range like the <em>summary</em>
592 option of <a href="git-submodule.html">git-submodule(1)</a> does.
593 </p>
594 </dd>
595 <dt class="hdlist1">
596 --color[=&lt;when&gt;]
597 </dt>
598 <dd>
600 Show colored diff.
601 The value must be always (the default), never, or auto.
602 </p>
603 </dd>
604 <dt class="hdlist1">
605 --no-color
606 </dt>
607 <dd>
609 Turn off colored diff, even when the configuration file
610 gives the default to color output.
611 Same as <tt>--color=never</tt>.
612 </p>
613 </dd>
614 <dt class="hdlist1">
615 --word-diff[=&lt;mode&gt;]
616 </dt>
617 <dd>
619 Show a word diff, using the &lt;mode&gt; to delimit changed words.
620 By default, words are delimited by whitespace; see
621 <tt>--word-diff-regex</tt> below. The &lt;mode&gt; defaults to <em>plain</em>, and
622 must be one of:
623 </p>
624 <div class="dlist"><dl>
625 <dt class="hdlist1">
626 color
627 </dt>
628 <dd>
630 Highlight changed words using only colors. Implies <tt>--color</tt>.
631 </p>
632 </dd>
633 <dt class="hdlist1">
634 plain
635 </dt>
636 <dd>
638 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
639 attempts to escape the delimiters if they appear in the input,
640 so the output may be ambiguous.
641 </p>
642 </dd>
643 <dt class="hdlist1">
644 porcelain
645 </dt>
646 <dd>
648 Use a special line-based format intended for script
649 consumption. Added/removed/unchanged runs are printed in the
650 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
651 character at the beginning of the line and extending to the
652 end of the line. Newlines in the input are represented by a
653 tilde <tt>~</tt> on a line of its own.
654 </p>
655 </dd>
656 <dt class="hdlist1">
657 none
658 </dt>
659 <dd>
661 Disable word diff again.
662 </p>
663 </dd>
664 </dl></div>
665 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
666 highlight the changed parts in all modes if enabled.</p></div>
667 </dd>
668 <dt class="hdlist1">
669 --word-diff-regex=&lt;regex&gt;
670 </dt>
671 <dd>
673 Use &lt;regex&gt; to decide what a word is, instead of considering
674 runs of non-whitespace to be a word. Also implies
675 <tt>--word-diff</tt> unless it was already enabled.
676 </p>
677 <div class="paragraph"><p>Every non-overlapping match of the
678 &lt;regex&gt; is considered a word. Anything between these matches is
679 considered whitespace and ignored(!) for the purposes of finding
680 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
681 expression to make sure that it matches all non-whitespace characters.
682 A match that contains a newline is silently truncated(!) at the
683 newline.</p></div>
684 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
685 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
686 overrides any diff driver or configuration setting. Diff drivers
687 override configuration settings.</p></div>
688 </dd>
689 <dt class="hdlist1">
690 --color-words[=&lt;regex&gt;]
691 </dt>
692 <dd>
694 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
695 specified) <tt>--word-diff-regex=&lt;regex&gt;</tt>.
696 </p>
697 </dd>
698 <dt class="hdlist1">
699 --no-renames
700 </dt>
701 <dd>
703 Turn off rename detection, even when the configuration
704 file gives the default to do so.
705 </p>
706 </dd>
707 <dt class="hdlist1">
708 --check
709 </dt>
710 <dd>
712 Warn if changes introduce trailing whitespace
713 or an indent that uses a space before a tab. Exits with
714 non-zero status if problems are found. Not compatible with
715 --exit-code.
716 </p>
717 </dd>
718 <dt class="hdlist1">
719 --full-index
720 </dt>
721 <dd>
723 Instead of the first handful of characters, show the full
724 pre- and post-image blob object names on the "index"
725 line when generating patch format output.
726 </p>
727 </dd>
728 <dt class="hdlist1">
729 --binary
730 </dt>
731 <dd>
733 In addition to <tt>--full-index</tt>, output a binary diff that
734 can be applied with <tt>git-apply</tt>.
735 </p>
736 </dd>
737 <dt class="hdlist1">
738 --abbrev[=&lt;n&gt;]
739 </dt>
740 <dd>
742 Instead of showing the full 40-byte hexadecimal object
743 name in diff-raw format output and diff-tree header
744 lines, show only a partial prefix. This is
745 independent of the <tt>--full-index</tt> option above, which controls
746 the diff-patch output format. Non default number of
747 digits can be specified with <tt>--abbrev=&lt;n&gt;</tt>.
748 </p>
749 </dd>
750 <dt class="hdlist1">
751 -B[&lt;n&gt;][/&lt;m&gt;]
752 </dt>
753 <dt class="hdlist1">
754 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]
755 </dt>
756 <dd>
758 Break complete rewrite changes into pairs of delete and
759 create. This serves two purposes:
760 </p>
761 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
762 not as a series of deletion and insertion mixed together with a very
763 few lines that happen to match textually as the context, but as a
764 single deletion of everything old followed by a single insertion of
765 everything new, and the number <tt>m</tt> controls this aspect of the -B
766 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
767 original should remain in the result for git to consider it a total
768 rewrite (i.e. otherwise the resulting patch will be a series of
769 deletion and insertion mixed together with context lines).</p></div>
770 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
771 source of a rename (usually -M only considers a file that disappeared
772 as the source of a rename), and the number <tt>n</tt> controls this aspect of
773 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
774 addition and deletion compared to 20% or more of the file&#8217;s size are
775 eligible for being picked up as a possible source of a rename to
776 another file.</p></div>
777 </dd>
778 <dt class="hdlist1">
779 -M[&lt;n&gt;]
780 </dt>
781 <dt class="hdlist1">
782 --find-renames[=&lt;n&gt;]
783 </dt>
784 <dd>
786 Detect renames.
787 If <tt>n</tt> is specified, it is a is a threshold on the similarity
788 index (i.e. amount of addition/deletions compared to the
789 file&#8217;s size). For example, <tt>-M90%</tt> means git should consider a
790 delete/add pair to be a rename if more than 90% of the file
791 hasn&#8217;t changed.
792 </p>
793 </dd>
794 <dt class="hdlist1">
795 -C[&lt;n&gt;]
796 </dt>
797 <dt class="hdlist1">
798 --find-copies[=&lt;n&gt;]
799 </dt>
800 <dd>
802 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
803 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M&lt;n&gt;</tt>.
804 </p>
805 </dd>
806 <dt class="hdlist1">
807 --find-copies-harder
808 </dt>
809 <dd>
811 For performance reasons, by default, <tt>-C</tt> option finds copies only
812 if the original file of the copy was modified in the same
813 changeset. This flag makes the command
814 inspect unmodified files as candidates for the source of
815 copy. This is a very expensive operation for large
816 projects, so use it with caution. Giving more than one
817 <tt>-C</tt> option has the same effect.
818 </p>
819 </dd>
820 <dt class="hdlist1">
821 -l&lt;num&gt;
822 </dt>
823 <dd>
825 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
826 is the number of potential rename/copy targets. This
827 option prevents rename/copy detection from running if
828 the number of rename/copy targets exceeds the specified
829 number.
830 </p>
831 </dd>
832 <dt class="hdlist1">
833 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]
834 </dt>
835 <dd>
837 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
838 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
839 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
840 are Unmerged (<tt>U</tt>), are
841 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
842 Any combination of the filter characters (including none) can be used.
843 When <tt>*</tt> (All-or-none) is added to the combination, all
844 paths are selected if there is any file that matches
845 other criteria in the comparison; if there is no file
846 that matches other criteria, nothing is selected.
847 </p>
848 </dd>
849 <dt class="hdlist1">
850 -S&lt;string&gt;
851 </dt>
852 <dd>
854 Look for differences that introduce or remove an instance of
855 &lt;string&gt;. Note that this is different than the string simply
856 appearing in diff output; see the <em>pickaxe</em> entry in
857 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
858 </p>
859 </dd>
860 <dt class="hdlist1">
861 -G&lt;regex&gt;
862 </dt>
863 <dd>
865 Look for differences whose added or removed line matches
866 the given &lt;regex&gt;.
867 </p>
868 </dd>
869 <dt class="hdlist1">
870 --pickaxe-all
871 </dt>
872 <dd>
874 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
875 changeset, not just the files that contain the change
876 in &lt;string&gt;.
877 </p>
878 </dd>
879 <dt class="hdlist1">
880 --pickaxe-regex
881 </dt>
882 <dd>
884 Make the &lt;string&gt; not a plain string but an extended POSIX
885 regex to match.
886 </p>
887 </dd>
888 <dt class="hdlist1">
889 -O&lt;orderfile&gt;
890 </dt>
891 <dd>
893 Output the patch in the order specified in the
894 &lt;orderfile&gt;, which has one shell glob pattern per line.
895 </p>
896 </dd>
897 <dt class="hdlist1">
899 </dt>
900 <dd>
902 Swap two inputs; that is, show differences from index or
903 on-disk file to tree contents.
904 </p>
905 </dd>
906 <dt class="hdlist1">
907 --relative[=&lt;path&gt;]
908 </dt>
909 <dd>
911 When run from a subdirectory of the project, it can be
912 told to exclude changes outside the directory and show
913 pathnames relative to it with this option. When you are
914 not in a subdirectory (e.g. in a bare repository), you
915 can name which subdirectory to make the output relative
916 to by giving a &lt;path&gt; as an argument.
917 </p>
918 </dd>
919 <dt class="hdlist1">
921 </dt>
922 <dt class="hdlist1">
923 --text
924 </dt>
925 <dd>
927 Treat all files as text.
928 </p>
929 </dd>
930 <dt class="hdlist1">
931 --ignore-space-at-eol
932 </dt>
933 <dd>
935 Ignore changes in whitespace at EOL.
936 </p>
937 </dd>
938 <dt class="hdlist1">
940 </dt>
941 <dt class="hdlist1">
942 --ignore-space-change
943 </dt>
944 <dd>
946 Ignore changes in amount of whitespace. This ignores whitespace
947 at line end, and considers all other sequences of one or
948 more whitespace characters to be equivalent.
949 </p>
950 </dd>
951 <dt class="hdlist1">
953 </dt>
954 <dt class="hdlist1">
955 --ignore-all-space
956 </dt>
957 <dd>
959 Ignore whitespace when comparing lines. This ignores
960 differences even if one line has whitespace where the other
961 line has none.
962 </p>
963 </dd>
964 <dt class="hdlist1">
965 --inter-hunk-context=&lt;lines&gt;
966 </dt>
967 <dd>
969 Show the context between diff hunks, up to the specified number
970 of lines, thereby fusing hunks that are close to each other.
971 </p>
972 </dd>
973 <dt class="hdlist1">
974 --exit-code
975 </dt>
976 <dd>
978 Make the program exit with codes similar to diff(1).
979 That is, it exits with 1 if there were differences and
980 0 means no differences.
981 </p>
982 </dd>
983 <dt class="hdlist1">
984 --quiet
985 </dt>
986 <dd>
988 Disable all output of the program. Implies <tt>--exit-code</tt>.
989 </p>
990 </dd>
991 <dt class="hdlist1">
992 --ext-diff
993 </dt>
994 <dd>
996 Allow an external diff helper to be executed. If you set an
997 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
998 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
999 </p>
1000 </dd>
1001 <dt class="hdlist1">
1002 --no-ext-diff
1003 </dt>
1004 <dd>
1006 Disallow external diff drivers.
1007 </p>
1008 </dd>
1009 <dt class="hdlist1">
1010 --ignore-submodules[=&lt;when&gt;]
1011 </dt>
1012 <dd>
1014 Ignore changes to submodules in the diff generation. &lt;when&gt; can be
1015 either "none", "untracked", "dirty" or "all", which is the default
1016 Using "none" will consider the submodule modified when it either contains
1017 untracked or modified files or its HEAD differs from the commit recorded
1018 in the superproject and can be used to override any settings of the
1019 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1020 "untracked" is used submodules are not considered dirty when they only
1021 contain untracked content (but they are still scanned for modified
1022 content). Using "dirty" ignores all changes to the work tree of submodules,
1023 only changes to the commits stored in the superproject are shown (this was
1024 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1025 </p>
1026 </dd>
1027 <dt class="hdlist1">
1028 --src-prefix=&lt;prefix&gt;
1029 </dt>
1030 <dd>
1032 Show the given source prefix instead of "a/".
1033 </p>
1034 </dd>
1035 <dt class="hdlist1">
1036 --dst-prefix=&lt;prefix&gt;
1037 </dt>
1038 <dd>
1040 Show the given destination prefix instead of "b/".
1041 </p>
1042 </dd>
1043 <dt class="hdlist1">
1044 --no-prefix
1045 </dt>
1046 <dd>
1048 Do not show any source or destination prefix.
1049 </p>
1050 </dd>
1051 </dl></div>
1052 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1053 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1054 <div class="dlist"><dl>
1055 <dt class="hdlist1">
1056 &lt;tree-ish&gt;
1057 </dt>
1058 <dd>
1060 The id of a tree object to diff against.
1061 </p>
1062 </dd>
1063 <dt class="hdlist1">
1064 --cached
1065 </dt>
1066 <dd>
1068 do not consider the on-disk file at all
1069 </p>
1070 </dd>
1071 <dt class="hdlist1">
1073 </dt>
1074 <dd>
1076 By default, files recorded in the index but not checked
1077 out are reported as deleted. This flag makes
1078 <em>git diff-index</em> say that all non-checked-out files are up
1079 to date.
1080 </p>
1081 </dd>
1082 </dl></div>
1083 </div>
1084 <h2 id="_raw_output_format">Raw output format</h2>
1085 <div class="sectionbody">
1086 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1087 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1088 <div class="paragraph"><p>These commands all compare two sets of things; what is
1089 compared differs:</p></div>
1090 <div class="dlist"><dl>
1091 <dt class="hdlist1">
1092 git-diff-index &lt;tree-ish&gt;
1093 </dt>
1094 <dd>
1096 compares the &lt;tree-ish&gt; and the files on the filesystem.
1097 </p>
1098 </dd>
1099 <dt class="hdlist1">
1100 git-diff-index --cached &lt;tree-ish&gt;
1101 </dt>
1102 <dd>
1104 compares the &lt;tree-ish&gt; and the index.
1105 </p>
1106 </dd>
1107 <dt class="hdlist1">
1108 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1109 </dt>
1110 <dd>
1112 compares the trees named by the two arguments.
1113 </p>
1114 </dd>
1115 <dt class="hdlist1">
1116 git-diff-files [&lt;pattern&gt;&#8230;]
1117 </dt>
1118 <dd>
1120 compares the index and the files on the filesystem.
1121 </p>
1122 </dd>
1123 </dl></div>
1124 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1125 what is being compared. After that, all the commands print one output
1126 line per changed file.</p></div>
1127 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1128 <div class="listingblock">
1129 <div class="content">
1130 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1131 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1132 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1133 create :000000 100644 0000000... 1234567... A file4
1134 delete :100644 000000 1234567... 0000000... D file5
1135 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1136 </div></div>
1137 <div class="paragraph"><p>That is, from the left to the right:</p></div>
1138 <div class="olist arabic"><ol class="arabic">
1139 <li>
1141 a colon.
1142 </p>
1143 </li>
1144 <li>
1146 mode for "src"; 000000 if creation or unmerged.
1147 </p>
1148 </li>
1149 <li>
1151 a space.
1152 </p>
1153 </li>
1154 <li>
1156 mode for "dst"; 000000 if deletion or unmerged.
1157 </p>
1158 </li>
1159 <li>
1161 a space.
1162 </p>
1163 </li>
1164 <li>
1166 sha1 for "src"; 0{40} if creation or unmerged.
1167 </p>
1168 </li>
1169 <li>
1171 a space.
1172 </p>
1173 </li>
1174 <li>
1176 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1177 </p>
1178 </li>
1179 <li>
1181 a space.
1182 </p>
1183 </li>
1184 <li>
1186 status, followed by optional "score" number.
1187 </p>
1188 </li>
1189 <li>
1191 a tab or a NUL when <em>-z</em> option is used.
1192 </p>
1193 </li>
1194 <li>
1196 path for "src"
1197 </p>
1198 </li>
1199 <li>
1201 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1202 </p>
1203 </li>
1204 <li>
1206 path for "dst"; only exists for C or R.
1207 </p>
1208 </li>
1209 <li>
1211 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1212 </p>
1213 </li>
1214 </ol></div>
1215 <div class="paragraph"><p>Possible status letters are:</p></div>
1216 <div class="ulist"><ul>
1217 <li>
1219 A: addition of a file
1220 </p>
1221 </li>
1222 <li>
1224 C: copy of a file into a new one
1225 </p>
1226 </li>
1227 <li>
1229 D: deletion of a file
1230 </p>
1231 </li>
1232 <li>
1234 M: modification of the contents or mode of a file
1235 </p>
1236 </li>
1237 <li>
1239 R: renaming of a file
1240 </p>
1241 </li>
1242 <li>
1244 T: change in the type of the file
1245 </p>
1246 </li>
1247 <li>
1249 U: file is unmerged (you must complete the merge before it can
1250 be committed)
1251 </p>
1252 </li>
1253 <li>
1255 X: "unknown" change type (most probably a bug, please report it)
1256 </p>
1257 </li>
1258 </ul></div>
1259 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
1260 percentage of similarity between the source and target of the move or
1261 copy), and are the only ones to be so.</p></div>
1262 <div class="paragraph"><p>&lt;sha1&gt; is shown as all 0&#8217;s if a file is new on the filesystem
1263 and it is out of sync with the index.</p></div>
1264 <div class="paragraph"><p>Example:</p></div>
1265 <div class="listingblock">
1266 <div class="content">
1267 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1268 </div></div>
1269 <div class="paragraph"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1270 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1271 respectively.</p></div>
1272 </div>
1273 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1274 <div class="sectionbody">
1275 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1276 can take <em>-c</em> or <em>--cc</em> option
1277 to generate diff output also for merge commits. The output differs
1278 from the format described above in the following way:</p></div>
1279 <div class="olist arabic"><ol class="arabic">
1280 <li>
1282 there is a colon for each parent
1283 </p>
1284 </li>
1285 <li>
1287 there are more "src" modes and "src" sha1
1288 </p>
1289 </li>
1290 <li>
1292 status is concatenated status characters for each parent
1293 </p>
1294 </li>
1295 <li>
1297 no optional "score" number
1298 </p>
1299 </li>
1300 <li>
1302 single path, only for "dst"
1303 </p>
1304 </li>
1305 </ol></div>
1306 <div class="paragraph"><p>Example:</p></div>
1307 <div class="listingblock">
1308 <div class="content">
1309 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1310 </div></div>
1311 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
1312 all parents.</p></div>
1313 </div>
1314 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1315 <div class="sectionbody">
1316 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1317 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1318 "git log" with the "-p" option, they
1319 do not produce the output described above; instead they produce a
1320 patch file. You can customize the creation of such patches via the
1321 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1322 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
1323 diff format:</p></div>
1324 <div class="olist arabic"><ol class="arabic">
1325 <li>
1327 It is preceded with a "git diff" header that looks like this:
1328 </p>
1329 <div class="literalblock">
1330 <div class="content">
1331 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1332 </div></div>
1333 <div class="paragraph"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1334 involved. Especially, even for a creation or a deletion,
1335 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1336 <div class="paragraph"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1337 name of the source file of the rename/copy and the name of
1338 the file that rename/copy produces, respectively.</p></div>
1339 </li>
1340 <li>
1342 It is followed by one or more extended header lines:
1343 </p>
1344 <div class="literalblock">
1345 <div class="content">
1346 <pre><tt>old mode &lt;mode&gt;
1347 new mode &lt;mode&gt;
1348 deleted file mode &lt;mode&gt;
1349 new file mode &lt;mode&gt;
1350 copy from &lt;path&gt;
1351 copy to &lt;path&gt;
1352 rename from &lt;path&gt;
1353 rename to &lt;path&gt;
1354 similarity index &lt;number&gt;
1355 dissimilarity index &lt;number&gt;
1356 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1357 </div></div>
1358 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
1359 and file permission bits.</p></div>
1360 <div class="paragraph"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
1361 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
1362 the dissimilarity index is the percentage of changed lines. It
1363 is a rounded down integer, followed by a percent sign. The
1364 similarity index value of 100% is thus reserved for two equal
1365 files, while 100% dissimilarity means that no line from the old
1366 file made it into the new one.</p></div>
1367 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
1368 The &lt;mode&gt; is included if the file mode does not change; otherwise,
1369 separate lines indicate the old and the new mode.</p></div>
1370 </li>
1371 <li>
1373 TAB, LF, double quote and backslash characters in pathnames
1374 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1375 If there is need for such substitution then the whole
1376 pathname is put in double quotes.
1377 </p>
1378 </li>
1379 <li>
1381 All the <tt>file1</tt> files in the output refer to files before the
1382 commit, and all the <tt>file2</tt> files refer to files after the commit.
1383 It is incorrect to apply each change to each file sequentially. For
1384 example, this patch will swap a and b:
1385 </p>
1386 <div class="literalblock">
1387 <div class="content">
1388 <pre><tt>diff --git a/a b/b
1389 rename from a
1390 rename to b
1391 diff --git a/b b/a
1392 rename from b
1393 rename to a</tt></pre>
1394 </div></div>
1395 </li>
1396 </ol></div>
1397 </div>
1398 <h2 id="_combined_diff_format">combined diff format</h2>
1399 <div class="sectionbody">
1400 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
1401 <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1402 with "git log -p", this is the default format; you can force showing
1403 full diff with the <em>-m</em> option.
1404 A <em>combined diff</em> format looks like this:</p></div>
1405 <div class="listingblock">
1406 <div class="content">
1407 <pre><tt>diff --combined describe.c
1408 index fabadb8,cc95eb0..4866510
1409 --- a/describe.c
1410 +++ b/describe.c
1411 @@@ -98,20 -98,12 +98,20 @@@
1412 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1415 - static void describe(char *arg)
1416 -static void describe(struct commit *cmit, int last_one)
1417 ++static void describe(char *arg, int last_one)
1419 + unsigned char sha1[20];
1420 + struct commit *cmit;
1421 struct commit_list *list;
1422 static int initialized = 0;
1423 struct commit_name *n;
1425 + if (get_sha1(arg, sha1) &lt; 0)
1426 + usage(describe_usage);
1427 + cmit = lookup_commit_reference(sha1);
1428 + if (!cmit)
1429 + usage(describe_usage);
1431 if (!initialized) {
1432 initialized = 1;
1433 for_each_ref(get_name);</tt></pre>
1434 </div></div>
1435 <div class="olist arabic"><ol class="arabic">
1436 <li>
1438 It is preceded with a "git diff" header, that looks like
1439 this (when <em>-c</em> option is used):
1440 </p>
1441 <div class="literalblock">
1442 <div class="content">
1443 <pre><tt>diff --combined file</tt></pre>
1444 </div></div>
1445 <div class="paragraph"><p>or like this (when <em>--cc</em> option is used):</p></div>
1446 <div class="literalblock">
1447 <div class="content">
1448 <pre><tt>diff --cc file</tt></pre>
1449 </div></div>
1450 </li>
1451 <li>
1453 It is followed by one or more extended header lines
1454 (this example shows a merge with two parents):
1455 </p>
1456 <div class="literalblock">
1457 <div class="content">
1458 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1459 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1460 new file mode &lt;mode&gt;
1461 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1462 </div></div>
1463 <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
1464 the &lt;mode&gt; is different from the rest. Extended headers with
1465 information about detected contents movement (renames and
1466 copying detection) are designed to work with diff of two
1467 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1468 </li>
1469 <li>
1471 It is followed by two-line from-file/to-file header
1472 </p>
1473 <div class="literalblock">
1474 <div class="content">
1475 <pre><tt>--- a/file
1476 +++ b/file</tt></pre>
1477 </div></div>
1478 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
1479 format, <tt>/dev/null</tt> is used to signal created or deleted
1480 files.</p></div>
1481 </li>
1482 <li>
1484 Chunk header format is modified to prevent people from
1485 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1486 was created for review of merge commit changes, and was not
1487 meant for apply. The change is similar to the change in the
1488 extended <em>index</em> header:
1489 </p>
1490 <div class="literalblock">
1491 <div class="content">
1492 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1493 </div></div>
1494 <div class="paragraph"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1495 header for combined diff format.</p></div>
1496 </li>
1497 </ol></div>
1498 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1499 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
1500 added to B), or <tt>" "</tt> (space&#8201;&#8212;&#8201;unchanged) prefix, this format
1501 compares two or more files file1, file2,&#8230; with one file X, and
1502 shows how X differs from each of fileN. One column for each of
1503 fileN is prepended to the output line to note how X&#8217;s line is
1504 different from it.</p></div>
1505 <div class="paragraph"><p>A <tt>-</tt> character in the column N means that the line appears in
1506 fileN but it does not appear in the result. A <tt>+</tt> character
1507 in the column N means that the line appears in the result,
1508 and fileN does not have that line (in other words, the line was
1509 added, from the point of view of that parent).</p></div>
1510 <div class="paragraph"><p>In the above example output, the function signature was changed
1511 from both files (hence two <tt>-</tt> removals from both file1 and
1512 file2, plus <tt>++</tt> to mean one line that was added does not appear
1513 in either file1 nor file2). Also eight other lines are the same
1514 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1515 <div class="paragraph"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1516 merge commit with the merge result (i.e. file1..fileN are the
1517 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1518 two unresolved merge parents with the working tree file
1519 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1520 "their version").</p></div>
1521 </div>
1522 <h2 id="_other_diff_formats">other diff formats</h2>
1523 <div class="sectionbody">
1524 <div class="paragraph"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1525 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1526 output. These options can be combined with other options, such as
1527 <tt>-p</tt>, and are meant for human consumption.</p></div>
1528 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1529 formats the pathnames compactly by combining common prefix and suffix of
1530 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1531 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1532 <div class="listingblock">
1533 <div class="content">
1534 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1535 </div></div>
1536 <div class="paragraph"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1537 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1538 like this:</p></div>
1539 <div class="listingblock">
1540 <div class="content">
1541 <pre><tt>1 2 README
1542 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1543 </div></div>
1544 <div class="paragraph"><p>That is, from left to right:</p></div>
1545 <div class="olist arabic"><ol class="arabic">
1546 <li>
1548 the number of added lines;
1549 </p>
1550 </li>
1551 <li>
1553 a tab;
1554 </p>
1555 </li>
1556 <li>
1558 the number of deleted lines;
1559 </p>
1560 </li>
1561 <li>
1563 a tab;
1564 </p>
1565 </li>
1566 <li>
1568 pathname (possibly with rename/copy information);
1569 </p>
1570 </li>
1571 <li>
1573 a newline.
1574 </p>
1575 </li>
1576 </ol></div>
1577 <div class="paragraph"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1578 <div class="listingblock">
1579 <div class="content">
1580 <pre><tt>1 2 README NUL
1581 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1582 </div></div>
1583 <div class="paragraph"><p>That is:</p></div>
1584 <div class="olist arabic"><ol class="arabic">
1585 <li>
1587 the number of added lines;
1588 </p>
1589 </li>
1590 <li>
1592 a tab;
1593 </p>
1594 </li>
1595 <li>
1597 the number of deleted lines;
1598 </p>
1599 </li>
1600 <li>
1602 a tab;
1603 </p>
1604 </li>
1605 <li>
1607 a NUL (only exists if renamed/copied);
1608 </p>
1609 </li>
1610 <li>
1612 pathname in preimage;
1613 </p>
1614 </li>
1615 <li>
1617 a NUL (only exists if renamed/copied);
1618 </p>
1619 </li>
1620 <li>
1622 pathname in postimage (only exists if renamed/copied);
1623 </p>
1624 </li>
1625 <li>
1627 a NUL.
1628 </p>
1629 </li>
1630 </ol></div>
1631 <div class="paragraph"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1632 scripts that read the output to tell if the current record being read is
1633 a single-path record or a rename/copy record without reading ahead.
1634 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1635 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1636 </div>
1637 <h2 id="_operating_modes">Operating Modes</h2>
1638 <div class="sectionbody">
1639 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
1640 (using the <em>--cached</em> flag) or ask the diff logic to show any files
1641 that don&#8217;t match the stat state as being "tentatively changed". Both
1642 of these operations are very useful indeed.</p></div>
1643 </div>
1644 <h2 id="_cached_mode">Cached Mode</h2>
1645 <div class="sectionbody">
1646 <div class="paragraph"><p>If <em>--cached</em> is specified, it allows you to ask:</p></div>
1647 <div class="literalblock">
1648 <div class="content">
1649 <pre><tt>show me the differences between HEAD and the current index
1650 contents (the ones I'd write using 'git write-tree')</tt></pre>
1651 </div></div>
1652 <div class="paragraph"><p>For example, let&#8217;s say that you have worked on your working directory, updated
1653 some files in the index and are ready to commit. You want to see exactly
1654 <strong>what</strong> you are going to commit, without having to write a new tree
1655 object and compare it that way, and to do that, you just do</p></div>
1656 <div class="literalblock">
1657 <div class="content">
1658 <pre><tt>git diff-index --cached HEAD</tt></pre>
1659 </div></div>
1660 <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
1661 done an <tt>update-index</tt> to make that effective in the index file.
1662 <tt>git diff-files</tt> wouldn&#8217;t show anything at all, since the index file
1663 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
1664 <div class="literalblock">
1665 <div class="content">
1666 <pre><tt>torvalds@ppc970:~/git&gt; git diff-index --cached HEAD
1667 -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
1668 +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre>
1669 </div></div>
1670 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
1671 <div class="paragraph"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to
1672 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
1673 nicer for the case where you just want to check where you are.</p></div>
1674 <div class="paragraph"><p>So doing a <tt>git diff-index --cached</tt> is basically very useful when you are
1675 asking yourself "what have I already marked for being committed, and
1676 what&#8217;s the difference to a previous tree".</p></div>
1677 </div>
1678 <h2 id="_non_cached_mode">Non-cached Mode</h2>
1679 <div class="sectionbody">
1680 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
1681 the more useful of the two in that what it does can&#8217;t be emulated with
1682 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that&#8217;s the default mode.
1683 The non-cached version asks the question:</p></div>
1684 <div class="literalblock">
1685 <div class="content">
1686 <pre><tt>show me the differences between HEAD and the currently checked out
1687 tree - index contents _and_ files that aren't up-to-date</tt></pre>
1688 </div></div>
1689 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
1690 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
1691 output to a tee, but with a twist.</p></div>
1692 <div class="paragraph"><p>The twist is that if some file doesn&#8217;t match the index, we don&#8217;t have
1693 a backing store thing for it, and we use the magic "all-zero" sha1 to
1694 show that. So let&#8217;s say that you have edited <tt>kernel/sched.c</tt>, but
1695 have not actually done a <em>git update-index</em> on it yet - there is no
1696 "object" associated with the new state, and you get:</p></div>
1697 <div class="literalblock">
1698 <div class="content">
1699 <pre><tt>torvalds@ppc970:~/v2.6/linux&gt; git diff-index HEAD
1700 *100644-&gt;100664 blob 7476bb......-&gt;000000...... kernel/sched.c</tt></pre>
1701 </div></div>
1702 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <tt>kernel/sched.c</tt> has is
1703 not up-to-date and may contain new stuff. The all-zero sha1 means that to
1704 get the real diff, you need to look at the object in the working directory
1705 directly rather than do an object-to-object diff.</p></div>
1706 <div class="admonitionblock">
1707 <table><tr>
1708 <td class="icon">
1709 <div class="title">Note</div>
1710 </td>
1711 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
1712 actually look at the contents of the file at all. So maybe
1713 <tt>kernel/sched.c</tt> hasn&#8217;t actually changed, and it&#8217;s just that you
1714 touched it. In either case, it&#8217;s a note that you need to
1715 <em>git update-index</em> it to make the index be in sync.</td>
1716 </tr></table>
1717 </div>
1718 <div class="admonitionblock">
1719 <table><tr>
1720 <td class="icon">
1721 <div class="title">Note</div>
1722 </td>
1723 <td class="content">You can have a mixture of files show up as "has been updated"
1724 and "is still dirty in the working directory" together. You can always
1725 tell which file is in which state, since the "has been updated" ones
1726 show a valid sha1, and the "not in sync with the index" ones will
1727 always have the special all-zero sha1.</td>
1728 </tr></table>
1729 </div>
1730 </div>
1731 <h2 id="_author">Author</h2>
1732 <div class="sectionbody">
1733 <div class="paragraph"><p>Written by Linus Torvalds &lt;<a href="mailto:torvalds@osdl.org">torvalds@osdl.org</a>&gt;</p></div>
1734 </div>
1735 <h2 id="_documentation">Documentation</h2>
1736 <div class="sectionbody">
1737 <div class="paragraph"><p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;<a href="mailto:git@vger.kernel.org">git@vger.kernel.org</a>&gt;.</p></div>
1738 </div>
1739 <h2 id="_git">GIT</h2>
1740 <div class="sectionbody">
1741 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1742 </div>
1743 <div id="footer">
1744 <div id="footer-text">
1745 Last updated 2010-01-21 17:44:19 UTC
1746 </div>
1747 </div>
1748 </body>
1749 </html>