Updated git_doc to git 1.8
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-diff-index.xml
blob6446f992a401354a5e1955490a83c7767e9b3e85
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="git-diff-index(1)">\r
5     <title>git-diff-index(1)</title>\r
6 <indexterm>\r
7 <primary>git-diff-index(1)</primary>\r
8 </indexterm>\r
9 <simplesect id="git-diff-index(1)__name">\r
10 <title>NAME</title>\r
11 <simpara>git-diff-index - Compares content and mode of blobs between the index and repository</simpara>\r
12 </simplesect>\r
13 <simplesect id="git-diff-index(1)__synopsis">\r
14 <title>SYNOPSIS</title>\r
15 <blockquote>\r
16 <literallayout><emphasis>git diff-index</emphasis> [-m] [--cached] [&lt;common diff options&gt;] &lt;tree-ish&gt; [&lt;path&gt;&#8230;]</literallayout>\r
17 </blockquote>\r
18 </simplesect>\r
19 <simplesect id="git-diff-index(1)__description">\r
20 <title>DESCRIPTION</title>\r
21 <simpara>Compares the content and mode of the blobs found via a tree\r
22 object with the content of the current index and, optionally\r
23 ignoring the stat state of the file on disk.  When paths are\r
24 specified, compares only those named paths.  Otherwise all\r
25 entries in the index are compared.</simpara>\r
26 </simplesect>\r
27 <simplesect id="git-diff-index(1)__options">\r
28 <title>OPTIONS</title>\r
29 <variablelist>\r
30 <varlistentry>\r
31 <term>\r
32 -p\r
33 </term>\r
34 <term>\r
35 -u\r
36 </term>\r
37 <term>\r
38 --patch\r
39 </term>\r
40 <listitem>\r
41 <simpara>\r
42         Generate patch (see section on generating patches).\r
43         \r
44 </simpara>\r
45 </listitem>\r
46 </varlistentry>\r
47 <varlistentry>\r
48 <term>\r
49 -U&lt;n&gt;\r
50 </term>\r
51 <term>\r
52 --unified=&lt;n&gt;\r
53 </term>\r
54 <listitem>\r
55 <simpara>\r
56         Generate diffs with &lt;n&gt; lines of context instead of\r
57         the usual three.\r
58         Implies <emphasis>-p</emphasis>.\r
59 </simpara>\r
60 </listitem>\r
61 </varlistentry>\r
62 <varlistentry>\r
63 <term>\r
64 --raw\r
65 </term>\r
66 <listitem>\r
67 <simpara>\r
68         Generate the raw format.\r
69          This is the default.\r
70 </simpara>\r
71 </listitem>\r
72 </varlistentry>\r
73 <varlistentry>\r
74 <term>\r
75 --patch-with-raw\r
76 </term>\r
77 <listitem>\r
78 <simpara>\r
79         Synonym for <emphasis>-p --raw</emphasis>.\r
80 </simpara>\r
81 </listitem>\r
82 </varlistentry>\r
83 <varlistentry>\r
84 <term>\r
85 --minimal\r
86 </term>\r
87 <listitem>\r
88 <simpara>\r
89         Spend extra time to make sure the smallest possible\r
90         diff is produced.\r
91 </simpara>\r
92 </listitem>\r
93 </varlistentry>\r
94 <varlistentry>\r
95 <term>\r
96 --patience\r
97 </term>\r
98 <listitem>\r
99 <simpara>\r
100         Generate a diff using the "patience diff" algorithm.\r
101 </simpara>\r
102 </listitem>\r
103 </varlistentry>\r
104 <varlistentry>\r
105 <term>\r
106 --histogram\r
107 </term>\r
108 <listitem>\r
109 <simpara>\r
110         Generate a diff using the "histogram diff" algorithm.\r
111 </simpara>\r
112 </listitem>\r
113 </varlistentry>\r
114 <varlistentry>\r
115 <term>\r
116 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]\r
117 </term>\r
118 <listitem>\r
119 <simpara>\r
120         Generate a diffstat. By default, as much space as necessary\r
121         will be used for the filename part, and the rest for the graph\r
122         part. Maximum width defaults to terminal width, or 80 columns\r
123         if not connected to a terminal, and can be overridden by\r
124         <emphasis>&lt;width&gt;</emphasis>. The width of the filename part can be limited by\r
125         giving another width <emphasis>&lt;name-width&gt;</emphasis> after a comma. The width\r
126         of the graph part can be limited by using\r
127         <emphasis>--stat-graph-width=&lt;width&gt;</emphasis> (affects all commands generating\r
128         a stat graph) or by setting <emphasis>diff.statGraphWidth=&lt;width&gt;</emphasis>\r
129         (does not affect <emphasis>git format-patch</emphasis>).\r
130         By giving a third parameter <emphasis>&lt;count&gt;</emphasis>, you can limit the\r
131         output to the first <emphasis>&lt;count&gt;</emphasis> lines, followed by <emphasis>...</emphasis> if\r
132         there are more.\r
133 </simpara>\r
134 <simpara>These parameters can also be set individually with <emphasis>--stat-width=&lt;width&gt;</emphasis>,\r
135 <emphasis>--stat-name-width=&lt;name-width&gt;</emphasis> and <emphasis>--stat-count=&lt;count&gt;</emphasis>.</simpara>\r
136 </listitem>\r
137 </varlistentry>\r
138 <varlistentry>\r
139 <term>\r
140 --numstat\r
141 </term>\r
142 <listitem>\r
143 <simpara>\r
144         Similar to <emphasis>--stat</emphasis>, but shows number of added and\r
145         deleted lines in decimal notation and pathname without\r
146         abbreviation, to make it more machine friendly.  For\r
147         binary files, outputs two <emphasis>-</emphasis> instead of saying\r
148         <emphasis>0 0</emphasis>.\r
149 </simpara>\r
150 </listitem>\r
151 </varlistentry>\r
152 <varlistentry>\r
153 <term>\r
154 --shortstat\r
155 </term>\r
156 <listitem>\r
157 <simpara>\r
158         Output only the last line of the <emphasis>--stat</emphasis> format containing total\r
159         number of modified files, as well as number of added and deleted\r
160         lines.\r
161 </simpara>\r
162 </listitem>\r
163 </varlistentry>\r
164 <varlistentry>\r
165 <term>\r
166 --dirstat[=&lt;param1,param2,&#8230;&gt;]\r
167 </term>\r
168 <listitem>\r
169 <simpara>\r
170         Output the distribution of relative amount of changes for each\r
171         sub-directory. The behavior of <emphasis>--dirstat</emphasis> can be customized by\r
172         passing it a comma separated list of parameters.\r
173         The defaults are controlled by the <emphasis>diff.dirstat</emphasis> configuration\r
174         variable (see <xref linkend="git-config(1)" />).\r
175         The following parameters are available:\r
176 </simpara>\r
177 <variablelist>\r
178 <varlistentry>\r
179 <term>\r
180 <emphasis>changes</emphasis>\r
181 </term>\r
182 <listitem>\r
183 <simpara>\r
184         Compute the dirstat numbers by counting the lines that have been\r
185         removed from the source, or added to the destination. This ignores\r
186         the amount of pure code movements within a file.  In other words,\r
187         rearranging lines in a file is not counted as much as other changes.\r
188         This is the default behavior when no parameter is given.\r
189 </simpara>\r
190 </listitem>\r
191 </varlistentry>\r
192 <varlistentry>\r
193 <term>\r
194 <emphasis>lines</emphasis>\r
195 </term>\r
196 <listitem>\r
197 <simpara>\r
198         Compute the dirstat numbers by doing the regular line-based diff\r
199         analysis, and summing the removed/added line counts. (For binary\r
200         files, count 64-byte chunks instead, since binary files have no\r
201         natural concept of lines). This is a more expensive <emphasis>--dirstat</emphasis>\r
202         behavior than the <emphasis>changes</emphasis> behavior, but it does count rearranged\r
203         lines within a file as much as other changes. The resulting output\r
204         is consistent with what you get from the other <emphasis>--*stat</emphasis> options.\r
205 </simpara>\r
206 </listitem>\r
207 </varlistentry>\r
208 <varlistentry>\r
209 <term>\r
210 <emphasis>files</emphasis>\r
211 </term>\r
212 <listitem>\r
213 <simpara>\r
214         Compute the dirstat numbers by counting the number of files changed.\r
215         Each changed file counts equally in the dirstat analysis. This is\r
216         the computationally cheapest <emphasis>--dirstat</emphasis> behavior, since it does\r
217         not have to look at the file contents at all.\r
218 </simpara>\r
219 </listitem>\r
220 </varlistentry>\r
221 <varlistentry>\r
222 <term>\r
223 <emphasis>cumulative</emphasis>\r
224 </term>\r
225 <listitem>\r
226 <simpara>\r
227         Count changes in a child directory for the parent directory as well.\r
228         Note that when using <emphasis>cumulative</emphasis>, the sum of the percentages\r
229         reported may exceed 100%. The default (non-cumulative) behavior can\r
230         be specified with the <emphasis>noncumulative</emphasis> parameter.\r
231 </simpara>\r
232 </listitem>\r
233 </varlistentry>\r
234 <varlistentry>\r
235 <term>\r
236 &lt;limit&gt;\r
237 </term>\r
238 <listitem>\r
239 <simpara>\r
240         An integer parameter specifies a cut-off percent (3% by default).\r
241         Directories contributing less than this percentage of the changes\r
242         are not shown in the output.\r
243 </simpara>\r
244 </listitem>\r
245 </varlistentry>\r
246 </variablelist>\r
247 <simpara>Example: The following will count changed files, while ignoring\r
248 directories with less than 10% of the total amount of changed files,\r
249 and accumulating child directory counts in the parent directories:\r
250 <emphasis>--dirstat=files,10,cumulative</emphasis>.</simpara>\r
251 </listitem>\r
252 </varlistentry>\r
253 <varlistentry>\r
254 <term>\r
255 --summary\r
256 </term>\r
257 <listitem>\r
258 <simpara>\r
259         Output a condensed summary of extended header information\r
260         such as creations, renames and mode changes.\r
261 </simpara>\r
262 </listitem>\r
263 </varlistentry>\r
264 <varlistentry>\r
265 <term>\r
266 --patch-with-stat\r
267 </term>\r
268 <listitem>\r
269 <simpara>\r
270         Synonym for <emphasis>-p --stat</emphasis>.\r
271 </simpara>\r
272 </listitem>\r
273 </varlistentry>\r
274 <varlistentry>\r
275 <term>\r
276 -z\r
277 </term>\r
278 <listitem>\r
279 <simpara>\r
280         When <emphasis>--raw</emphasis>, <emphasis>--numstat</emphasis>, <emphasis>--name-only</emphasis> or <emphasis>--name-status</emphasis> has been\r
281         given, do not munge pathnames and use NULs as output field terminators.\r
282 </simpara>\r
283 <simpara>Without this option, each pathname output will have TAB, LF, double quotes,\r
284 and backslash characters replaced with <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, <emphasis>\"</emphasis>, and <emphasis>\\</emphasis>,\r
285 respectively, and the pathname will be enclosed in double quotes if\r
286 any of those replacements occurred.</simpara>\r
287 </listitem>\r
288 </varlistentry>\r
289 <varlistentry>\r
290 <term>\r
291 --name-only\r
292 </term>\r
293 <listitem>\r
294 <simpara>\r
295         Show only names of changed files.\r
296 </simpara>\r
297 </listitem>\r
298 </varlistentry>\r
299 <varlistentry>\r
300 <term>\r
301 --name-status\r
302 </term>\r
303 <listitem>\r
304 <simpara>\r
305         Show only names and status of changed files. See the description\r
306         of the <emphasis>--diff-filter</emphasis> option on what the status letters mean.\r
307 </simpara>\r
308 </listitem>\r
309 </varlistentry>\r
310 <varlistentry>\r
311 <term>\r
312 --submodule[=&lt;format&gt;]\r
313 </term>\r
314 <listitem>\r
315 <simpara>\r
316         Specify how differences in submodules are shown.  When <emphasis>--submodule</emphasis>\r
317         or <emphasis>--submodule=log</emphasis> is given, the <emphasis>log</emphasis> format is used.  This format lists\r
318         the commits in the range like <xref linkend="git-submodule(1)" /> <emphasis>summary</emphasis> does.\r
319         Omitting the <emphasis>--submodule</emphasis> option or specifying <emphasis>--submodule=short</emphasis>,\r
320         uses the <emphasis>short</emphasis> format. This format just shows the names of the commits\r
321         at the beginning and end of the range.  Can be tweaked via the\r
322         <emphasis>diff.submodule</emphasis> configuration variable.\r
323 </simpara>\r
324 </listitem>\r
325 </varlistentry>\r
326 <varlistentry>\r
327 <term>\r
328 --color[=&lt;when&gt;]\r
329 </term>\r
330 <listitem>\r
331 <simpara>\r
332         Show colored diff.\r
333         The value must be <emphasis>always</emphasis> (the default for <emphasis>&lt;when&gt;</emphasis>), <emphasis>never</emphasis>, or <emphasis>auto</emphasis>.\r
334         The default value is <emphasis>never</emphasis>.\r
335 </simpara>\r
336 </listitem>\r
337 </varlistentry>\r
338 <varlistentry>\r
339 <term>\r
340 --no-color\r
341 </term>\r
342 <listitem>\r
343 <simpara>\r
344         Turn off colored diff.\r
345         It is the same as <emphasis>--color=never</emphasis>.\r
346 </simpara>\r
347 </listitem>\r
348 </varlistentry>\r
349 <varlistentry>\r
350 <term>\r
351 --word-diff[=&lt;mode&gt;]\r
352 </term>\r
353 <listitem>\r
354 <simpara>\r
355         Show a word diff, using the &lt;mode&gt; to delimit changed words.\r
356         By default, words are delimited by whitespace; see\r
357         <emphasis>--word-diff-regex</emphasis> below.  The &lt;mode&gt; defaults to <emphasis>plain</emphasis>, and\r
358         must be one of:\r
359 </simpara>\r
360 <variablelist>\r
361 <varlistentry>\r
362 <term>\r
363 color\r
364 </term>\r
365 <listitem>\r
366 <simpara>\r
367         Highlight changed words using only colors.  Implies <emphasis>--color</emphasis>.\r
368 </simpara>\r
369 </listitem>\r
370 </varlistentry>\r
371 <varlistentry>\r
372 <term>\r
373 plain\r
374 </term>\r
375 <listitem>\r
376 <simpara>\r
377         Show words as <emphasis>[-removed-]</emphasis> and <emphasis>{+added+}</emphasis>.  Makes no\r
378         attempts to escape the delimiters if they appear in the input,\r
379         so the output may be ambiguous.\r
380 </simpara>\r
381 </listitem>\r
382 </varlistentry>\r
383 <varlistentry>\r
384 <term>\r
385 porcelain\r
386 </term>\r
387 <listitem>\r
388 <simpara>\r
389         Use a special line-based format intended for script\r
390         consumption.  Added/removed/unchanged runs are printed in the\r
391         usual unified diff format, starting with a <emphasis>+</emphasis>/<emphasis>-</emphasis>/` `\r
392         character at the beginning of the line and extending to the\r
393         end of the line.  Newlines in the input are represented by a\r
394         tilde <emphasis>~</emphasis> on a line of its own.\r
395 </simpara>\r
396 </listitem>\r
397 </varlistentry>\r
398 <varlistentry>\r
399 <term>\r
400 none\r
401 </term>\r
402 <listitem>\r
403 <simpara>\r
404         Disable word diff again.\r
405 </simpara>\r
406 </listitem>\r
407 </varlistentry>\r
408 </variablelist>\r
409 <simpara>Note that despite the name of the first mode, color is used to\r
410 highlight the changed parts in all modes if enabled.</simpara>\r
411 </listitem>\r
412 </varlistentry>\r
413 <varlistentry>\r
414 <term>\r
415 --word-diff-regex=&lt;regex&gt;\r
416 </term>\r
417 <listitem>\r
418 <simpara>\r
419         Use &lt;regex&gt; to decide what a word is, instead of considering\r
420         runs of non-whitespace to be a word.  Also implies\r
421         <emphasis>--word-diff</emphasis> unless it was already enabled.\r
422 </simpara>\r
423 <simpara>Every non-overlapping match of the\r
424 &lt;regex&gt; is considered a word.  Anything between these matches is\r
425 considered whitespace and ignored(!) for the purposes of finding\r
426 differences.  You may want to append <emphasis>|[^[:space:]]</emphasis> to your regular\r
427 expression to make sure that it matches all non-whitespace characters.\r
428 A match that contains a newline is silently truncated(!) at the\r
429 newline.</simpara>\r
430 <simpara>The regex can also be set via a diff driver or configuration option, see\r
431 <xref linkend="gitattributes(1)" /> or <xref linkend="git-config(1)" />.  Giving it explicitly\r
432 overrides any diff driver or configuration setting.  Diff drivers\r
433 override configuration settings.</simpara>\r
434 </listitem>\r
435 </varlistentry>\r
436 <varlistentry>\r
437 <term>\r
438 --color-words[=&lt;regex&gt;]\r
439 </term>\r
440 <listitem>\r
441 <simpara>\r
442         Equivalent to <emphasis>--word-diff=color</emphasis> plus (if a regex was\r
443         specified) <emphasis>--word-diff-regex=&lt;regex&gt;</emphasis>.\r
444 </simpara>\r
445 </listitem>\r
446 </varlistentry>\r
447 <varlistentry>\r
448 <term>\r
449 --no-renames\r
450 </term>\r
451 <listitem>\r
452 <simpara>\r
453         Turn off rename detection, even when the configuration\r
454         file gives the default to do so.\r
455 </simpara>\r
456 </listitem>\r
457 </varlistentry>\r
458 <varlistentry>\r
459 <term>\r
460 --check\r
461 </term>\r
462 <listitem>\r
463 <simpara>\r
464         Warn if changes introduce whitespace errors.  What are\r
465         considered whitespace errors is controlled by <emphasis>core.whitespace</emphasis>\r
466         configuration.  By default, trailing whitespaces (including\r
467         lines that solely consist of whitespaces) and a space character\r
468         that is immediately followed by a tab character inside the\r
469         initial indent of the line are considered whitespace errors.\r
470         Exits with non-zero status if problems are found. Not compatible\r
471         with --exit-code.\r
472 </simpara>\r
473 </listitem>\r
474 </varlistentry>\r
475 <varlistentry>\r
476 <term>\r
477 --full-index\r
478 </term>\r
479 <listitem>\r
480 <simpara>\r
481         Instead of the first handful of characters, show the full\r
482         pre- and post-image blob object names on the "index"\r
483         line when generating patch format output.\r
484 </simpara>\r
485 </listitem>\r
486 </varlistentry>\r
487 <varlistentry>\r
488 <term>\r
489 --binary\r
490 </term>\r
491 <listitem>\r
492 <simpara>\r
493         In addition to <emphasis>--full-index</emphasis>, output a binary diff that\r
494         can be applied with <emphasis>git-apply</emphasis>.\r
495 </simpara>\r
496 </listitem>\r
497 </varlistentry>\r
498 <varlistentry>\r
499 <term>\r
500 --abbrev[=&lt;n&gt;]\r
501 </term>\r
502 <listitem>\r
503 <simpara>\r
504         Instead of showing the full 40-byte hexadecimal object\r
505         name in diff-raw format output and diff-tree header\r
506         lines, show only a partial prefix.  This is\r
507         independent of the <emphasis>--full-index</emphasis> option above, which controls\r
508         the diff-patch output format.  Non default number of\r
509         digits can be specified with <emphasis>--abbrev=&lt;n&gt;</emphasis>.\r
510 </simpara>\r
511 </listitem>\r
512 </varlistentry>\r
513 <varlistentry>\r
514 <term>\r
515 -B[&lt;n&gt;][/&lt;m&gt;]\r
516 </term>\r
517 <term>\r
518 --break-rewrites[=[&lt;n&gt;][/&lt;m&gt;]]\r
519 </term>\r
520 <listitem>\r
521 <simpara>\r
522         Break complete rewrite changes into pairs of delete and\r
523         create. This serves two purposes:\r
524 </simpara>\r
525 <simpara>It affects the way a change that amounts to a total rewrite of a file\r
526 not as a series of deletion and insertion mixed together with a very\r
527 few lines that happen to match textually as the context, but as a\r
528 single deletion of everything old followed by a single insertion of\r
529 everything new, and the number <emphasis>m</emphasis> controls this aspect of the -B\r
530 option (defaults to 60%). <emphasis>-B/70%</emphasis> specifies that less than 30% of the\r
531 original should remain in the result for git to consider it a total\r
532 rewrite (i.e. otherwise the resulting patch will be a series of\r
533 deletion and insertion mixed together with context lines).</simpara>\r
534 <simpara>When used with -M, a totally-rewritten file is also considered as the\r
535 source of a rename (usually -M only considers a file that disappeared\r
536 as the source of a rename), and the number <emphasis>n</emphasis> controls this aspect of\r
537 the -B option (defaults to 50%). <emphasis>-B20%</emphasis> specifies that a change with\r
538 addition and deletion compared to 20% or more of the file's size are\r
539 eligible for being picked up as a possible source of a rename to\r
540 another file.</simpara>\r
541 </listitem>\r
542 </varlistentry>\r
543 <varlistentry>\r
544 <term>\r
545 -M[&lt;n&gt;]\r
546 </term>\r
547 <term>\r
548 --find-renames[=&lt;n&gt;]\r
549 </term>\r
550 <listitem>\r
551 <simpara>\r
552         Detect renames.\r
553         If <emphasis>n</emphasis> is specified, it is a threshold on the similarity\r
554         index (i.e. amount of addition/deletions compared to the\r
555         file's size). For example, <emphasis>-M90%</emphasis> means git should consider a\r
556         delete/add pair to be a rename if more than 90% of the file\r
557         hasn't changed.  Without a <emphasis>%</emphasis> sign, the number is to be read as\r
558         a fraction, with a decimal point before it.  I.e., <emphasis>-M5</emphasis> becomes\r
559         0.5, and is thus the same as <emphasis>-M50%</emphasis>.  Similarly, <emphasis>-M05</emphasis> is\r
560         the same as <emphasis>-M5%</emphasis>.  To limit detection to exact renames, use\r
561         <emphasis>-M100%</emphasis>.\r
562 </simpara>\r
563 </listitem>\r
564 </varlistentry>\r
565 <varlistentry>\r
566 <term>\r
567 -C[&lt;n&gt;]\r
568 </term>\r
569 <term>\r
570 --find-copies[=&lt;n&gt;]\r
571 </term>\r
572 <listitem>\r
573 <simpara>\r
574         Detect copies as well as renames.  See also <emphasis>--find-copies-harder</emphasis>.\r
575         If <emphasis>n</emphasis> is specified, it has the same meaning as for <emphasis>-M&lt;n&gt;</emphasis>.\r
576 </simpara>\r
577 </listitem>\r
578 </varlistentry>\r
579 <varlistentry>\r
580 <term>\r
581 --find-copies-harder\r
582 </term>\r
583 <listitem>\r
584 <simpara>\r
585         For performance reasons, by default, <emphasis>-C</emphasis> option finds copies only\r
586         if the original file of the copy was modified in the same\r
587         changeset.  This flag makes the command\r
588         inspect unmodified files as candidates for the source of\r
589         copy.  This is a very expensive operation for large\r
590         projects, so use it with caution.  Giving more than one\r
591         <emphasis>-C</emphasis> option has the same effect.\r
592 </simpara>\r
593 </listitem>\r
594 </varlistentry>\r
595 <varlistentry>\r
596 <term>\r
597 -D\r
598 </term>\r
599 <term>\r
600 --irreversible-delete\r
601 </term>\r
602 <listitem>\r
603 <simpara>\r
604         Omit the preimage for deletes, i.e. print only the header but not\r
605         the diff between the preimage and <emphasis>/dev/null</emphasis>. The resulting patch\r
606         is not meant to be applied with <emphasis>patch</emphasis> nor <emphasis>git apply</emphasis>; this is\r
607         solely for people who want to just concentrate on reviewing the\r
608         text after the change. In addition, the output obviously lack\r
609         enough information to apply such a patch in reverse, even manually,\r
610         hence the name of the option.\r
611 </simpara>\r
612 <simpara>When used together with <emphasis>-B</emphasis>, omit also the preimage in the deletion part\r
613 of a delete/create pair.</simpara>\r
614 </listitem>\r
615 </varlistentry>\r
616 <varlistentry>\r
617 <term>\r
618 -l&lt;num&gt;\r
619 </term>\r
620 <listitem>\r
621 <simpara>\r
622         The <emphasis>-M</emphasis> and <emphasis>-C</emphasis> options require O(n^2) processing time where n\r
623         is the number of potential rename/copy targets.  This\r
624         option prevents rename/copy detection from running if\r
625         the number of rename/copy targets exceeds the specified\r
626         number.\r
627 </simpara>\r
628 </listitem>\r
629 </varlistentry>\r
630 <varlistentry>\r
631 <term>\r
632 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]\r
633 </term>\r
634 <listitem>\r
635 <simpara>\r
636         Select only files that are Added (<emphasis>A</emphasis>), Copied (<emphasis>C</emphasis>),\r
637         Deleted (<emphasis>D</emphasis>), Modified (<emphasis>M</emphasis>), Renamed (<emphasis>R</emphasis>), have their\r
638         type (i.e. regular file, symlink, submodule, &#8230;) changed (<emphasis>T</emphasis>),\r
639         are Unmerged (<emphasis>U</emphasis>), are\r
640         Unknown (<emphasis>X</emphasis>), or have had their pairing Broken (<emphasis>B</emphasis>).\r
641         Any combination of the filter characters (including none) can be used.\r
642         When <emphasis>*</emphasis> (All-or-none) is added to the combination, all\r
643         paths are selected if there is any file that matches\r
644         other criteria in the comparison; if there is no file\r
645         that matches other criteria, nothing is selected.\r
646 </simpara>\r
647 </listitem>\r
648 </varlistentry>\r
649 <varlistentry>\r
650 <term>\r
651 -S&lt;string&gt;\r
652 </term>\r
653 <listitem>\r
654 <simpara>\r
655         Look for differences that introduce or remove an instance of\r
656         &lt;string&gt;. Note that this is different than the string simply\r
657         appearing in diff output; see the <emphasis>pickaxe</emphasis> entry in\r
658         <xref linkend="gitdiffcore(7)" /> for more details.\r
659 </simpara>\r
660 </listitem>\r
661 </varlistentry>\r
662 <varlistentry>\r
663 <term>\r
664 -G&lt;regex&gt;\r
665 </term>\r
666 <listitem>\r
667 <simpara>\r
668         Look for differences whose added or removed line matches\r
669         the given &lt;regex&gt;.\r
670 </simpara>\r
671 </listitem>\r
672 </varlistentry>\r
673 <varlistentry>\r
674 <term>\r
675 --pickaxe-all\r
676 </term>\r
677 <listitem>\r
678 <simpara>\r
679         When <emphasis>-S</emphasis> or <emphasis>-G</emphasis> finds a change, show all the changes in that\r
680         changeset, not just the files that contain the change\r
681         in &lt;string&gt;.\r
682 </simpara>\r
683 </listitem>\r
684 </varlistentry>\r
685 <varlistentry>\r
686 <term>\r
687 --pickaxe-regex\r
688 </term>\r
689 <listitem>\r
690 <simpara>\r
691         Make the &lt;string&gt; not a plain string but an extended POSIX\r
692         regex to match.\r
693 </simpara>\r
694 </listitem>\r
695 </varlistentry>\r
696 <varlistentry>\r
697 <term>\r
698 -O&lt;orderfile&gt;\r
699 </term>\r
700 <listitem>\r
701 <simpara>\r
702         Output the patch in the order specified in the\r
703         &lt;orderfile&gt;, which has one shell glob pattern per line.\r
704 </simpara>\r
705 </listitem>\r
706 </varlistentry>\r
707 <varlistentry>\r
708 <term>\r
709 -R\r
710 </term>\r
711 <listitem>\r
712 <simpara>\r
713         Swap two inputs; that is, show differences from index or\r
714         on-disk file to tree contents.\r
715 </simpara>\r
716 </listitem>\r
717 </varlistentry>\r
718 <varlistentry>\r
719 <term>\r
720 --relative[=&lt;path&gt;]\r
721 </term>\r
722 <listitem>\r
723 <simpara>\r
724         When run from a subdirectory of the project, it can be\r
725         told to exclude changes outside the directory and show\r
726         pathnames relative to it with this option.  When you are\r
727         not in a subdirectory (e.g. in a bare repository), you\r
728         can name which subdirectory to make the output relative\r
729         to by giving a &lt;path&gt; as an argument.\r
730 </simpara>\r
731 </listitem>\r
732 </varlistentry>\r
733 <varlistentry>\r
734 <term>\r
735 -a\r
736 </term>\r
737 <term>\r
738 --text\r
739 </term>\r
740 <listitem>\r
741 <simpara>\r
742         Treat all files as text.\r
743 </simpara>\r
744 </listitem>\r
745 </varlistentry>\r
746 <varlistentry>\r
747 <term>\r
748 --ignore-space-at-eol\r
749 </term>\r
750 <listitem>\r
751 <simpara>\r
752         Ignore changes in whitespace at EOL.\r
753 </simpara>\r
754 </listitem>\r
755 </varlistentry>\r
756 <varlistentry>\r
757 <term>\r
758 -b\r
759 </term>\r
760 <term>\r
761 --ignore-space-change\r
762 </term>\r
763 <listitem>\r
764 <simpara>\r
765         Ignore changes in amount of whitespace.  This ignores whitespace\r
766         at line end, and considers all other sequences of one or\r
767         more whitespace characters to be equivalent.\r
768 </simpara>\r
769 </listitem>\r
770 </varlistentry>\r
771 <varlistentry>\r
772 <term>\r
773 -w\r
774 </term>\r
775 <term>\r
776 --ignore-all-space\r
777 </term>\r
778 <listitem>\r
779 <simpara>\r
780         Ignore whitespace when comparing lines.  This ignores\r
781         differences even if one line has whitespace where the other\r
782         line has none.\r
783 </simpara>\r
784 </listitem>\r
785 </varlistentry>\r
786 <varlistentry>\r
787 <term>\r
788 --inter-hunk-context=&lt;lines&gt;\r
789 </term>\r
790 <listitem>\r
791 <simpara>\r
792         Show the context between diff hunks, up to the specified number\r
793         of lines, thereby fusing hunks that are close to each other.\r
794 </simpara>\r
795 </listitem>\r
796 </varlistentry>\r
797 <varlistentry>\r
798 <term>\r
799 -W\r
800 </term>\r
801 <term>\r
802 --function-context\r
803 </term>\r
804 <listitem>\r
805 <simpara>\r
806         Show whole surrounding functions of changes.\r
807 </simpara>\r
808 </listitem>\r
809 </varlistentry>\r
810 <varlistentry>\r
811 <term>\r
812 --exit-code\r
813 </term>\r
814 <listitem>\r
815 <simpara>\r
816         Make the program exit with codes similar to diff(1).\r
817         That is, it exits with 1 if there were differences and\r
818         0 means no differences.\r
819 </simpara>\r
820 </listitem>\r
821 </varlistentry>\r
822 <varlistentry>\r
823 <term>\r
824 --quiet\r
825 </term>\r
826 <listitem>\r
827 <simpara>\r
828         Disable all output of the program. Implies <emphasis>--exit-code</emphasis>.\r
829 </simpara>\r
830 </listitem>\r
831 </varlistentry>\r
832 <varlistentry>\r
833 <term>\r
834 --ext-diff\r
835 </term>\r
836 <listitem>\r
837 <simpara>\r
838         Allow an external diff helper to be executed. If you set an\r
839         external diff driver with <xref linkend="gitattributes(5)" />, you need\r
840         to use this option with <xref linkend="git-log(1)" /> and friends.\r
841 </simpara>\r
842 </listitem>\r
843 </varlistentry>\r
844 <varlistentry>\r
845 <term>\r
846 --no-ext-diff\r
847 </term>\r
848 <listitem>\r
849 <simpara>\r
850         Disallow external diff drivers.\r
851 </simpara>\r
852 </listitem>\r
853 </varlistentry>\r
854 <varlistentry>\r
855 <term>\r
856 --textconv\r
857 </term>\r
858 <term>\r
859 --no-textconv\r
860 </term>\r
861 <listitem>\r
862 <simpara>\r
863         Allow (or disallow) external text conversion filters to be run\r
864         when comparing binary files. See <xref linkend="gitattributes(5)" /> for\r
865         details. Because textconv filters are typically a one-way\r
866         conversion, the resulting diff is suitable for human\r
867         consumption, but cannot be applied. For this reason, textconv\r
868         filters are enabled by default only for <xref linkend="git-diff(1)" /> and\r
869         <xref linkend="git-log(1)" />, but not for <xref linkend="git-format-patch(1)" /> or\r
870         diff plumbing commands.\r
871 </simpara>\r
872 </listitem>\r
873 </varlistentry>\r
874 <varlistentry>\r
875 <term>\r
876 --ignore-submodules[=&lt;when&gt;]\r
877 </term>\r
878 <listitem>\r
879 <simpara>\r
880         Ignore changes to submodules in the diff generation. &lt;when&gt; can be\r
881         either "none", "untracked", "dirty" or "all", which is the default\r
882         Using "none" will consider the submodule modified when it either contains\r
883         untracked or modified files or its HEAD differs from the commit recorded\r
884         in the superproject and can be used to override any settings of the\r
885         <emphasis>ignore</emphasis> option in <xref linkend="git-config(1)" /> or <xref linkend="gitmodules(5)" />. When\r
886         "untracked" is used submodules are not considered dirty when they only\r
887         contain untracked content (but they are still scanned for modified\r
888         content). Using "dirty" ignores all changes to the work tree of submodules,\r
889         only changes to the commits stored in the superproject are shown (this was\r
890         the behavior until 1.7.0). Using "all" hides all changes to submodules.\r
891 </simpara>\r
892 </listitem>\r
893 </varlistentry>\r
894 <varlistentry>\r
895 <term>\r
896 --src-prefix=&lt;prefix&gt;\r
897 </term>\r
898 <listitem>\r
899 <simpara>\r
900         Show the given source prefix instead of "a/".\r
901 </simpara>\r
902 </listitem>\r
903 </varlistentry>\r
904 <varlistentry>\r
905 <term>\r
906 --dst-prefix=&lt;prefix&gt;\r
907 </term>\r
908 <listitem>\r
909 <simpara>\r
910         Show the given destination prefix instead of "b/".\r
911 </simpara>\r
912 </listitem>\r
913 </varlistentry>\r
914 <varlistentry>\r
915 <term>\r
916 --no-prefix\r
917 </term>\r
918 <listitem>\r
919 <simpara>\r
920         Do not show any source or destination prefix.\r
921 </simpara>\r
922 </listitem>\r
923 </varlistentry>\r
924 </variablelist>\r
925 <simpara>For more detailed explanation on these common options, see also\r
926 <xref linkend="gitdiffcore(7)" />.</simpara>\r
927 <variablelist>\r
928 <varlistentry>\r
929 <term>\r
930 &lt;tree-ish&gt;\r
931 </term>\r
932 <listitem>\r
933 <simpara>\r
934         The id of a tree object to diff against.\r
935 </simpara>\r
936 </listitem>\r
937 </varlistentry>\r
938 <varlistentry>\r
939 <term>\r
940 --cached\r
941 </term>\r
942 <listitem>\r
943 <simpara>\r
944         do not consider the on-disk file at all\r
945 </simpara>\r
946 </listitem>\r
947 </varlistentry>\r
948 <varlistentry>\r
949 <term>\r
950 -m\r
951 </term>\r
952 <listitem>\r
953 <simpara>\r
954         By default, files recorded in the index but not checked\r
955         out are reported as deleted.  This flag makes\r
956         <emphasis>git diff-index</emphasis> say that all non-checked-out files are up\r
957         to date.\r
958 </simpara>\r
959 </listitem>\r
960 </varlistentry>\r
961 </variablelist>\r
962 </simplesect>\r
963 <simplesect id="git-diff-index(1)__raw_output_format">\r
964 <title>Raw output format</title>\r
965 <simpara>The raw output format from "git-diff-index", "git-diff-tree",\r
966 "git-diff-files" and "git diff --raw" are very similar.</simpara>\r
967 <simpara>These commands all compare two sets of things; what is\r
968 compared differs:</simpara>\r
969 <variablelist>\r
970 <varlistentry>\r
971 <term>\r
972 git-diff-index &lt;tree-ish&gt;\r
973 </term>\r
974 <listitem>\r
975 <simpara>\r
976         compares the &lt;tree-ish&gt; and the files on the filesystem.\r
977 </simpara>\r
978 </listitem>\r
979 </varlistentry>\r
980 <varlistentry>\r
981 <term>\r
982 git-diff-index --cached &lt;tree-ish&gt;\r
983 </term>\r
984 <listitem>\r
985 <simpara>\r
986         compares the &lt;tree-ish&gt; and the index.\r
987 </simpara>\r
988 </listitem>\r
989 </varlistentry>\r
990 <varlistentry>\r
991 <term>\r
992 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]\r
993 </term>\r
994 <listitem>\r
995 <simpara>\r
996         compares the trees named by the two arguments.\r
997 </simpara>\r
998 </listitem>\r
999 </varlistentry>\r
1000 <varlistentry>\r
1001 <term>\r
1002 git-diff-files [&lt;pattern&gt;&#8230;]\r
1003 </term>\r
1004 <listitem>\r
1005 <simpara>\r
1006         compares the index and the files on the filesystem.\r
1007 </simpara>\r
1008 </listitem>\r
1009 </varlistentry>\r
1010 </variablelist>\r
1011 <simpara>The "git-diff-tree" command begins its output by printing the hash of\r
1012 what is being compared. After that, all the commands print one output\r
1013 line per changed file.</simpara>\r
1014 <simpara>An output line is formatted this way:</simpara>\r
1015 <screen>in-place edit  :100644 100644 bcd1234... 0123456... M file0\r
1016 copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2\r
1017 rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3\r
1018 create         :000000 100644 0000000... 1234567... A file4\r
1019 delete         :100644 000000 1234567... 0000000... D file5\r
1020 unmerged       :000000 000000 0000000... 0000000... U file6</screen>\r
1021 <simpara>That is, from the left to the right:</simpara>\r
1022 <orderedlist numeration="arabic">\r
1023 <listitem>\r
1024 <simpara>\r
1025 a colon.\r
1026 </simpara>\r
1027 </listitem>\r
1028 <listitem>\r
1029 <simpara>\r
1030 mode for "src"; 000000 if creation or unmerged.\r
1031 </simpara>\r
1032 </listitem>\r
1033 <listitem>\r
1034 <simpara>\r
1035 a space.\r
1036 </simpara>\r
1037 </listitem>\r
1038 <listitem>\r
1039 <simpara>\r
1040 mode for "dst"; 000000 if deletion or unmerged.\r
1041 </simpara>\r
1042 </listitem>\r
1043 <listitem>\r
1044 <simpara>\r
1045 a space.\r
1046 </simpara>\r
1047 </listitem>\r
1048 <listitem>\r
1049 <simpara>\r
1050 sha1 for "src"; 0{40} if creation or unmerged.\r
1051 </simpara>\r
1052 </listitem>\r
1053 <listitem>\r
1054 <simpara>\r
1055 a space.\r
1056 </simpara>\r
1057 </listitem>\r
1058 <listitem>\r
1059 <simpara>\r
1060 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".\r
1061 </simpara>\r
1062 </listitem>\r
1063 <listitem>\r
1064 <simpara>\r
1065 a space.\r
1066 </simpara>\r
1067 </listitem>\r
1068 <listitem>\r
1069 <simpara>\r
1070 status, followed by optional "score" number.\r
1071 </simpara>\r
1072 </listitem>\r
1073 <listitem>\r
1074 <simpara>\r
1075 a tab or a NUL when <emphasis>-z</emphasis> option is used.\r
1076 </simpara>\r
1077 </listitem>\r
1078 <listitem>\r
1079 <simpara>\r
1080 path for "src"\r
1081 </simpara>\r
1082 </listitem>\r
1083 <listitem>\r
1084 <simpara>\r
1085 a tab or a NUL when <emphasis>-z</emphasis> option is used; only exists for C or R.\r
1086 </simpara>\r
1087 </listitem>\r
1088 <listitem>\r
1089 <simpara>\r
1090 path for "dst"; only exists for C or R.\r
1091 </simpara>\r
1092 </listitem>\r
1093 <listitem>\r
1094 <simpara>\r
1095 an LF or a NUL when <emphasis>-z</emphasis> option is used, to terminate the record.\r
1096 </simpara>\r
1097 </listitem>\r
1098 </orderedlist>\r
1099 <simpara>Possible status letters are:</simpara>\r
1100 <itemizedlist>\r
1101 <listitem>\r
1102 <simpara>\r
1103 A: addition of a file\r
1104 </simpara>\r
1105 </listitem>\r
1106 <listitem>\r
1107 <simpara>\r
1108 C: copy of a file into a new one\r
1109 </simpara>\r
1110 </listitem>\r
1111 <listitem>\r
1112 <simpara>\r
1113 D: deletion of a file\r
1114 </simpara>\r
1115 </listitem>\r
1116 <listitem>\r
1117 <simpara>\r
1118 M: modification of the contents or mode of a file\r
1119 </simpara>\r
1120 </listitem>\r
1121 <listitem>\r
1122 <simpara>\r
1123 R: renaming of a file\r
1124 </simpara>\r
1125 </listitem>\r
1126 <listitem>\r
1127 <simpara>\r
1128 T: change in the type of the file\r
1129 </simpara>\r
1130 </listitem>\r
1131 <listitem>\r
1132 <simpara>\r
1133 U: file is unmerged (you must complete the merge before it can\r
1134 be committed)\r
1135 </simpara>\r
1136 </listitem>\r
1137 <listitem>\r
1138 <simpara>\r
1139 X: "unknown" change type (most probably a bug, please report it)\r
1140 </simpara>\r
1141 </listitem>\r
1142 </itemizedlist>\r
1143 <simpara>Status letters C and R are always followed by a score (denoting the\r
1144 percentage of similarity between the source and target of the move or\r
1145 copy), and are the only ones to be so.</simpara>\r
1146 <simpara>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem\r
1147 and it is out of sync with the index.</simpara>\r
1148 <simpara>Example:</simpara>\r
1149 <screen>:100644 100644 5be4a4...... 000000...... M file.c</screen>\r
1150 <simpara>When <emphasis>-z</emphasis> option is not used, TAB, LF, and backslash characters\r
1151 in pathnames are represented as <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, and <emphasis>\\</emphasis>,\r
1152 respectively.</simpara>\r
1153 </simplesect>\r
1154 <simplesect id="git-diff-index(1)__diff_format_for_merges">\r
1155 <title>diff format for merges</title>\r
1156 <simpara>"git-diff-tree", "git-diff-files" and "git-diff --raw"\r
1157 can take <emphasis>-c</emphasis> or <emphasis>--cc</emphasis> option\r
1158 to generate diff output also for merge commits.  The output differs\r
1159 from the format described above in the following way:</simpara>\r
1160 <orderedlist numeration="arabic">\r
1161 <listitem>\r
1162 <simpara>\r
1163 there is a colon for each parent\r
1164 </simpara>\r
1165 </listitem>\r
1166 <listitem>\r
1167 <simpara>\r
1168 there are more "src" modes and "src" sha1\r
1169 </simpara>\r
1170 </listitem>\r
1171 <listitem>\r
1172 <simpara>\r
1173 status is concatenated status characters for each parent\r
1174 </simpara>\r
1175 </listitem>\r
1176 <listitem>\r
1177 <simpara>\r
1178 no optional "score" number\r
1179 </simpara>\r
1180 </listitem>\r
1181 <listitem>\r
1182 <simpara>\r
1183 single path, only for "dst"\r
1184 </simpara>\r
1185 </listitem>\r
1186 </orderedlist>\r
1187 <simpara>Example:</simpara>\r
1188 <screen>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM      describe.c</screen>\r
1189 <simpara>Note that <emphasis>combined diff</emphasis> lists only files which were modified from\r
1190 all parents.</simpara>\r
1191 </simplesect>\r
1192 <simplesect id="git-diff-index(1)__generating_patches_with_p">\r
1193 <title>Generating patches with -p</title>\r
1194 <simpara>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run\r
1195 with a <emphasis>-p</emphasis> option, "git diff" without the <emphasis>--raw</emphasis> option, or\r
1196 "git log" with the "-p" option, they\r
1197 do not produce the output described above; instead they produce a\r
1198 patch file.  You can customize the creation of such patches via the\r
1199 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</simpara>\r
1200 <simpara>What the -p option produces is slightly different from the traditional\r
1201 diff format:</simpara>\r
1202 <orderedlist numeration="arabic">\r
1203 <listitem>\r
1204 <simpara>\r
1205 It is preceded with a "git diff" header that looks like this:\r
1206 </simpara>\r
1207 <literallayout class="monospaced">diff --git a/file1 b/file2</literallayout>\r
1208 <simpara>The <emphasis>a/</emphasis> and <emphasis>b/</emphasis> filenames are the same unless rename/copy is\r
1209 involved.  Especially, even for a creation or a deletion,\r
1210 <emphasis>/dev/null</emphasis> is <emphasis>not</emphasis> used in place of the <emphasis>a/</emphasis> or <emphasis>b/</emphasis> filenames.</simpara>\r
1211 <simpara>When rename/copy is involved, <emphasis>file1</emphasis> and <emphasis>file2</emphasis> show the\r
1212 name of the source file of the rename/copy and the name of\r
1213 the file that rename/copy produces, respectively.</simpara>\r
1214 </listitem>\r
1215 <listitem>\r
1216 <simpara>\r
1217 It is followed by one or more extended header lines:\r
1218 </simpara>\r
1219 <literallayout class="monospaced">old mode &lt;mode&gt;\r
1220 new mode &lt;mode&gt;\r
1221 deleted file mode &lt;mode&gt;\r
1222 new file mode &lt;mode&gt;\r
1223 copy from &lt;path&gt;\r
1224 copy to &lt;path&gt;\r
1225 rename from &lt;path&gt;\r
1226 rename to &lt;path&gt;\r
1227 similarity index &lt;number&gt;\r
1228 dissimilarity index &lt;number&gt;\r
1229 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</literallayout>\r
1230 <simpara>File modes are printed as 6-digit octal numbers including the file type\r
1231 and file permission bits.</simpara>\r
1232 <simpara>Path names in extended headers do not include the <emphasis>a/</emphasis> and <emphasis>b/</emphasis> prefixes.</simpara>\r
1233 <simpara>The similarity index is the percentage of unchanged lines, and\r
1234 the dissimilarity index is the percentage of changed lines.  It\r
1235 is a rounded down integer, followed by a percent sign.  The\r
1236 similarity index value of 100% is thus reserved for two equal\r
1237 files, while 100% dissimilarity means that no line from the old\r
1238 file made it into the new one.</simpara>\r
1239 <simpara>The index line includes the SHA-1 checksum before and after the change.\r
1240 The &lt;mode&gt; is included if the file mode does not change; otherwise,\r
1241 separate lines indicate the old and the new mode.</simpara>\r
1242 </listitem>\r
1243 <listitem>\r
1244 <simpara>\r
1245 TAB, LF, double quote and backslash characters in pathnames\r
1246     are represented as <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, <emphasis>\"</emphasis> and <emphasis>\\</emphasis>, respectively.\r
1247     If there is need for such substitution then the whole\r
1248     pathname is put in double quotes.\r
1249 </simpara>\r
1250 </listitem>\r
1251 <listitem>\r
1252 <simpara>\r
1253 All the <emphasis>file1</emphasis> files in the output refer to files before the\r
1254     commit, and all the <emphasis>file2</emphasis> files refer to files after the commit.\r
1255     It is incorrect to apply each change to each file sequentially.  For\r
1256     example, this patch will swap a and b:\r
1257 </simpara>\r
1258 <literallayout class="monospaced">diff --git a/a b/b\r
1259 rename from a\r
1260 rename to b\r
1261 diff --git a/b b/a\r
1262 rename from b\r
1263 rename to a</literallayout>\r
1264 </listitem>\r
1265 </orderedlist>\r
1266 </simplesect>\r
1267 <simplesect id="git-diff-index(1)__combined_diff_format">\r
1268 <title>combined diff format</title>\r
1269 <simpara>Any diff-generating command can take the -c` or <emphasis>--cc</emphasis> option to\r
1270 produce a <emphasis>combined diff</emphasis> when showing a merge. This is the default\r
1271 format when showing merges with <xref linkend="git-diff(1)" /> or\r
1272 <xref linkend="git-show(1)" />. Note also that you can give the `-m option to any\r
1273 of these commands to force generation of diffs with individual parents\r
1274 of a merge.</simpara>\r
1275 <simpara>A <emphasis>combined diff</emphasis> format looks like this:</simpara>\r
1276 <screen>diff --combined describe.c\r
1277 index fabadb8,cc95eb0..4866510\r
1278 --- a/describe.c\r
1279 +++ b/describe.c\r
1280 @@@ -98,20 -98,12 +98,20 @@@\r
1281         return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;\r
1282   }\r
1284 - static void describe(char *arg)\r
1285  -static void describe(struct commit *cmit, int last_one)\r
1286 ++static void describe(char *arg, int last_one)\r
1287   {\r
1288  +      unsigned char sha1[20];\r
1289  +      struct commit *cmit;\r
1290         struct commit_list *list;\r
1291         static int initialized = 0;\r
1292         struct commit_name *n;\r
1294  +      if (get_sha1(arg, sha1) &lt; 0)\r
1295  +              usage(describe_usage);\r
1296  +      cmit = lookup_commit_reference(sha1);\r
1297  +      if (!cmit)\r
1298  +              usage(describe_usage);\r
1299  +\r
1300         if (!initialized) {\r
1301                 initialized = 1;\r
1302                 for_each_ref(get_name);</screen>\r
1303 <orderedlist numeration="arabic">\r
1304 <listitem>\r
1305 <simpara>\r
1306 It is preceded with a "git diff" header, that looks like\r
1307      this (when <emphasis>-c</emphasis> option is used):\r
1308 </simpara>\r
1309 <literallayout class="monospaced">diff --combined file</literallayout>\r
1310 <simpara>or like this (when <emphasis>--cc</emphasis> option is used):</simpara>\r
1311 <literallayout class="monospaced">diff --cc file</literallayout>\r
1312 </listitem>\r
1313 <listitem>\r
1314 <simpara>\r
1315 It is followed by one or more extended header lines\r
1316      (this example shows a merge with two parents):\r
1317 </simpara>\r
1318 <literallayout class="monospaced">index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;\r
1319 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;\r
1320 new file mode &lt;mode&gt;\r
1321 deleted file mode &lt;mode&gt;,&lt;mode&gt;</literallayout>\r
1322 <simpara>The <emphasis>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</emphasis> line appears only if at least one of\r
1323 the &lt;mode&gt; is different from the rest. Extended headers with\r
1324 information about detected contents movement (renames and\r
1325 copying detection) are designed to work with diff of two\r
1326 &lt;tree-ish&gt; and are not used by combined diff format.</simpara>\r
1327 </listitem>\r
1328 <listitem>\r
1329 <simpara>\r
1330 It is followed by two-line from-file/to-file header\r
1331 </simpara>\r
1332 <literallayout class="monospaced">--- a/file\r
1333 +++ b/file</literallayout>\r
1334 <simpara>Similar to two-line header for traditional <emphasis>unified</emphasis> diff\r
1335 format, <emphasis>/dev/null</emphasis> is used to signal created or deleted\r
1336 files.</simpara>\r
1337 </listitem>\r
1338 <listitem>\r
1339 <simpara>\r
1340 Chunk header format is modified to prevent people from\r
1341      accidentally feeding it to <emphasis>patch -p1</emphasis>. Combined diff format\r
1342      was created for review of merge commit changes, and was not\r
1343      meant for apply. The change is similar to the change in the\r
1344      extended <emphasis>index</emphasis> header:\r
1345 </simpara>\r
1346 <literallayout class="monospaced">@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</literallayout>\r
1347 <simpara>There are (number of parents + 1) <emphasis>@</emphasis> characters in the chunk\r
1348 header for combined diff format.</simpara>\r
1349 </listitem>\r
1350 </orderedlist>\r
1351 <simpara>Unlike the traditional <emphasis>unified</emphasis> diff format, which shows two\r
1352 files A and B with a single column that has <emphasis>-</emphasis> (minus --\r
1353 appears in A but removed in B), <emphasis>+</emphasis> (plus -- missing in A but\r
1354 added to B), or <emphasis>" "</emphasis> (space -- unchanged) prefix, this format\r
1355 compares two or more files file1, file2,&#8230; with one file X, and\r
1356 shows how X differs from each of fileN.  One column for each of\r
1357 fileN is prepended to the output line to note how X's line is\r
1358 different from it.</simpara>\r
1359 <simpara>A <emphasis>-</emphasis> character in the column N means that the line appears in\r
1360 fileN but it does not appear in the result.  A <emphasis>+</emphasis> character\r
1361 in the column N means that the line appears in the result,\r
1362 and fileN does not have that line (in other words, the line was\r
1363 added, from the point of view of that parent).</simpara>\r
1364 <simpara>In the above example output, the function signature was changed\r
1365 from both files (hence two <emphasis>-</emphasis> removals from both file1 and\r
1366 file2, plus <emphasis>++</emphasis> to mean one line that was added does not appear\r
1367 in either file1 nor file2).  Also eight other lines are the same\r
1368 from file1 but do not appear in file2 (hence prefixed with <emphasis>+</emphasis>).</simpara>\r
1369 <simpara>When shown by <emphasis>git diff-tree -c</emphasis>, it compares the parents of a\r
1370 merge commit with the merge result (i.e. file1..fileN are the\r
1371 parents).  When shown by <emphasis>git diff-files -c</emphasis>, it compares the\r
1372 two unresolved merge parents with the working tree file\r
1373 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka\r
1374 "their version").</simpara>\r
1375 </simplesect>\r
1376 <simplesect id="git-diff-index(1)__other_diff_formats">\r
1377 <title>other diff formats</title>\r
1378 <simpara>The <emphasis>--summary</emphasis> option describes newly added, deleted, renamed and\r
1379 copied files.  The <emphasis>--stat</emphasis> option adds diffstat(1) graph to the\r
1380 output.  These options can be combined with other options, such as\r
1381 <emphasis>-p</emphasis>, and are meant for human consumption.</simpara>\r
1382 <simpara>When showing a change that involves a rename or a copy, <emphasis>--stat</emphasis> output\r
1383 formats the pathnames compactly by combining common prefix and suffix of\r
1384 the pathnames.  For example, a change that moves <emphasis>arch/i386/Makefile</emphasis> to\r
1385 <emphasis>arch/x86/Makefile</emphasis> while modifying 4 lines will be shown like this:</simpara>\r
1386 <screen>arch/{i386 =&gt; x86}/Makefile    |   4 +--</screen>\r
1387 <simpara>The <emphasis>--numstat</emphasis> option gives the diffstat(1) information but is designed\r
1388 for easier machine consumption.  An entry in <emphasis>--numstat</emphasis> output looks\r
1389 like this:</simpara>\r
1390 <screen>1       2       README\r
1391 3       1       arch/{i386 =&gt; x86}/Makefile</screen>\r
1392 <simpara>That is, from left to right:</simpara>\r
1393 <orderedlist numeration="arabic">\r
1394 <listitem>\r
1395 <simpara>\r
1396 the number of added lines;\r
1397 </simpara>\r
1398 </listitem>\r
1399 <listitem>\r
1400 <simpara>\r
1401 a tab;\r
1402 </simpara>\r
1403 </listitem>\r
1404 <listitem>\r
1405 <simpara>\r
1406 the number of deleted lines;\r
1407 </simpara>\r
1408 </listitem>\r
1409 <listitem>\r
1410 <simpara>\r
1411 a tab;\r
1412 </simpara>\r
1413 </listitem>\r
1414 <listitem>\r
1415 <simpara>\r
1416 pathname (possibly with rename/copy information);\r
1417 </simpara>\r
1418 </listitem>\r
1419 <listitem>\r
1420 <simpara>\r
1421 a newline.\r
1422 </simpara>\r
1423 </listitem>\r
1424 </orderedlist>\r
1425 <simpara>When <emphasis>-z</emphasis> output option is in effect, the output is formatted this way:</simpara>\r
1426 <screen>1       2       README NUL\r
1427 3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</screen>\r
1428 <simpara>That is:</simpara>\r
1429 <orderedlist numeration="arabic">\r
1430 <listitem>\r
1431 <simpara>\r
1432 the number of added lines;\r
1433 </simpara>\r
1434 </listitem>\r
1435 <listitem>\r
1436 <simpara>\r
1437 a tab;\r
1438 </simpara>\r
1439 </listitem>\r
1440 <listitem>\r
1441 <simpara>\r
1442 the number of deleted lines;\r
1443 </simpara>\r
1444 </listitem>\r
1445 <listitem>\r
1446 <simpara>\r
1447 a tab;\r
1448 </simpara>\r
1449 </listitem>\r
1450 <listitem>\r
1451 <simpara>\r
1452 a NUL (only exists if renamed/copied);\r
1453 </simpara>\r
1454 </listitem>\r
1455 <listitem>\r
1456 <simpara>\r
1457 pathname in preimage;\r
1458 </simpara>\r
1459 </listitem>\r
1460 <listitem>\r
1461 <simpara>\r
1462 a NUL (only exists if renamed/copied);\r
1463 </simpara>\r
1464 </listitem>\r
1465 <listitem>\r
1466 <simpara>\r
1467 pathname in postimage (only exists if renamed/copied);\r
1468 </simpara>\r
1469 </listitem>\r
1470 <listitem>\r
1471 <simpara>\r
1472 a NUL.\r
1473 </simpara>\r
1474 </listitem>\r
1475 </orderedlist>\r
1476 <simpara>The extra <emphasis>NUL</emphasis> before the preimage path in renamed case is to allow\r
1477 scripts that read the output to tell if the current record being read is\r
1478 a single-path record or a rename/copy record without reading ahead.\r
1479 After reading added and deleted lines, reading up to <emphasis>NUL</emphasis> would yield\r
1480 the pathname, but if that is <emphasis>NUL</emphasis>, the record will show two paths.</simpara>\r
1481 </simplesect>\r
1482 <simplesect id="git-diff-index(1)__operating_modes">\r
1483 <title>Operating Modes</title>\r
1484 <simpara>You can choose whether you want to trust the index file entirely\r
1485 (using the <emphasis>--cached</emphasis> flag) or ask the diff logic to show any files\r
1486 that don't match the stat state as being "tentatively changed".  Both\r
1487 of these operations are very useful indeed.</simpara>\r
1488 </simplesect>\r
1489 <simplesect id="git-diff-index(1)__cached_mode">\r
1490 <title>Cached Mode</title>\r
1491 <simpara>If <emphasis>--cached</emphasis> is specified, it allows you to ask:</simpara>\r
1492 <literallayout class="monospaced">show me the differences between HEAD and the current index\r
1493 contents (the ones I'd write using 'git write-tree')</literallayout>\r
1494 <simpara>For example, let's say that you have worked on your working directory, updated\r
1495 some files in the index and are ready to commit. You want to see exactly\r
1496 <emphasis role="strong">what</emphasis> you are going to commit, without having to write a new tree\r
1497 object and compare it that way, and to do that, you just do</simpara>\r
1498 <literallayout class="monospaced">git diff-index --cached HEAD</literallayout>\r
1499 <simpara>Example: let's say I had renamed <emphasis>commit.c</emphasis> to <emphasis>git-commit.c</emphasis>, and I had\r
1500 done an <emphasis>update-index</emphasis> to make that effective in the index file.\r
1501 <emphasis>git diff-files</emphasis> wouldn't show anything at all, since the index file\r
1502 matches my working directory. But doing a <emphasis>git diff-index</emphasis> does:</simpara>\r
1503 <literallayout class="monospaced">torvalds@ppc970:~/git&gt; git diff-index --cached HEAD\r
1504 -100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c\r
1505 +100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c</literallayout>\r
1506 <simpara>You can see easily that the above is a rename.</simpara>\r
1507 <simpara>In fact, <emphasis>git diff-index --cached</emphasis> <emphasis role="strong">should</emphasis> always be entirely equivalent to\r
1508 actually doing a <emphasis>git write-tree</emphasis> and comparing that. Except this one is much\r
1509 nicer for the case where you just want to check where you are.</simpara>\r
1510 <simpara>So doing a <emphasis>git diff-index --cached</emphasis> is basically very useful when you are\r
1511 asking yourself "what have I already marked for being committed, and\r
1512 what's the difference to a previous tree".</simpara>\r
1513 </simplesect>\r
1514 <simplesect id="git-diff-index(1)__non_cached_mode">\r
1515 <title>Non-cached Mode</title>\r
1516 <simpara>The "non-cached" mode takes a different approach, and is potentially\r
1517 the more useful of the two in that what it does can't be emulated with\r
1518 a <emphasis>git write-tree</emphasis> + <emphasis>git diff-tree</emphasis>. Thus that's the default mode.\r
1519 The non-cached version asks the question:</simpara>\r
1520 <literallayout class="monospaced">show me the differences between HEAD and the currently checked out\r
1521 tree - index contents _and_ files that aren't up-to-date</literallayout>\r
1522 <simpara>which is obviously a very useful question too, since that tells you what\r
1523 you <emphasis role="strong">could</emphasis> commit. Again, the output matches the <emphasis>git diff-tree -r</emphasis>\r
1524 output to a tee, but with a twist.</simpara>\r
1525 <simpara>The twist is that if some file doesn't match the index, we don't have\r
1526 a backing store thing for it, and we use the magic "all-zero" sha1 to\r
1527 show that. So let's say that you have edited <emphasis>kernel/sched.c</emphasis>, but\r
1528 have not actually done a <emphasis>git update-index</emphasis> on it yet - there is no\r
1529 "object" associated with the new state, and you get:</simpara>\r
1530 <literallayout class="monospaced">torvalds@ppc970:~/v2.6/linux&gt; git diff-index --abbrev HEAD\r
1531 :100644 100664 7476bb... 000000...      kernel/sched.c</literallayout>\r
1532 <simpara>i.e., it shows that the tree has changed, and that <emphasis>kernel/sched.c</emphasis> has is\r
1533 not up-to-date and may contain new stuff. The all-zero sha1 means that to\r
1534 get the real diff, you need to look at the object in the working directory\r
1535 directly rather than do an object-to-object diff.</simpara>\r
1536 <note><simpara>As with other commands of this type, <emphasis>git diff-index</emphasis> does not\r
1537 actually look at the contents of the file at all. So maybe\r
1538 <emphasis>kernel/sched.c</emphasis> hasn't actually changed, and it's just that you\r
1539 touched it. In either case, it's a note that you need to\r
1540 <emphasis>git update-index</emphasis> it to make the index be in sync.</simpara></note>\r
1541 <note><simpara>You can have a mixture of files show up as "has been updated"\r
1542 and "is still dirty in the working directory" together. You can always\r
1543 tell which file is in which state, since the "has been updated" ones\r
1544 show a valid sha1, and the "not in sync with the index" ones will\r
1545 always have the special all-zero sha1.</simpara></note>\r
1546 </simplesect>\r
1547 <simplesect id="git-diff-index(1)__git">\r
1548 <title>GIT</title>\r
1549 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
1550 </simplesect>\r
1551 </sect2>\r