"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 8.6.10" />
8 <title>git-diff-index(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
11
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
15 }
16
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
25 }
26
27 body {
28 margin: 1em 5% 1em 5%;
29 }
30
31 a {
32 color: blue;
33 text-decoration: underline;
34 }
35 a:visited {
36 color: fuchsia;
37 }
38
39 em {
40 font-style: italic;
41 color: navy;
42 }
43
44 strong {
45 font-weight: bold;
46 color: #083194;
47 }
48
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
54 }
55
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
58 }
59 h2 {
60 padding-top: 0.5em;
61 }
62 h3 {
63 float: left;
64 }
65 h3 + * {
66 clear: left;
67 }
68 h5 {
69 font-size: 1.0em;
70 }
71
72 div.sectionbody {
73 margin-left: 0;
74 }
75
76 hr {
77 border: 1px solid silver;
78 }
79
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
83 }
84
85 ul, ol, li > p {
86 margin-top: 0;
87 }
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
90
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
97 }
98 pre {
99 white-space: pre-wrap;
100 }
101
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
106 }
107 #email {
108 }
109 #revnumber, #revdate, #revremark {
110 }
111
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
117 }
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
121 }
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
125 }
126
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
130 }
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
136 }
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
142 }
143
144 div.content { /* Block element content. */
145 padding: 0;
146 }
147
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
155 }
156 div.title + * {
157 margin-top: 0;
158 }
159
160 td div.title:first-child {
161 margin-top: 0.0em;
162 }
163 div.content div.title:first-child {
164 margin-top: 0.0em;
165 }
166 div.content + div.title {
167 margin-top: 0.0em;
168 }
169
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
175 }
176
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
182 }
183
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
190 }
191
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
195 }
196
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
200 }
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
204 }
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
208 }
209
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
217 }
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
221 }
222
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
226 }
227
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
231
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
235 }
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
241 }
242 dd > *:first-child {
243 margin-top: 0.1em;
244 }
245
246 ul, ol {
247 list-style-position: outside;
248 }
249 ol.arabic {
250 list-style-type: decimal;
251 }
252 ol.loweralpha {
253 list-style-type: lower-alpha;
254 }
255 ol.upperalpha {
256 list-style-type: upper-alpha;
257 }
258 ol.lowerroman {
259 list-style-type: lower-roman;
260 }
261 ol.upperroman {
262 list-style-type: upper-roman;
263 }
264
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
270 }
271
272 tfoot {
273 font-weight: bold;
274 }
275 td > div.verse {
276 white-space: pre;
277 }
278
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
282 }
283 div.hdlist tr {
284 padding-bottom: 15px;
285 }
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
288 }
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
294 }
295 td.hdlist2 {
296 vertical-align: top;
297 }
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
301 }
302
303 .comment {
304 background: yellow;
305 }
306
307 .footnote, .footnoteref {
308 font-size: 0.8em;
309 }
310
311 span.footnote, span.footnoteref {
312 vertical-align: super;
313 }
314
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
318 }
319
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
322 }
323
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
332 }
333
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
338 }
339 div.colist td img {
340 margin-top: 0.3em;
341 }
342
343 @media print {
344 #footer-badges { display: none; }
345 }
346
347 #toc {
348 margin-bottom: 2.5em;
349 }
350
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
357 }
358
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
362 }
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
366 }
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
370 }
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
374 }
375
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
392
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
409
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
412
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
416
417 div.unbreakable { page-break-inside: avoid; }
418
419
420 /*
421 * xhtml11 specific
422 *
423 * */
424
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
428 }
429 div.tableblock > table {
430 border: 3px solid #527bbd;
431 }
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
435 }
436 p.table {
437 margin-top: 0;
438 }
439 /* Because the table frame attribute is overriden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
442 }
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
446 }
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
450 }
451
452
453 /*
454 * html5 specific
455 *
456 * */
457
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
461 }
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
465 }
466 p.tableblock {
467 margin-top: 0;
468 }
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
475 }
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
481 }
482
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
486 }
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
490 }
491 table.tableblock.frame-none {
492 border-style: hidden;
493 }
494
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
497 }
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
500 }
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
503 }
504
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
507 }
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
510 }
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
513 }
514
515
516 /*
517 * manpage specific
518 *
519 * */
520
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
526 }
527 body.manpage h2 {
528 border-style: none;
529 }
530 body.manpage div.sectionbody {
531 margin-left: 3em;
532 }
533
534 @media print {
535 body.manpage div#toc { display: none; }
536 }
537
538
539 </style>
540 <script type="text/javascript">
541 /*<+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
593 }
594 iterate(i);
595 }
596 }
597 }
598 iterate(el);
599 return result;
600 }
601
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
605 }
606
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
616 }
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
619 }
620
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
634 }
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
637 },
638
639
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
643
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
646 */
647
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
654 }
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
660 }
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
663 }
664
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
682 }
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
689 }
690 }
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
703 }
704 }
705 }
706 },
707
708 install: function(toclevels) {
709 var timerId;
710
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
715 }
716 }
717
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
721 }
722
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
728 }
729
730 }
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-diff-index(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-diff-index -
743 Compare a tree to the working tree or index
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="verseblock">
752 <pre class="content"><em>git diff-index</em> [-m] [--cached] [<common diff options>] <tree-ish> [<path>…]</pre>
753 <div class="attribution">
754 </div></div>
755 </div>
756 </div>
757 <div class="sect1">
758 <h2 id="_description">DESCRIPTION</h2>
759 <div class="sectionbody">
760 <div class="paragraph"><p>Compares the content and mode of the blobs found in a tree object
761 with the corresponding tracked files in the working tree, or with the
762 corresponding paths in the index. When <path> arguments are present,
763 compares only paths matching those patterns. Otherwise all tracked
764 files are compared.</p></div>
765 </div>
766 </div>
767 <div class="sect1">
768 <h2 id="_options">OPTIONS</h2>
769 <div class="sectionbody">
770 <div class="dlist"><dl>
771 <dt class="hdlist1">
772 -p
773 </dt>
774 <dt class="hdlist1">
775 -u
776 </dt>
777 <dt class="hdlist1">
778 --patch
779 </dt>
780 <dd>
781 <p>
782 Generate patch (see section on generating patches).
783 </p>
784 </dd>
785 <dt class="hdlist1">
786 -s
787 </dt>
788 <dt class="hdlist1">
789 --no-patch
790 </dt>
791 <dd>
792 <p>
793 Suppress diff output. Useful for commands like <code>git show</code> that
794 show the patch by default, or to cancel the effect of <code>--patch</code>.
795 </p>
796 </dd>
797 <dt class="hdlist1">
798 -U<n>
799 </dt>
800 <dt class="hdlist1">
801 --unified=<n>
802 </dt>
803 <dd>
804 <p>
805 Generate diffs with <n> lines of context instead of
806 the usual three.
807 Implies <code>-p</code>.
808 </p>
809 </dd>
810 <dt class="hdlist1">
811 --raw
812 </dt>
813 <dd>
814 <p>
815 Generate the diff in raw format.
816 This is the default.
817 </p>
818 </dd>
819 <dt class="hdlist1">
820 --patch-with-raw
821 </dt>
822 <dd>
823 <p>
824 Synonym for <code>-p --raw</code>.
825 </p>
826 </dd>
827 <dt class="hdlist1">
828 --indent-heuristic
829 </dt>
830 <dd>
831 <p>
832 Enable the heuristic that shifts diff hunk boundaries to make patches
833 easier to read. This is the default.
834 </p>
835 </dd>
836 <dt class="hdlist1">
837 --no-indent-heuristic
838 </dt>
839 <dd>
840 <p>
841 Disable the indent heuristic.
842 </p>
843 </dd>
844 <dt class="hdlist1">
845 --minimal
846 </dt>
847 <dd>
848 <p>
849 Spend extra time to make sure the smallest possible
850 diff is produced.
851 </p>
852 </dd>
853 <dt class="hdlist1">
854 --patience
855 </dt>
856 <dd>
857 <p>
858 Generate a diff using the "patience diff" algorithm.
859 </p>
860 </dd>
861 <dt class="hdlist1">
862 --histogram
863 </dt>
864 <dd>
865 <p>
866 Generate a diff using the "histogram diff" algorithm.
867 </p>
868 </dd>
869 <dt class="hdlist1">
870 --anchored=<text>
871 </dt>
872 <dd>
873 <p>
874 Generate a diff using the "anchored diff" algorithm.
875 </p>
876 <div class="paragraph"><p>This option may be specified more than once.</p></div>
877 <div class="paragraph"><p>If a line exists in both the source and destination, exists only once,
878 and starts with this text, this algorithm attempts to prevent it from
879 appearing as a deletion or addition in the output. It uses the "patience
880 diff" algorithm internally.</p></div>
881 </dd>
882 <dt class="hdlist1">
883 --diff-algorithm={patience|minimal|histogram|myers}
884 </dt>
885 <dd>
886 <p>
887 Choose a diff algorithm. The variants are as follows:
888 </p>
889 <div class="openblock">
890 <div class="content">
891 <div class="dlist"><dl>
892 <dt class="hdlist1">
893 <code>default</code>, <code>myers</code>
894 </dt>
895 <dd>
896 <p>
897 The basic greedy diff algorithm. Currently, this is the default.
898 </p>
899 </dd>
900 <dt class="hdlist1">
901 <code>minimal</code>
902 </dt>
903 <dd>
904 <p>
905 Spend extra time to make sure the smallest possible diff is
906 produced.
907 </p>
908 </dd>
909 <dt class="hdlist1">
910 <code>patience</code>
911 </dt>
912 <dd>
913 <p>
914 Use "patience diff" algorithm when generating patches.
915 </p>
916 </dd>
917 <dt class="hdlist1">
918 <code>histogram</code>
919 </dt>
920 <dd>
921 <p>
922 This algorithm extends the patience algorithm to "support
923 low-occurrence common elements".
924 </p>
925 </dd>
926 </dl></div>
927 </div></div>
928 <div class="paragraph"><p>For instance, if you configured the <code>diff.algorithm</code> variable to a
929 non-default value and want to use the default one, then you
930 have to use <code>--diff-algorithm=default</code> option.</p></div>
931 </dd>
932 <dt class="hdlist1">
933 --stat[=<width>[,<name-width>[,<count>]]]
934 </dt>
935 <dd>
936 <p>
937 Generate a diffstat. By default, as much space as necessary
938 will be used for the filename part, and the rest for the graph
939 part. Maximum width defaults to terminal width, or 80 columns
940 if not connected to a terminal, and can be overridden by
941 <code><width></code>. The width of the filename part can be limited by
942 giving another width <code><name-width></code> after a comma. The width
943 of the graph part can be limited by using
944 <code>--stat-graph-width=<width></code> (affects all commands generating
945 a stat graph) or by setting <code>diff.statGraphWidth=<width></code>
946 (does not affect <code>git format-patch</code>).
947 By giving a third parameter <code><count></code>, you can limit the
948 output to the first <code><count></code> lines, followed by <code>...</code> if
949 there are more.
950 </p>
951 <div class="paragraph"><p>These parameters can also be set individually with <code>--stat-width=<width></code>,
952 <code>--stat-name-width=<name-width></code> and <code>--stat-count=<count></code>.</p></div>
953 </dd>
954 <dt class="hdlist1">
955 --compact-summary
956 </dt>
957 <dd>
958 <p>
959 Output a condensed summary of extended header information such
960 as file creations or deletions ("new" or "gone", optionally "+l"
961 if it’s a symlink) and mode changes ("+x" or "-x" for adding
962 or removing executable bit respectively) in diffstat. The
963 information is put between the filename part and the graph
964 part. Implies <code>--stat</code>.
965 </p>
966 </dd>
967 <dt class="hdlist1">
968 --numstat
969 </dt>
970 <dd>
971 <p>
972 Similar to <code>--stat</code>, but shows number of added and
973 deleted lines in decimal notation and pathname without
974 abbreviation, to make it more machine friendly. For
975 binary files, outputs two <code>-</code> instead of saying
976 <code>0 0</code>.
977 </p>
978 </dd>
979 <dt class="hdlist1">
980 --shortstat
981 </dt>
982 <dd>
983 <p>
984 Output only the last line of the <code>--stat</code> format containing total
985 number of modified files, as well as number of added and deleted
986 lines.
987 </p>
988 </dd>
989 <dt class="hdlist1">
990 --dirstat[=<param1,param2,…>]
991 </dt>
992 <dd>
993 <p>
994 Output the distribution of relative amount of changes for each
995 sub-directory. The behavior of <code>--dirstat</code> can be customized by
996 passing it a comma separated list of parameters.
997 The defaults are controlled by the <code>diff.dirstat</code> configuration
998 variable (see <a href="git-config.html">git-config(1)</a>).
999 The following parameters are available:
1000 </p>
1001 <div class="openblock">
1002 <div class="content">
1003 <div class="dlist"><dl>
1004 <dt class="hdlist1">
1005 <code>changes</code>
1006 </dt>
1007 <dd>
1008 <p>
1009 Compute the dirstat numbers by counting the lines that have been
1010 removed from the source, or added to the destination. This ignores
1011 the amount of pure code movements within a file. In other words,
1012 rearranging lines in a file is not counted as much as other changes.
1013 This is the default behavior when no parameter is given.
1014 </p>
1015 </dd>
1016 <dt class="hdlist1">
1017 <code>lines</code>
1018 </dt>
1019 <dd>
1020 <p>
1021 Compute the dirstat numbers by doing the regular line-based diff
1022 analysis, and summing the removed/added line counts. (For binary
1023 files, count 64-byte chunks instead, since binary files have no
1024 natural concept of lines). This is a more expensive <code>--dirstat</code>
1025 behavior than the <code>changes</code> behavior, but it does count rearranged
1026 lines within a file as much as other changes. The resulting output
1027 is consistent with what you get from the other <code>--*stat</code> options.
1028 </p>
1029 </dd>
1030 <dt class="hdlist1">
1031 <code>files</code>
1032 </dt>
1033 <dd>
1034 <p>
1035 Compute the dirstat numbers by counting the number of files changed.
1036 Each changed file counts equally in the dirstat analysis. This is
1037 the computationally cheapest <code>--dirstat</code> behavior, since it does
1038 not have to look at the file contents at all.
1039 </p>
1040 </dd>
1041 <dt class="hdlist1">
1042 <code>cumulative</code>
1043 </dt>
1044 <dd>
1045 <p>
1046 Count changes in a child directory for the parent directory as well.
1047 Note that when using <code>cumulative</code>, the sum of the percentages
1048 reported may exceed 100%. The default (non-cumulative) behavior can
1049 be specified with the <code>noncumulative</code> parameter.
1050 </p>
1051 </dd>
1052 <dt class="hdlist1">
1053 <limit>
1054 </dt>
1055 <dd>
1056 <p>
1057 An integer parameter specifies a cut-off percent (3% by default).
1058 Directories contributing less than this percentage of the changes
1059 are not shown in the output.
1060 </p>
1061 </dd>
1062 </dl></div>
1063 </div></div>
1064 <div class="paragraph"><p>Example: The following will count changed files, while ignoring
1065 directories with less than 10% of the total amount of changed files,
1066 and accumulating child directory counts in the parent directories:
1067 <code>--dirstat=files,10,cumulative</code>.</p></div>
1068 </dd>
1069 <dt class="hdlist1">
1070 --summary
1071 </dt>
1072 <dd>
1073 <p>
1074 Output a condensed summary of extended header information
1075 such as creations, renames and mode changes.
1076 </p>
1077 </dd>
1078 <dt class="hdlist1">
1079 --patch-with-stat
1080 </dt>
1081 <dd>
1082 <p>
1083 Synonym for <code>-p --stat</code>.
1084 </p>
1085 </dd>
1086 <dt class="hdlist1">
1087 -z
1088 </dt>
1089 <dd>
1090 <p>
1091 When <code>--raw</code>, <code>--numstat</code>, <code>--name-only</code> or <code>--name-status</code> has been
1092 given, do not munge pathnames and use NULs as output field terminators.
1093 </p>
1094 <div class="paragraph"><p>Without this option, pathnames with "unusual" characters are quoted as
1095 explained for the configuration variable <code>core.quotePath</code> (see
1096 <a href="git-config.html">git-config(1)</a>).</p></div>
1097 </dd>
1098 <dt class="hdlist1">
1099 --name-only
1100 </dt>
1101 <dd>
1102 <p>
1103 Show only names of changed files.
1104 </p>
1105 </dd>
1106 <dt class="hdlist1">
1107 --name-status
1108 </dt>
1109 <dd>
1110 <p>
1111 Show only names and status of changed files. See the description
1112 of the <code>--diff-filter</code> option on what the status letters mean.
1113 </p>
1114 </dd>
1115 <dt class="hdlist1">
1116 --submodule[=<format>]
1117 </dt>
1118 <dd>
1119 <p>
1120 Specify how differences in submodules are shown. When specifying
1121 <code>--submodule=short</code> the <em>short</em> format is used. This format just
1122 shows the names of the commits at the beginning and end of the range.
1123 When <code>--submodule</code> or <code>--submodule=log</code> is specified, the <em>log</em>
1124 format is used. This format lists the commits in the range like
1125 <a href="git-submodule.html">git-submodule(1)</a> <code>summary</code> does. When <code>--submodule=diff</code>
1126 is specified, the <em>diff</em> format is used. This format shows an
1127 inline diff of the changes in the submodule contents between the
1128 commit range. Defaults to <code>diff.submodule</code> or the <em>short</em> format
1129 if the config option is unset.
1130 </p>
1131 </dd>
1132 <dt class="hdlist1">
1133 --color[=<when>]
1134 </dt>
1135 <dd>
1136 <p>
1137 Show colored diff.
1138 <code>--color</code> (i.e. without <em>=<when></em>) is the same as <code>--color=always</code>.
1139 <em><when></em> can be one of <code>always</code>, <code>never</code>, or <code>auto</code>.
1140 </p>
1141 </dd>
1142 <dt class="hdlist1">
1143 --no-color
1144 </dt>
1145 <dd>
1146 <p>
1147 Turn off colored diff.
1148 It is the same as <code>--color=never</code>.
1149 </p>
1150 </dd>
1151 <dt class="hdlist1">
1152 --color-moved[=<mode>]
1153 </dt>
1154 <dd>
1155 <p>
1156 Moved lines of code are colored differently.
1157 The <mode> defaults to <em>no</em> if the option is not given
1158 and to <em>zebra</em> if the option with no mode is given.
1159 The mode must be one of:
1160 </p>
1161 <div class="openblock">
1162 <div class="content">
1163 <div class="dlist"><dl>
1164 <dt class="hdlist1">
1165 no
1166 </dt>
1167 <dd>
1168 <p>
1169 Moved lines are not highlighted.
1170 </p>
1171 </dd>
1172 <dt class="hdlist1">
1173 default
1174 </dt>
1175 <dd>
1176 <p>
1177 Is a synonym for <code>zebra</code>. This may change to a more sensible mode
1178 in the future.
1179 </p>
1180 </dd>
1181 <dt class="hdlist1">
1182 plain
1183 </dt>
1184 <dd>
1185 <p>
1186 Any line that is added in one location and was removed
1187 in another location will be colored with <em>color.diff.newMoved</em>.
1188 Similarly <em>color.diff.oldMoved</em> will be used for removed lines
1189 that are added somewhere else in the diff. This mode picks up any
1190 moved line, but it is not very useful in a review to determine
1191 if a block of code was moved without permutation.
1192 </p>
1193 </dd>
1194 <dt class="hdlist1">
1195 blocks
1196 </dt>
1197 <dd>
1198 <p>
1199 Blocks of moved text of at least 20 alphanumeric characters
1200 are detected greedily. The detected blocks are
1201 painted using either the <em>color.diff.{old,new}Moved</em> color.
1202 Adjacent blocks cannot be told apart.
1203 </p>
1204 </dd>
1205 <dt class="hdlist1">
1206 zebra
1207 </dt>
1208 <dd>
1209 <p>
1210 Blocks of moved text are detected as in <em>blocks</em> mode. The blocks
1211 are painted using either the <em>color.diff.{old,new}Moved</em> color or
1212 <em>color.diff.{old,new}MovedAlternative</em>. The change between
1213 the two colors indicates that a new block was detected.
1214 </p>
1215 </dd>
1216 <dt class="hdlist1">
1217 dimmed-zebra
1218 </dt>
1219 <dd>
1220 <p>
1221 Similar to <em>zebra</em>, but additional dimming of uninteresting parts
1222 of moved code is performed. The bordering lines of two adjacent
1223 blocks are considered interesting, the rest is uninteresting.
1224 <code>dimmed_zebra</code> is a deprecated synonym.
1225 </p>
1226 </dd>
1227 </dl></div>
1228 </div></div>
1229 </dd>
1230 <dt class="hdlist1">
1231 --color-moved-ws=<modes>
1232 </dt>
1233 <dd>
1234 <p>
1235 This configures how white spaces are ignored when performing the
1236 move detection for <code>--color-moved</code>.
1237 These modes can be given as a comma separated list:
1238 </p>
1239 <div class="openblock">
1240 <div class="content">
1241 <div class="dlist"><dl>
1242 <dt class="hdlist1">
1243 ignore-space-at-eol
1244 </dt>
1245 <dd>
1246 <p>
1247 Ignore changes in whitespace at EOL.
1248 </p>
1249 </dd>
1250 <dt class="hdlist1">
1251 ignore-space-change
1252 </dt>
1253 <dd>
1254 <p>
1255 Ignore changes in amount of whitespace. This ignores whitespace
1256 at line end, and considers all other sequences of one or
1257 more whitespace characters to be equivalent.
1258 </p>
1259 </dd>
1260 <dt class="hdlist1">
1261 ignore-all-space
1262 </dt>
1263 <dd>
1264 <p>
1265 Ignore whitespace when comparing lines. This ignores differences
1266 even if one line has whitespace where the other line has none.
1267 </p>
1268 </dd>
1269 <dt class="hdlist1">
1270 allow-indentation-change
1271 </dt>
1272 <dd>
1273 <p>
1274 Initially ignore any white spaces in the move detection, then
1275 group the moved code blocks only into a block if the change in
1276 whitespace is the same per line. This is incompatible with the
1277 other modes.
1278 </p>
1279 </dd>
1280 </dl></div>
1281 </div></div>
1282 </dd>
1283 <dt class="hdlist1">
1284 --word-diff[=<mode>]
1285 </dt>
1286 <dd>
1287 <p>
1288 Show a word diff, using the <mode> to delimit changed words.
1289 By default, words are delimited by whitespace; see
1290 <code>--word-diff-regex</code> below. The <mode> defaults to <em>plain</em>, and
1291 must be one of:
1292 </p>
1293 <div class="openblock">
1294 <div class="content">
1295 <div class="dlist"><dl>
1296 <dt class="hdlist1">
1297 color
1298 </dt>
1299 <dd>
1300 <p>
1301 Highlight changed words using only colors. Implies <code>--color</code>.
1302 </p>
1303 </dd>
1304 <dt class="hdlist1">
1305 plain
1306 </dt>
1307 <dd>
1308 <p>
1309 Show words as <code>[-removed-]</code> and <code>{+added+}</code>. Makes no
1310 attempts to escape the delimiters if they appear in the input,
1311 so the output may be ambiguous.
1312 </p>
1313 </dd>
1314 <dt class="hdlist1">
1315 porcelain
1316 </dt>
1317 <dd>
1318 <p>
1319 Use a special line-based format intended for script
1320 consumption. Added/removed/unchanged runs are printed in the
1321 usual unified diff format, starting with a <code>+</code>/<code>-</code>/` `
1322 character at the beginning of the line and extending to the
1323 end of the line. Newlines in the input are represented by a
1324 tilde <code>~</code> on a line of its own.
1325 </p>
1326 </dd>
1327 <dt class="hdlist1">
1328 none
1329 </dt>
1330 <dd>
1331 <p>
1332 Disable word diff again.
1333 </p>
1334 </dd>
1335 </dl></div>
1336 </div></div>
1337 <div class="paragraph"><p>Note that despite the name of the first mode, color is used to
1338 highlight the changed parts in all modes if enabled.</p></div>
1339 </dd>
1340 <dt class="hdlist1">
1341 --word-diff-regex=<regex>
1342 </dt>
1343 <dd>
1344 <p>
1345 Use <regex> to decide what a word is, instead of considering
1346 runs of non-whitespace to be a word. Also implies
1347 <code>--word-diff</code> unless it was already enabled.
1348 </p>
1349 <div class="paragraph"><p>Every non-overlapping match of the
1350 <regex> is considered a word. Anything between these matches is
1351 considered whitespace and ignored(!) for the purposes of finding
1352 differences. You may want to append <code>|[^[:space:]]</code> to your regular
1353 expression to make sure that it matches all non-whitespace characters.
1354 A match that contains a newline is silently truncated(!) at the
1355 newline.</p></div>
1356 <div class="paragraph"><p>For example, <code>--word-diff-regex=.</code> will treat each character as a word
1357 and, correspondingly, show differences character by character.</p></div>
1358 <div class="paragraph"><p>The regex can also be set via a diff driver or configuration option, see
1359 <a href="gitattributes.html">gitattributes(5)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
1360 overrides any diff driver or configuration setting. Diff drivers
1361 override configuration settings.</p></div>
1362 </dd>
1363 <dt class="hdlist1">
1364 --color-words[=<regex>]
1365 </dt>
1366 <dd>
1367 <p>
1368 Equivalent to <code>--word-diff=color</code> plus (if a regex was
1369 specified) <code>--word-diff-regex=<regex></code>.
1370 </p>
1371 </dd>
1372 <dt class="hdlist1">
1373 --no-renames
1374 </dt>
1375 <dd>
1376 <p>
1377 Turn off rename detection, even when the configuration
1378 file gives the default to do so.
1379 </p>
1380 </dd>
1381 <dt class="hdlist1">
1382 --check
1383 </dt>
1384 <dd>
1385 <p>
1386 Warn if changes introduce conflict markers or whitespace errors.
1387 What are considered whitespace errors is controlled by <code>core.whitespace</code>
1388 configuration. By default, trailing whitespaces (including
1389 lines that consist solely of whitespaces) and a space character
1390 that is immediately followed by a tab character inside the
1391 initial indent of the line are considered whitespace errors.
1392 Exits with non-zero status if problems are found. Not compatible
1393 with --exit-code.
1394 </p>
1395 </dd>
1396 <dt class="hdlist1">
1397 --ws-error-highlight=<kind>
1398 </dt>
1399 <dd>
1400 <p>
1401 Highlight whitespace errors in the <code>context</code>, <code>old</code> or <code>new</code>
1402 lines of the diff. Multiple values are separated by comma,
1403 <code>none</code> resets previous values, <code>default</code> reset the list to
1404 <code>new</code> and <code>all</code> is a shorthand for <code>old,new,context</code>. When
1405 this option is not given, and the configuration variable
1406 <code>diff.wsErrorHighlight</code> is not set, only whitespace errors in
1407 <code>new</code> lines are highlighted. The whitespace errors are colored
1408 with <code>color.diff.whitespace</code>.
1409 </p>
1410 </dd>
1411 <dt class="hdlist1">
1412 --full-index
1413 </dt>
1414 <dd>
1415 <p>
1416 Instead of the first handful of characters, show the full
1417 pre- and post-image blob object names on the "index"
1418 line when generating patch format output.
1419 </p>
1420 </dd>
1421 <dt class="hdlist1">
1422 --binary
1423 </dt>
1424 <dd>
1425 <p>
1426 In addition to <code>--full-index</code>, output a binary diff that
1427 can be applied with <code>git-apply</code>.
1428 </p>
1429 </dd>
1430 <dt class="hdlist1">
1431 --abbrev[=<n>]
1432 </dt>
1433 <dd>
1434 <p>
1435 Instead of showing the full 40-byte hexadecimal object
1436 name in diff-raw format output and diff-tree header
1437 lines, show only a partial prefix. This is
1438 independent of the <code>--full-index</code> option above, which controls
1439 the diff-patch output format. Non default number of
1440 digits can be specified with <code>--abbrev=<n></code>.
1441 </p>
1442 </dd>
1443 <dt class="hdlist1">
1444 -B[<n>][/<m>]
1445 </dt>
1446 <dt class="hdlist1">
1447 --break-rewrites[=[<n>][/<m>]]
1448 </dt>
1449 <dd>
1450 <p>
1451 Break complete rewrite changes into pairs of delete and
1452 create. This serves two purposes:
1453 </p>
1454 <div class="paragraph"><p>It affects the way a change that amounts to a total rewrite of a file
1455 not as a series of deletion and insertion mixed together with a very
1456 few lines that happen to match textually as the context, but as a
1457 single deletion of everything old followed by a single insertion of
1458 everything new, and the number <code>m</code> controls this aspect of the -B
1459 option (defaults to 60%). <code>-B/70%</code> specifies that less than 30% of the
1460 original should remain in the result for Git to consider it a total
1461 rewrite (i.e. otherwise the resulting patch will be a series of
1462 deletion and insertion mixed together with context lines).</p></div>
1463 <div class="paragraph"><p>When used with -M, a totally-rewritten file is also considered as the
1464 source of a rename (usually -M only considers a file that disappeared
1465 as the source of a rename), and the number <code>n</code> controls this aspect of
1466 the -B option (defaults to 50%). <code>-B20%</code> specifies that a change with
1467 addition and deletion compared to 20% or more of the file’s size are
1468 eligible for being picked up as a possible source of a rename to
1469 another file.</p></div>
1470 </dd>
1471 <dt class="hdlist1">
1472 -M[<n>]
1473 </dt>
1474 <dt class="hdlist1">
1475 --find-renames[=<n>]
1476 </dt>
1477 <dd>
1478 <p>
1479 Detect renames.
1480 If <code>n</code> is specified, it is a threshold on the similarity
1481 index (i.e. amount of addition/deletions compared to the
1482 file’s size). For example, <code>-M90%</code> means Git should consider a
1483 delete/add pair to be a rename if more than 90% of the file
1484 hasn’t changed. Without a <code>%</code> sign, the number is to be read as
1485 a fraction, with a decimal point before it. I.e., <code>-M5</code> becomes
1486 0.5, and is thus the same as <code>-M50%</code>. Similarly, <code>-M05</code> is
1487 the same as <code>-M5%</code>. To limit detection to exact renames, use
1488 <code>-M100%</code>. The default similarity index is 50%.
1489 </p>
1490 </dd>
1491 <dt class="hdlist1">
1492 -C[<n>]
1493 </dt>
1494 <dt class="hdlist1">
1495 --find-copies[=<n>]
1496 </dt>
1497 <dd>
1498 <p>
1499 Detect copies as well as renames. See also <code>--find-copies-harder</code>.
1500 If <code>n</code> is specified, it has the same meaning as for <code>-M<n></code>.
1501 </p>
1502 </dd>
1503 <dt class="hdlist1">
1504 --find-copies-harder
1505 </dt>
1506 <dd>
1507 <p>
1508 For performance reasons, by default, <code>-C</code> option finds copies only
1509 if the original file of the copy was modified in the same
1510 changeset. This flag makes the command
1511 inspect unmodified files as candidates for the source of
1512 copy. This is a very expensive operation for large
1513 projects, so use it with caution. Giving more than one
1514 <code>-C</code> option has the same effect.
1515 </p>
1516 </dd>
1517 <dt class="hdlist1">
1518 -D
1519 </dt>
1520 <dt class="hdlist1">
1521 --irreversible-delete
1522 </dt>
1523 <dd>
1524 <p>
1525 Omit the preimage for deletes, i.e. print only the header but not
1526 the diff between the preimage and <code>/dev/null</code>. The resulting patch
1527 is not meant to be applied with <code>patch</code> or <code>git apply</code>; this is
1528 solely for people who want to just concentrate on reviewing the
1529 text after the change. In addition, the output obviously lacks
1530 enough information to apply such a patch in reverse, even manually,
1531 hence the name of the option.
1532 </p>
1533 <div class="paragraph"><p>When used together with <code>-B</code>, omit also the preimage in the deletion part
1534 of a delete/create pair.</p></div>
1535 </dd>
1536 <dt class="hdlist1">
1537 -l<num>
1538 </dt>
1539 <dd>
1540 <p>
1541 The <code>-M</code> and <code>-C</code> options require O(n^2) processing time where n
1542 is the number of potential rename/copy targets. This
1543 option prevents rename/copy detection from running if
1544 the number of rename/copy targets exceeds the specified
1545 number.
1546 </p>
1547 </dd>
1548 <dt class="hdlist1">
1549 --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
1550 </dt>
1551 <dd>
1552 <p>
1553 Select only files that are Added (<code>A</code>), Copied (<code>C</code>),
1554 Deleted (<code>D</code>), Modified (<code>M</code>), Renamed (<code>R</code>), have their
1555 type (i.e. regular file, symlink, submodule, …) changed (<code>T</code>),
1556 are Unmerged (<code>U</code>), are
1557 Unknown (<code>X</code>), or have had their pairing Broken (<code>B</code>).
1558 Any combination of the filter characters (including none) can be used.
1559 When <code>*</code> (All-or-none) is added to the combination, all
1560 paths are selected if there is any file that matches
1561 other criteria in the comparison; if there is no file
1562 that matches other criteria, nothing is selected.
1563 </p>
1564 <div class="paragraph"><p>Also, these upper-case letters can be downcased to exclude. E.g.
1565 <code>--diff-filter=ad</code> excludes added and deleted paths.</p></div>
1566 <div class="paragraph"><p>Note that not all diffs can feature all types. For instance, diffs
1567 from the index to the working tree can never have Added entries
1568 (because the set of paths included in the diff is limited by what is in
1569 the index). Similarly, copied and renamed entries cannot appear if
1570 detection for those types is disabled.</p></div>
1571 </dd>
1572 <dt class="hdlist1">
1573 -S<string>
1574 </dt>
1575 <dd>
1576 <p>
1577 Look for differences that change the number of occurrences of
1578 the specified string (i.e. addition/deletion) in a file.
1579 Intended for the scripter’s use.
1580 </p>
1581 <div class="paragraph"><p>It is useful when you’re looking for an exact block of code (like a
1582 struct), and want to know the history of that block since it first
1583 came into being: use the feature iteratively to feed the interesting
1584 block in the preimage back into <code>-S</code>, and keep going until you get the
1585 very first version of the block.</p></div>
1586 </dd>
1587 <dt class="hdlist1">
1588 -G<regex>
1589 </dt>
1590 <dd>
1591 <p>
1592 Look for differences whose patch text contains added/removed
1593 lines that match <regex>.
1594 </p>
1595 <div class="paragraph"><p>To illustrate the difference between <code>-S<regex> --pickaxe-regex</code> and
1596 <code>-G<regex></code>, consider a commit with the following diff in the same
1597 file:</p></div>
1598 <div class="listingblock">
1599 <div class="content">
1600 <pre><code>+ return !regexec(regexp, two->ptr, 1, &regmatch, 0);
1601 ...
1602 - hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);</code></pre>
1603 </div></div>
1604 <div class="paragraph"><p>While <code>git log -G"regexec\(regexp"</code> will show this commit, <code>git log
1605 -S"regexec\(regexp" --pickaxe-regex</code> will not (because the number of
1606 occurrences of that string did not change).</p></div>
1607 <div class="paragraph"><p>See the <em>pickaxe</em> entry in <a href="gitdiffcore.html">gitdiffcore(7)</a> for more
1608 information.</p></div>
1609 </dd>
1610 <dt class="hdlist1">
1611 --find-object=<object-id>
1612 </dt>
1613 <dd>
1614 <p>
1615 Look for differences that change the number of occurrences of
1616 the specified object. Similar to <code>-S</code>, just the argument is different
1617 in that it doesn’t search for a specific string but for a specific
1618 object id.
1619 </p>
1620 <div class="paragraph"><p>The object can be a blob or a submodule commit. It implies the <code>-t</code> option in
1621 <code>git-log</code> to also find trees.</p></div>
1622 </dd>
1623 <dt class="hdlist1">
1624 --pickaxe-all
1625 </dt>
1626 <dd>
1627 <p>
1628 When <code>-S</code> or <code>-G</code> finds a change, show all the changes in that
1629 changeset, not just the files that contain the change
1630 in <string>.
1631 </p>
1632 </dd>
1633 <dt class="hdlist1">
1634 --pickaxe-regex
1635 </dt>
1636 <dd>
1637 <p>
1638 Treat the <string> given to <code>-S</code> as an extended POSIX regular
1639 expression to match.
1640 </p>
1641 </dd>
1642 <dt class="hdlist1">
1643 -O<orderfile>
1644 </dt>
1645 <dd>
1646 <p>
1647 Control the order in which files appear in the output.
1648 This overrides the <code>diff.orderFile</code> configuration variable
1649 (see <a href="git-config.html">git-config(1)</a>). To cancel <code>diff.orderFile</code>,
1650 use <code>-O/dev/null</code>.
1651 </p>
1652 <div class="paragraph"><p>The output order is determined by the order of glob patterns in
1653 <orderfile>.
1654 All files with pathnames that match the first pattern are output
1655 first, all files with pathnames that match the second pattern (but not
1656 the first) are output next, and so on.
1657 All files with pathnames that do not match any pattern are output
1658 last, as if there was an implicit match-all pattern at the end of the
1659 file.
1660 If multiple pathnames have the same rank (they match the same pattern
1661 but no earlier patterns), their output order relative to each other is
1662 the normal order.</p></div>
1663 <div class="paragraph"><p><orderfile> is parsed as follows:</p></div>
1664 <div class="openblock">
1665 <div class="content">
1666 <div class="ulist"><ul>
1667 <li>
1668 <p>
1669 Blank lines are ignored, so they can be used as separators for
1670 readability.
1671 </p>
1672 </li>
1673 <li>
1674 <p>
1675 Lines starting with a hash ("<code>#</code>") are ignored, so they can be used
1676 for comments. Add a backslash ("<code>\</code>") to the beginning of the
1677 pattern if it starts with a hash.
1678 </p>
1679 </li>
1680 <li>
1681 <p>
1682 Each other line contains a single pattern.
1683 </p>
1684 </li>
1685 </ul></div>
1686 </div></div>
1687 <div class="paragraph"><p>Patterns have the same syntax and semantics as patterns used for
1688 fnmatch(3) without the FNM_PATHNAME flag, except a pathname also
1689 matches a pattern if removing any number of the final pathname
1690 components matches the pattern. For example, the pattern "<code>foo*bar</code>"
1691 matches "<code>fooasdfbar</code>" and "<code>foo/bar/baz/asdf</code>" but not "<code>foobarx</code>".</p></div>
1692 </dd>
1693 <dt class="hdlist1">
1694 -R
1695 </dt>
1696 <dd>
1697 <p>
1698 Swap two inputs; that is, show differences from index or
1699 on-disk file to tree contents.
1700 </p>
1701 </dd>
1702 <dt class="hdlist1">
1703 --relative[=<path>]
1704 </dt>
1705 <dd>
1706 <p>
1707 When run from a subdirectory of the project, it can be
1708 told to exclude changes outside the directory and show
1709 pathnames relative to it with this option. When you are
1710 not in a subdirectory (e.g. in a bare repository), you
1711 can name which subdirectory to make the output relative
1712 to by giving a <path> as an argument.
1713 </p>
1714 </dd>
1715 <dt class="hdlist1">
1716 -a
1717 </dt>
1718 <dt class="hdlist1">
1719 --text
1720 </dt>
1721 <dd>
1722 <p>
1723 Treat all files as text.
1724 </p>
1725 </dd>
1726 <dt class="hdlist1">
1727 --ignore-cr-at-eol
1728 </dt>
1729 <dd>
1730 <p>
1731 Ignore carriage-return at the end of line when doing a comparison.
1732 </p>
1733 </dd>
1734 <dt class="hdlist1">
1735 --ignore-space-at-eol
1736 </dt>
1737 <dd>
1738 <p>
1739 Ignore changes in whitespace at EOL.
1740 </p>
1741 </dd>
1742 <dt class="hdlist1">
1743 -b
1744 </dt>
1745 <dt class="hdlist1">
1746 --ignore-space-change
1747 </dt>
1748 <dd>
1749 <p>
1750 Ignore changes in amount of whitespace. This ignores whitespace
1751 at line end, and considers all other sequences of one or
1752 more whitespace characters to be equivalent.
1753 </p>
1754 </dd>
1755 <dt class="hdlist1">
1756 -w
1757 </dt>
1758 <dt class="hdlist1">
1759 --ignore-all-space
1760 </dt>
1761 <dd>
1762 <p>
1763 Ignore whitespace when comparing lines. This ignores
1764 differences even if one line has whitespace where the other
1765 line has none.
1766 </p>
1767 </dd>
1768 <dt class="hdlist1">
1769 --ignore-blank-lines
1770 </dt>
1771 <dd>
1772 <p>
1773 Ignore changes whose lines are all blank.
1774 </p>
1775 </dd>
1776 <dt class="hdlist1">
1777 --inter-hunk-context=<lines>
1778 </dt>
1779 <dd>
1780 <p>
1781 Show the context between diff hunks, up to the specified number
1782 of lines, thereby fusing hunks that are close to each other.
1783 Defaults to <code>diff.interHunkContext</code> or 0 if the config option
1784 is unset.
1785 </p>
1786 </dd>
1787 <dt class="hdlist1">
1788 -W
1789 </dt>
1790 <dt class="hdlist1">
1791 --function-context
1792 </dt>
1793 <dd>
1794 <p>
1795 Show whole surrounding functions of changes.
1796 </p>
1797 </dd>
1798 <dt class="hdlist1">
1799 --exit-code
1800 </dt>
1801 <dd>
1802 <p>
1803 Make the program exit with codes similar to diff(1).
1804 That is, it exits with 1 if there were differences and
1805 0 means no differences.
1806 </p>
1807 </dd>
1808 <dt class="hdlist1">
1809 --quiet
1810 </dt>
1811 <dd>
1812 <p>
1813 Disable all output of the program. Implies <code>--exit-code</code>.
1814 </p>
1815 </dd>
1816 <dt class="hdlist1">
1817 --ext-diff
1818 </dt>
1819 <dd>
1820 <p>
1821 Allow an external diff helper to be executed. If you set an
1822 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
1823 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
1824 </p>
1825 </dd>
1826 <dt class="hdlist1">
1827 --no-ext-diff
1828 </dt>
1829 <dd>
1830 <p>
1831 Disallow external diff drivers.
1832 </p>
1833 </dd>
1834 <dt class="hdlist1">
1835 --textconv
1836 </dt>
1837 <dt class="hdlist1">
1838 --no-textconv
1839 </dt>
1840 <dd>
1841 <p>
1842 Allow (or disallow) external text conversion filters to be run
1843 when comparing binary files. See <a href="gitattributes.html">gitattributes(5)</a> for
1844 details. Because textconv filters are typically a one-way
1845 conversion, the resulting diff is suitable for human
1846 consumption, but cannot be applied. For this reason, textconv
1847 filters are enabled by default only for <a href="git-diff.html">git-diff(1)</a> and
1848 <a href="git-log.html">git-log(1)</a>, but not for <a href="git-format-patch.html">git-format-patch(1)</a> or
1849 diff plumbing commands.
1850 </p>
1851 </dd>
1852 <dt class="hdlist1">
1853 --ignore-submodules[=<when>]
1854 </dt>
1855 <dd>
1856 <p>
1857 Ignore changes to submodules in the diff generation. <when> can be
1858 either "none", "untracked", "dirty" or "all", which is the default.
1859 Using "none" will consider the submodule modified when it either contains
1860 untracked or modified files or its HEAD differs from the commit recorded
1861 in the superproject and can be used to override any settings of the
1862 <em>ignore</em> option in <a href="git-config.html">git-config(1)</a> or <a href="gitmodules.html">gitmodules(5)</a>. When
1863 "untracked" is used submodules are not considered dirty when they only
1864 contain untracked content (but they are still scanned for modified
1865 content). Using "dirty" ignores all changes to the work tree of submodules,
1866 only changes to the commits stored in the superproject are shown (this was
1867 the behavior until 1.7.0). Using "all" hides all changes to submodules.
1868 </p>
1869 </dd>
1870 <dt class="hdlist1">
1871 --src-prefix=<prefix>
1872 </dt>
1873 <dd>
1874 <p>
1875 Show the given source prefix instead of "a/".
1876 </p>
1877 </dd>
1878 <dt class="hdlist1">
1879 --dst-prefix=<prefix>
1880 </dt>
1881 <dd>
1882 <p>
1883 Show the given destination prefix instead of "b/".
1884 </p>
1885 </dd>
1886 <dt class="hdlist1">
1887 --no-prefix
1888 </dt>
1889 <dd>
1890 <p>
1891 Do not show any source or destination prefix.
1892 </p>
1893 </dd>
1894 <dt class="hdlist1">
1895 --line-prefix=<prefix>
1896 </dt>
1897 <dd>
1898 <p>
1899 Prepend an additional prefix to every line of output.
1900 </p>
1901 </dd>
1902 <dt class="hdlist1">
1903 --ita-invisible-in-index
1904 </dt>
1905 <dd>
1906 <p>
1907 By default entries added by "git add -N" appear as an existing
1908 empty file in "git diff" and a new file in "git diff --cached".
1909 This option makes the entry appear as a new file in "git diff"
1910 and non-existent in "git diff --cached". This option could be
1911 reverted with <code>--ita-visible-in-index</code>. Both options are
1912 experimental and could be removed in future.
1913 </p>
1914 </dd>
1915 </dl></div>
1916 <div class="paragraph"><p>For more detailed explanation on these common options, see also
1917 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
1918 <div class="dlist"><dl>
1919 <dt class="hdlist1">
1920 <tree-ish>
1921 </dt>
1922 <dd>
1923 <p>
1924 The id of a tree object to diff against.
1925 </p>
1926 </dd>
1927 <dt class="hdlist1">
1928 --cached
1929 </dt>
1930 <dd>
1931 <p>
1932 do not consider the on-disk file at all
1933 </p>
1934 </dd>
1935 <dt class="hdlist1">
1936 -m
1937 </dt>
1938 <dd>
1939 <p>
1940 By default, files recorded in the index but not checked
1941 out are reported as deleted. This flag makes
1942 <em>git diff-index</em> say that all non-checked-out files are up
1943 to date.
1944 </p>
1945 </dd>
1946 </dl></div>
1947 </div>
1948 </div>
1949 <div class="sect1">
1950 <h2 id="_raw_output_format">Raw output format</h2>
1951 <div class="sectionbody">
1952 <div class="paragraph"><p>The raw output format from "git-diff-index", "git-diff-tree",
1953 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1954 <div class="paragraph"><p>These commands all compare two sets of things; what is
1955 compared differs:</p></div>
1956 <div class="dlist"><dl>
1957 <dt class="hdlist1">
1958 git-diff-index <tree-ish>
1959 </dt>
1960 <dd>
1961 <p>
1962 compares the <tree-ish> and the files on the filesystem.
1963 </p>
1964 </dd>
1965 <dt class="hdlist1">
1966 git-diff-index --cached <tree-ish>
1967 </dt>
1968 <dd>
1969 <p>
1970 compares the <tree-ish> and the index.
1971 </p>
1972 </dd>
1973 <dt class="hdlist1">
1974 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
1975 </dt>
1976 <dd>
1977 <p>
1978 compares the trees named by the two arguments.
1979 </p>
1980 </dd>
1981 <dt class="hdlist1">
1982 git-diff-files [<pattern>…]
1983 </dt>
1984 <dd>
1985 <p>
1986 compares the index and the files on the filesystem.
1987 </p>
1988 </dd>
1989 </dl></div>
1990 <div class="paragraph"><p>The "git-diff-tree" command begins its output by printing the hash of
1991 what is being compared. After that, all the commands print one output
1992 line per changed file.</p></div>
1993 <div class="paragraph"><p>An output line is formatted this way:</p></div>
1994 <div class="listingblock">
1995 <div class="content">
1996 <pre><code>in-place edit :100644 100644 bcd1234 0123456 M file0
1997 copy-edit :100644 100644 abcd123 1234567 C68 file1 file2
1998 rename-edit :100644 100644 abcd123 1234567 R86 file1 file3
1999 create :000000 100644 0000000 1234567 A file4
2000 delete :100644 000000 1234567 0000000 D file5
2001 unmerged :000000 000000 0000000 0000000 U file6</code></pre>
2002 </div></div>
2003 <div class="paragraph"><p>That is, from the left to the right:</p></div>
2004 <div class="olist arabic"><ol class="arabic">
2005 <li>
2006 <p>
2007 a colon.
2008 </p>
2009 </li>
2010 <li>
2011 <p>
2012 mode for "src"; 000000 if creation or unmerged.
2013 </p>
2014 </li>
2015 <li>
2016 <p>
2017 a space.
2018 </p>
2019 </li>
2020 <li>
2021 <p>
2022 mode for "dst"; 000000 if deletion or unmerged.
2023 </p>
2024 </li>
2025 <li>
2026 <p>
2027 a space.
2028 </p>
2029 </li>
2030 <li>
2031 <p>
2032 sha1 for "src"; 0{40} if creation or unmerged.
2033 </p>
2034 </li>
2035 <li>
2036 <p>
2037 a space.
2038 </p>
2039 </li>
2040 <li>
2041 <p>
2042 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
2043 </p>
2044 </li>
2045 <li>
2046 <p>
2047 a space.
2048 </p>
2049 </li>
2050 <li>
2051 <p>
2052 status, followed by optional "score" number.
2053 </p>
2054 </li>
2055 <li>
2056 <p>
2057 a tab or a NUL when <code>-z</code> option is used.
2058 </p>
2059 </li>
2060 <li>
2061 <p>
2062 path for "src"
2063 </p>
2064 </li>
2065 <li>
2066 <p>
2067 a tab or a NUL when <code>-z</code> option is used; only exists for C or R.
2068 </p>
2069 </li>
2070 <li>
2071 <p>
2072 path for "dst"; only exists for C or R.
2073 </p>
2074 </li>
2075 <li>
2076 <p>
2077 an LF or a NUL when <code>-z</code> option is used, to terminate the record.
2078 </p>
2079 </li>
2080 </ol></div>
2081 <div class="paragraph"><p>Possible status letters are:</p></div>
2082 <div class="ulist"><ul>
2083 <li>
2084 <p>
2085 A: addition of a file
2086 </p>
2087 </li>
2088 <li>
2089 <p>
2090 C: copy of a file into a new one
2091 </p>
2092 </li>
2093 <li>
2094 <p>
2095 D: deletion of a file
2096 </p>
2097 </li>
2098 <li>
2099 <p>
2100 M: modification of the contents or mode of a file
2101 </p>
2102 </li>
2103 <li>
2104 <p>
2105 R: renaming of a file
2106 </p>
2107 </li>
2108 <li>
2109 <p>
2110 T: change in the type of the file
2111 </p>
2112 </li>
2113 <li>
2114 <p>
2115 U: file is unmerged (you must complete the merge before it can
2116 be committed)
2117 </p>
2118 </li>
2119 <li>
2120 <p>
2121 X: "unknown" change type (most probably a bug, please report it)
2122 </p>
2123 </li>
2124 </ul></div>
2125 <div class="paragraph"><p>Status letters C and R are always followed by a score (denoting the
2126 percentage of similarity between the source and target of the move or
2127 copy). Status letter M may be followed by a score (denoting the
2128 percentage of dissimilarity) for file rewrites.</p></div>
2129 <div class="paragraph"><p><sha1> is shown as all 0’s if a file is new on the filesystem
2130 and it is out of sync with the index.</p></div>
2131 <div class="paragraph"><p>Example:</p></div>
2132 <div class="listingblock">
2133 <div class="content">
2134 <pre><code>:100644 100644 5be4a4a 0000000 M file.c</code></pre>
2135 </div></div>
2136 <div class="paragraph"><p>Without the <code>-z</code> option, pathnames with "unusual" characters are
2137 quoted as explained for the configuration variable <code>core.quotePath</code>
2138 (see <a href="git-config.html">git-config(1)</a>). Using <code>-z</code> the filename is output
2139 verbatim and the line is terminated by a NUL byte.</p></div>
2140 </div>
2141 </div>
2142 <div class="sect1">
2143 <h2 id="_diff_format_for_merges">diff format for merges</h2>
2144 <div class="sectionbody">
2145 <div class="paragraph"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
2146 can take <code>-c</code> or <code>--cc</code> option
2147 to generate diff output also for merge commits. The output differs
2148 from the format described above in the following way:</p></div>
2149 <div class="olist arabic"><ol class="arabic">
2150 <li>
2151 <p>
2152 there is a colon for each parent
2153 </p>
2154 </li>
2155 <li>
2156 <p>
2157 there are more "src" modes and "src" sha1
2158 </p>
2159 </li>
2160 <li>
2161 <p>
2162 status is concatenated status characters for each parent
2163 </p>
2164 </li>
2165 <li>
2166 <p>
2167 no optional "score" number
2168 </p>
2169 </li>
2170 <li>
2171 <p>
2172 single path, only for "dst"
2173 </p>
2174 </li>
2175 </ol></div>
2176 <div class="paragraph"><p>Example:</p></div>
2177 <div class="listingblock">
2178 <div class="content">
2179 <pre><code>::100644 100644 100644 fabadb8 cc95eb0 4866510 MM describe.c</code></pre>
2180 </div></div>
2181 <div class="paragraph"><p>Note that <em>combined diff</em> lists only files which were modified from
2182 all parents.</p></div>
2183 </div>
2184 </div>
2185 <div class="sect1">
2186 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
2187 <div class="sectionbody">
2188 <div class="paragraph"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
2189 with a <code>-p</code> option, "git diff" without the <code>--raw</code> option, or
2190 "git log" with the "-p" option, they
2191 do not produce the output described above; instead they produce a
2192 patch file. You can customize the creation of such patches via the
2193 <code>GIT_EXTERNAL_DIFF</code> and the <code>GIT_DIFF_OPTS</code> environment variables.</p></div>
2194 <div class="paragraph"><p>What the -p option produces is slightly different from the traditional
2195 diff format:</p></div>
2196 <div class="olist arabic"><ol class="arabic">
2197 <li>
2198 <p>
2199 It is preceded with a "git diff" header that looks like this:
2200 </p>
2201 <div class="literalblock">
2202 <div class="content">
2203 <pre><code>diff --git a/file1 b/file2</code></pre>
2204 </div></div>
2205 <div class="paragraph"><p>The <code>a/</code> and <code>b/</code> filenames are the same unless rename/copy is
2206 involved. Especially, even for a creation or a deletion,
2207 <code>/dev/null</code> is <em>not</em> used in place of the <code>a/</code> or <code>b/</code> filenames.</p></div>
2208 <div class="paragraph"><p>When rename/copy is involved, <code>file1</code> and <code>file2</code> show the
2209 name of the source file of the rename/copy and the name of
2210 the file that rename/copy produces, respectively.</p></div>
2211 </li>
2212 <li>
2213 <p>
2214 It is followed by one or more extended header lines:
2215 </p>
2216 <div class="literalblock">
2217 <div class="content">
2218 <pre><code>old mode <mode>
2219 new mode <mode>
2220 deleted file mode <mode>
2221 new file mode <mode>
2222 copy from <path>
2223 copy to <path>
2224 rename from <path>
2225 rename to <path>
2226 similarity index <number>
2227 dissimilarity index <number>
2228 index <hash>..<hash> <mode></code></pre>
2229 </div></div>
2230 <div class="paragraph"><p>File modes are printed as 6-digit octal numbers including the file type
2231 and file permission bits.</p></div>
2232 <div class="paragraph"><p>Path names in extended headers do not include the <code>a/</code> and <code>b/</code> prefixes.</p></div>
2233 <div class="paragraph"><p>The similarity index is the percentage of unchanged lines, and
2234 the dissimilarity index is the percentage of changed lines. It
2235 is a rounded down integer, followed by a percent sign. The
2236 similarity index value of 100% is thus reserved for two equal
2237 files, while 100% dissimilarity means that no line from the old
2238 file made it into the new one.</p></div>
2239 <div class="paragraph"><p>The index line includes the SHA-1 checksum before and after the change.
2240 The <mode> is included if the file mode does not change; otherwise,
2241 separate lines indicate the old and the new mode.</p></div>
2242 </li>
2243 <li>
2244 <p>
2245 Pathnames with "unusual" characters are quoted as explained for
2246 the configuration variable <code>core.quotePath</code> (see
2247 <a href="git-config.html">git-config(1)</a>).
2248 </p>
2249 </li>
2250 <li>
2251 <p>
2252 All the <code>file1</code> files in the output refer to files before the
2253 commit, and all the <code>file2</code> files refer to files after the commit.
2254 It is incorrect to apply each change to each file sequentially. For
2255 example, this patch will swap a and b:
2256 </p>
2257 <div class="literalblock">
2258 <div class="content">
2259 <pre><code>diff --git a/a b/b
2260 rename from a
2261 rename to b
2262 diff --git a/b b/a
2263 rename from b
2264 rename to a</code></pre>
2265 </div></div>
2266 </li>
2267 </ol></div>
2268 </div>
2269 </div>
2270 <div class="sect1">
2271 <h2 id="_combined_diff_format">combined diff format</h2>
2272 <div class="sectionbody">
2273 <div class="paragraph"><p>Any diff-generating command can take the <code>-c</code> or <code>--cc</code> option to
2274 produce a <em>combined diff</em> when showing a merge. This is the default
2275 format when showing merges with <a href="git-diff.html">git-diff(1)</a> or
2276 <a href="git-show.html">git-show(1)</a>. Note also that you can give the <code>-m</code> option to any
2277 of these commands to force generation of diffs with individual parents
2278 of a merge.</p></div>
2279 <div class="paragraph"><p>A <em>combined diff</em> format looks like this:</p></div>
2280 <div class="listingblock">
2281 <div class="content">
2282 <pre><code>diff --combined describe.c
2283 index fabadb8,cc95eb0..4866510
2284 --- a/describe.c
2285 +++ b/describe.c
2286 @@@ -98,20 -98,12 +98,20 @@@
2287 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
2288 }
2289
2290 - static void describe(char *arg)
2291 -static void describe(struct commit *cmit, int last_one)
2292 ++static void describe(char *arg, int last_one)
2293 {
2294 + unsigned char sha1[20];
2295 + struct commit *cmit;
2296 struct commit_list *list;
2297 static int initialized = 0;
2298 struct commit_name *n;
2299
2300 + if (get_sha1(arg, sha1) < 0)
2301 + usage(describe_usage);
2302 + cmit = lookup_commit_reference(sha1);
2303 + if (!cmit)
2304 + usage(describe_usage);
2305 +
2306 if (!initialized) {
2307 initialized = 1;
2308 for_each_ref(get_name);</code></pre>
2309 </div></div>
2310 <div class="olist arabic"><ol class="arabic">
2311 <li>
2312 <p>
2313 It is preceded with a "git diff" header, that looks like
2314 this (when <code>-c</code> option is used):
2315 </p>
2316 <div class="literalblock">
2317 <div class="content">
2318 <pre><code>diff --combined file</code></pre>
2319 </div></div>
2320 <div class="paragraph"><p>or like this (when <code>--cc</code> option is used):</p></div>
2321 <div class="literalblock">
2322 <div class="content">
2323 <pre><code>diff --cc file</code></pre>
2324 </div></div>
2325 </li>
2326 <li>
2327 <p>
2328 It is followed by one or more extended header lines
2329 (this example shows a merge with two parents):
2330 </p>
2331 <div class="literalblock">
2332 <div class="content">
2333 <pre><code>index <hash>,<hash>..<hash>
2334 mode <mode>,<mode>..<mode>
2335 new file mode <mode>
2336 deleted file mode <mode>,<mode></code></pre>
2337 </div></div>
2338 <div class="paragraph"><p>The <code>mode <mode>,<mode>..<mode></code> line appears only if at least one of
2339 the <mode> is different from the rest. Extended headers with
2340 information about detected contents movement (renames and
2341 copying detection) are designed to work with diff of two
2342 <tree-ish> and are not used by combined diff format.</p></div>
2343 </li>
2344 <li>
2345 <p>
2346 It is followed by two-line from-file/to-file header
2347 </p>
2348 <div class="literalblock">
2349 <div class="content">
2350 <pre><code>--- a/file
2351 +++ b/file</code></pre>
2352 </div></div>
2353 <div class="paragraph"><p>Similar to two-line header for traditional <em>unified</em> diff
2354 format, <code>/dev/null</code> is used to signal created or deleted
2355 files.</p></div>
2356 </li>
2357 <li>
2358 <p>
2359 Chunk header format is modified to prevent people from
2360 accidentally feeding it to <code>patch -p1</code>. Combined diff format
2361 was created for review of merge commit changes, and was not
2362 meant for apply. The change is similar to the change in the
2363 extended <em>index</em> header:
2364 </p>
2365 <div class="literalblock">
2366 <div class="content">
2367 <pre><code>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</code></pre>
2368 </div></div>
2369 <div class="paragraph"><p>There are (number of parents + 1) <code>@</code> characters in the chunk
2370 header for combined diff format.</p></div>
2371 </li>
2372 </ol></div>
2373 <div class="paragraph"><p>Unlike the traditional <em>unified</em> diff format, which shows two
2374 files A and B with a single column that has <code>-</code> (minus — appears in A but removed in B), <code>+</code> (plus — missing in A but
2375 added to B), or <code>" "</code> (space — unchanged) prefix, this format
2376 compares two or more files file1, file2,… with one file X, and
2377 shows how X differs from each of fileN. One column for each of
2378 fileN is prepended to the output line to note how X’s line is
2379 different from it.</p></div>
2380 <div class="paragraph"><p>A <code>-</code> character in the column N means that the line appears in
2381 fileN but it does not appear in the result. A <code>+</code> character
2382 in the column N means that the line appears in the result,
2383 and fileN does not have that line (in other words, the line was
2384 added, from the point of view of that parent).</p></div>
2385 <div class="paragraph"><p>In the above example output, the function signature was changed
2386 from both files (hence two <code>-</code> removals from both file1 and
2387 file2, plus <code>++</code> to mean one line that was added does not appear
2388 in either file1 or file2). Also eight other lines are the same
2389 from file1 but do not appear in file2 (hence prefixed with <code>+</code>).</p></div>
2390 <div class="paragraph"><p>When shown by <code>git diff-tree -c</code>, it compares the parents of a
2391 merge commit with the merge result (i.e. file1..fileN are the
2392 parents). When shown by <code>git diff-files -c</code>, it compares the
2393 two unresolved merge parents with the working tree file
2394 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
2395 "their version").</p></div>
2396 </div>
2397 </div>
2398 <div class="sect1">
2399 <h2 id="_other_diff_formats">other diff formats</h2>
2400 <div class="sectionbody">
2401 <div class="paragraph"><p>The <code>--summary</code> option describes newly added, deleted, renamed and
2402 copied files. The <code>--stat</code> option adds diffstat(1) graph to the
2403 output. These options can be combined with other options, such as
2404 <code>-p</code>, and are meant for human consumption.</p></div>
2405 <div class="paragraph"><p>When showing a change that involves a rename or a copy, <code>--stat</code> output
2406 formats the pathnames compactly by combining common prefix and suffix of
2407 the pathnames. For example, a change that moves <code>arch/i386/Makefile</code> to
2408 <code>arch/x86/Makefile</code> while modifying 4 lines will be shown like this:</p></div>
2409 <div class="listingblock">
2410 <div class="content">
2411 <pre><code>arch/{i386 => x86}/Makefile | 4 +--</code></pre>
2412 </div></div>
2413 <div class="paragraph"><p>The <code>--numstat</code> option gives the diffstat(1) information but is designed
2414 for easier machine consumption. An entry in <code>--numstat</code> output looks
2415 like this:</p></div>
2416 <div class="listingblock">
2417 <div class="content">
2418 <pre><code>1 2 README
2419 3 1 arch/{i386 => x86}/Makefile</code></pre>
2420 </div></div>
2421 <div class="paragraph"><p>That is, from left to right:</p></div>
2422 <div class="olist arabic"><ol class="arabic">
2423 <li>
2424 <p>
2425 the number of added lines;
2426 </p>
2427 </li>
2428 <li>
2429 <p>
2430 a tab;
2431 </p>
2432 </li>
2433 <li>
2434 <p>
2435 the number of deleted lines;
2436 </p>
2437 </li>
2438 <li>
2439 <p>
2440 a tab;
2441 </p>
2442 </li>
2443 <li>
2444 <p>
2445 pathname (possibly with rename/copy information);
2446 </p>
2447 </li>
2448 <li>
2449 <p>
2450 a newline.
2451 </p>
2452 </li>
2453 </ol></div>
2454 <div class="paragraph"><p>When <code>-z</code> output option is in effect, the output is formatted this way:</p></div>
2455 <div class="listingblock">
2456 <div class="content">
2457 <pre><code>1 2 README NUL
2458 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</code></pre>
2459 </div></div>
2460 <div class="paragraph"><p>That is:</p></div>
2461 <div class="olist arabic"><ol class="arabic">
2462 <li>
2463 <p>
2464 the number of added lines;
2465 </p>
2466 </li>
2467 <li>
2468 <p>
2469 a tab;
2470 </p>
2471 </li>
2472 <li>
2473 <p>
2474 the number of deleted lines;
2475 </p>
2476 </li>
2477 <li>
2478 <p>
2479 a tab;
2480 </p>
2481 </li>
2482 <li>
2483 <p>
2484 a NUL (only exists if renamed/copied);
2485 </p>
2486 </li>
2487 <li>
2488 <p>
2489 pathname in preimage;
2490 </p>
2491 </li>
2492 <li>
2493 <p>
2494 a NUL (only exists if renamed/copied);
2495 </p>
2496 </li>
2497 <li>
2498 <p>
2499 pathname in postimage (only exists if renamed/copied);
2500 </p>
2501 </li>
2502 <li>
2503 <p>
2504 a NUL.
2505 </p>
2506 </li>
2507 </ol></div>
2508 <div class="paragraph"><p>The extra <code>NUL</code> before the preimage path in renamed case is to allow
2509 scripts that read the output to tell if the current record being read is
2510 a single-path record or a rename/copy record without reading ahead.
2511 After reading added and deleted lines, reading up to <code>NUL</code> would yield
2512 the pathname, but if that is <code>NUL</code>, the record will show two paths.</p></div>
2513 </div>
2514 </div>
2515 <div class="sect1">
2516 <h2 id="_operating_modes">OPERATING MODES</h2>
2517 <div class="sectionbody">
2518 <div class="paragraph"><p>You can choose whether you want to trust the index file entirely
2519 (using the <code>--cached</code> flag) or ask the diff logic to show any files
2520 that don’t match the stat state as being "tentatively changed". Both
2521 of these operations are very useful indeed.</p></div>
2522 </div>
2523 </div>
2524 <div class="sect1">
2525 <h2 id="_cached_mode">CACHED MODE</h2>
2526 <div class="sectionbody">
2527 <div class="paragraph"><p>If <code>--cached</code> is specified, it allows you to ask:</p></div>
2528 <div class="literalblock">
2529 <div class="content">
2530 <pre><code>show me the differences between HEAD and the current index
2531 contents (the ones I'd write using 'git write-tree')</code></pre>
2532 </div></div>
2533 <div class="paragraph"><p>For example, let’s say that you have worked on your working directory, updated
2534 some files in the index and are ready to commit. You want to see exactly
2535 <strong>what</strong> you are going to commit, without having to write a new tree
2536 object and compare it that way, and to do that, you just do</p></div>
2537 <div class="literalblock">
2538 <div class="content">
2539 <pre><code>git diff-index --cached HEAD</code></pre>
2540 </div></div>
2541 <div class="paragraph"><p>Example: let’s say I had renamed <code>commit.c</code> to <code>git-commit.c</code>, and I had
2542 done an <code>update-index</code> to make that effective in the index file.
2543 <code>git diff-files</code> wouldn’t show anything at all, since the index file
2544 matches my working directory. But doing a <em>git diff-index</em> does:</p></div>
2545 <div class="literalblock">
2546 <div class="content">
2547 <pre><code>torvalds@ppc970:~/git> git diff-index --cached HEAD
2548 -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c
2549 +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</code></pre>
2550 </div></div>
2551 <div class="paragraph"><p>You can see easily that the above is a rename.</p></div>
2552 <div class="paragraph"><p>In fact, <code>git diff-index --cached</code> <strong>should</strong> always be entirely equivalent to
2553 actually doing a <em>git write-tree</em> and comparing that. Except this one is much
2554 nicer for the case where you just want to check where you are.</p></div>
2555 <div class="paragraph"><p>So doing a <code>git diff-index --cached</code> is basically very useful when you are
2556 asking yourself "what have I already marked for being committed, and
2557 what’s the difference to a previous tree".</p></div>
2558 </div>
2559 </div>
2560 <div class="sect1">
2561 <h2 id="_non_cached_mode">NON-CACHED MODE</h2>
2562 <div class="sectionbody">
2563 <div class="paragraph"><p>The "non-cached" mode takes a different approach, and is potentially
2564 the more useful of the two in that what it does can’t be emulated with
2565 a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that’s the default mode.
2566 The non-cached version asks the question:</p></div>
2567 <div class="literalblock">
2568 <div class="content">
2569 <pre><code>show me the differences between HEAD and the currently checked out
2570 tree - index contents _and_ files that aren't up to date</code></pre>
2571 </div></div>
2572 <div class="paragraph"><p>which is obviously a very useful question too, since that tells you what
2573 you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em>
2574 output to a tee, but with a twist.</p></div>
2575 <div class="paragraph"><p>The twist is that if some file doesn’t match the index, we don’t have
2576 a backing store thing for it, and we use the magic "all-zero" sha1 to
2577 show that. So let’s say that you have edited <code>kernel/sched.c</code>, but
2578 have not actually done a <em>git update-index</em> on it yet - there is no
2579 "object" associated with the new state, and you get:</p></div>
2580 <div class="literalblock">
2581 <div class="content">
2582 <pre><code>torvalds@ppc970:~/v2.6/linux> git diff-index --abbrev HEAD
2583 :100644 100664 7476bb... 000000... kernel/sched.c</code></pre>
2584 </div></div>
2585 <div class="paragraph"><p>i.e., it shows that the tree has changed, and that <code>kernel/sched.c</code> is
2586 not up to date and may contain new stuff. The all-zero sha1 means that to
2587 get the real diff, you need to look at the object in the working directory
2588 directly rather than do an object-to-object diff.</p></div>
2589 <div class="admonitionblock">
2590 <table><tr>
2591 <td class="icon">
2592 <div class="title">Note</div>
2593 </td>
2594 <td class="content">As with other commands of this type, <em>git diff-index</em> does not
2595 actually look at the contents of the file at all. So maybe
2596 <code>kernel/sched.c</code> hasn’t actually changed, and it’s just that you
2597 touched it. In either case, it’s a note that you need to
2598 <em>git update-index</em> it to make the index be in sync.</td>
2599 </tr></table>
2600 </div>
2601 <div class="admonitionblock">
2602 <table><tr>
2603 <td class="icon">
2604 <div class="title">Note</div>
2605 </td>
2606 <td class="content">You can have a mixture of files show up as "has been updated"
2607 and "is still dirty in the working directory" together. You can always
2608 tell which file is in which state, since the "has been updated" ones
2609 show a valid sha1, and the "not in sync with the index" ones will
2610 always have the special all-zero sha1.</td>
2611 </tr></table>
2612 </div>
2613 </div>
2614 </div>
2615 <div class="sect1">
2616 <h2 id="_git">GIT</h2>
2617 <div class="sectionbody">
2618 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2619 </div>
2620 </div>
2621 </div>
2622 <div id="footnotes"><hr /></div>
2623 <div id="footer">
2624 <div id="footer-text">
2625 Last updated
2626 2018-12-10 16:43:18 JST
2627 </div>
2628 </div>
2629 </body>
2630 </html>