updated git doc
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / git-diff-files.xml
blob4b859940c6da5fe8555db22bd228da96f286a632
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <article lang="en" id="git-diff-files(1)">\r
5 <articleinfo>\r
6     <title>git-diff-files(1)</title>\r
7 <indexterm>\r
8 <primary>git-diff-files(1)</primary>\r
9 </indexterm>\r
10 </articleinfo>\r
11 <simplesect id="_name">\r
12 <title>NAME</title>\r
13 <simpara>git-diff-files - Compares files in the working tree and the index</simpara>\r
14 </simplesect>\r
15 <simplesect id="_synopsis">\r
16 <title>SYNOPSIS</title>\r
17 <blockquote>\r
18 <literallayout><emphasis>git diff-files</emphasis> [-q] [-0|-1|-2|-3|-c|--cc] [&lt;common diff options&gt;] [&lt;path&gt;&#8230;]</literallayout>\r
19 </blockquote>\r
20 </simplesect>\r
21 <simplesect id="_description">\r
22 <title>DESCRIPTION</title>\r
23 <simpara>Compares the files in the working tree and the index.  When paths\r
24 are specified, compares only those named paths.  Otherwise all\r
25 entries in the index are compared.  The output format is the\r
26 same as for <emphasis>git diff-index</emphasis> and <emphasis>git diff-tree</emphasis>.</simpara>\r
27 </simplesect>\r
28 <simplesect id="_options">\r
29 <title>OPTIONS</title>\r
30 <variablelist>\r
31 <varlistentry>\r
32 <term>\r
33 -p\r
34 </term>\r
35 <term>\r
36 -u\r
37 </term>\r
38 <term>\r
39 --patch\r
40 </term>\r
41 <listitem>\r
42 <simpara>\r
43         Generate patch (see section on generating patches).\r
44         \r
45 </simpara>\r
46 </listitem>\r
47 </varlistentry>\r
48 <varlistentry>\r
49 <term>\r
50 -U&lt;n&gt;\r
51 </term>\r
52 <term>\r
53 --unified=&lt;n&gt;\r
54 </term>\r
55 <listitem>\r
56 <simpara>\r
57         Generate diffs with &lt;n&gt; lines of context instead of\r
58         the usual three.\r
59         Implies <emphasis>-p</emphasis>.\r
60 </simpara>\r
61 </listitem>\r
62 </varlistentry>\r
63 <varlistentry>\r
64 <term>\r
65 --raw\r
66 </term>\r
67 <listitem>\r
68 <simpara>\r
69         Generate the raw format.\r
70          This is the default.\r
71 </simpara>\r
72 </listitem>\r
73 </varlistentry>\r
74 <varlistentry>\r
75 <term>\r
76 --patch-with-raw\r
77 </term>\r
78 <listitem>\r
79 <simpara>\r
80         Synonym for <emphasis>-p --raw</emphasis>.\r
81 </simpara>\r
82 </listitem>\r
83 </varlistentry>\r
84 <varlistentry>\r
85 <term>\r
86 --minimal\r
87 </term>\r
88 <listitem>\r
89 <simpara>\r
90         Spend extra time to make sure the smallest possible\r
91         diff is produced.\r
92 </simpara>\r
93 </listitem>\r
94 </varlistentry>\r
95 <varlistentry>\r
96 <term>\r
97 --patience\r
98 </term>\r
99 <listitem>\r
100 <simpara>\r
101         Generate a diff using the "patience diff" algorithm.\r
102 </simpara>\r
103 </listitem>\r
104 </varlistentry>\r
105 <varlistentry>\r
106 <term>\r
107 --histogram\r
108 </term>\r
109 <listitem>\r
110 <simpara>\r
111         Generate a diff using the "histogram diff" algorithm.\r
112 </simpara>\r
113 </listitem>\r
114 </varlistentry>\r
115 <varlistentry>\r
116 <term>\r
117 --stat[=&lt;width&gt;[,&lt;name-width&gt;[,&lt;count&gt;]]]\r
118 </term>\r
119 <listitem>\r
120 <simpara>\r
121         Generate a diffstat. By default, as much space as necessary\r
122         will be used for the filename part, and the rest for the graph\r
123         part. Maximum width defaults to terminal width, or 80 columns\r
124         if not connected to a terminal, and can be overriden by\r
125         <emphasis>&lt;width&gt;</emphasis>. The width of the filename part can be limited by\r
126         giving another width <emphasis>&lt;name-width&gt;</emphasis> after a comma. The width\r
127         of the graph part can be limited by using\r
128         <emphasis>--stat-graph-width=&lt;width&gt;</emphasis> (affects all commands generating\r
129         a stat graph) or by setting <emphasis>diff.statGraphWidth=&lt;width&gt;</emphasis>\r
130         (does not affect <emphasis>git format-patch</emphasis>).\r
131         By giving a third parameter <emphasis>&lt;count&gt;</emphasis>, you can limit the\r
132         output to the first <emphasis>&lt;count&gt;</emphasis> lines, followed by <emphasis>...</emphasis> if\r
133         there are more.\r
134 </simpara>\r
135 <simpara>These parameters can also be set individually with <emphasis>--stat-width=&lt;width&gt;</emphasis>,\r
136 <emphasis>--stat-name-width=&lt;name-width&gt;</emphasis> and <emphasis>--stat-count=&lt;count&gt;</emphasis>.</simpara>\r
137 </listitem>\r
138 </varlistentry>\r
139 <varlistentry>\r
140 <term>\r
141 --numstat\r
142 </term>\r
143 <listitem>\r
144 <simpara>\r
145         Similar to <emphasis>--stat</emphasis>, but shows number of added and\r
146         deleted lines in decimal notation and pathname without\r
147         abbreviation, to make it more machine friendly.  For\r
148         binary files, outputs two <emphasis>-</emphasis> instead of saying\r
149         <emphasis>0 0</emphasis>.\r
150 </simpara>\r
151 </listitem>\r
152 </varlistentry>\r
153 <varlistentry>\r
154 <term>\r
155 --shortstat\r
156 </term>\r
157 <listitem>\r
158 <simpara>\r
159         Output only the last line of the <emphasis>--stat</emphasis> format containing total\r
160         number of modified files, as well as number of added and deleted\r
161         lines.\r
162 </simpara>\r
163 </listitem>\r
164 </varlistentry>\r
165 <varlistentry>\r
166 <term>\r
167 --dirstat[=&lt;param1,param2,&#8230;&gt;]\r
168 </term>\r
169 <listitem>\r
170 <simpara>\r
171         Output the distribution of relative amount of changes for each\r
172         sub-directory. The behavior of <emphasis>--dirstat</emphasis> can be customized by\r
173         passing it a comma separated list of parameters.\r
174         The defaults are controlled by the <emphasis>diff.dirstat</emphasis> configuration\r
175         variable (see <xref linkend="git-config(1)" />).\r
176         The following parameters are available:\r
177 </simpara>\r
178 <variablelist>\r
179 <varlistentry>\r
180 <term>\r
181 <emphasis>changes</emphasis>\r
182 </term>\r
183 <listitem>\r
184 <simpara>\r
185         Compute the dirstat numbers by counting the lines that have been\r
186         removed from the source, or added to the destination. This ignores\r
187         the amount of pure code movements within a file.  In other words,\r
188         rearranging lines in a file is not counted as much as other changes.\r
189         This is the default behavior when no parameter is given.\r
190 </simpara>\r
191 </listitem>\r
192 </varlistentry>\r
193 <varlistentry>\r
194 <term>\r
195 <emphasis>lines</emphasis>\r
196 </term>\r
197 <listitem>\r
198 <simpara>\r
199         Compute the dirstat numbers by doing the regular line-based diff\r
200         analysis, and summing the removed/added line counts. (For binary\r
201         files, count 64-byte chunks instead, since binary files have no\r
202         natural concept of lines). This is a more expensive <emphasis>--dirstat</emphasis>\r
203         behavior than the <emphasis>changes</emphasis> behavior, but it does count rearranged\r
204         lines within a file as much as other changes. The resulting output\r
205         is consistent with what you get from the other <emphasis>--*stat</emphasis> options.\r
206 </simpara>\r
207 </listitem>\r
208 </varlistentry>\r
209 <varlistentry>\r
210 <term>\r
211 <emphasis>files</emphasis>\r
212 </term>\r
213 <listitem>\r
214 <simpara>\r
215         Compute the dirstat numbers by counting the number of files changed.\r
216         Each changed file counts equally in the dirstat analysis. This is\r
217         the computationally cheapest <emphasis>--dirstat</emphasis> behavior, since it does\r
218         not have to look at the file contents at all.\r
219 </simpara>\r
220 </listitem>\r
221 </varlistentry>\r
222 <varlistentry>\r
223 <term>\r
224 <emphasis>cumulative</emphasis>\r
225 </term>\r
226 <listitem>\r
227 <simpara>\r
228         Count changes in a child directory for the parent directory as well.\r
229         Note that when using <emphasis>cumulative</emphasis>, the sum of the percentages\r
230         reported may exceed 100%. The default (non-cumulative) behavior can\r
231         be specified with the <emphasis>noncumulative</emphasis> parameter.\r
232 </simpara>\r
233 </listitem>\r
234 </varlistentry>\r
235 <varlistentry>\r
236 <term>\r
237 &lt;limit&gt;\r
238 </term>\r
239 <listitem>\r
240 <simpara>\r
241         An integer parameter specifies a cut-off percent (3% by default).\r
242         Directories contributing less than this percentage of the changes\r
243         are not shown in the output.\r
244 </simpara>\r
245 </listitem>\r
246 </varlistentry>\r
247 </variablelist>\r
248 <simpara>Example: The following will count changed files, while ignoring\r
249 directories with less than 10% of the total amount of changed files,\r
250 and accumulating child directory counts in the parent directories:\r
251 <emphasis>--dirstat=files,10,cumulative</emphasis>.</simpara>\r
252 </listitem>\r
253 </varlistentry>\r
254 <varlistentry>\r
255 <term>\r
256 --summary\r
257 </term>\r
258 <listitem>\r
259 <simpara>\r
260         Output a condensed summary of extended header information\r
261         such as creations, renames and mode changes.\r
262 </simpara>\r
263 </listitem>\r
264 </varlistentry>\r
265 <varlistentry>\r
266 <term>\r
267 --patch-with-stat\r
268 </term>\r
269 <listitem>\r
270 <simpara>\r
271         Synonym for <emphasis>-p --stat</emphasis>.\r
272 </simpara>\r
273 </listitem>\r
274 </varlistentry>\r
275 <varlistentry>\r
276 <term>\r
277 -z\r
278 </term>\r
279 <listitem>\r
280 <simpara>\r
281         When <emphasis>--raw</emphasis>, <emphasis>--numstat</emphasis>, <emphasis>--name-only</emphasis> or <emphasis>--name-status</emphasis> has been\r
282         given, do not munge pathnames and use NULs as output field terminators.\r
283 </simpara>\r
284 <simpara>Without this option, each pathname output will have TAB, LF, double quotes,\r
285 and backslash characters replaced with <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, <emphasis>\"</emphasis>, and <emphasis>\\</emphasis>,\r
286 respectively, and the pathname will be enclosed in double quotes if\r
287 any of those replacements occurred.</simpara>\r
288 </listitem>\r
289 </varlistentry>\r
290 <varlistentry>\r
291 <term>\r
292 --name-only\r
293 </term>\r
294 <listitem>\r
295 <simpara>\r
296         Show only names of changed files.\r
297 </simpara>\r
298 </listitem>\r
299 </varlistentry>\r
300 <varlistentry>\r
301 <term>\r
302 --name-status\r
303 </term>\r
304 <listitem>\r
305 <simpara>\r
306         Show only names and status of changed files. See the description\r
307         of the <emphasis>--diff-filter</emphasis> option on what the status letters mean.\r
308 </simpara>\r
309 </listitem>\r
310 </varlistentry>\r
311 <varlistentry>\r
312 <term>\r
313 --submodule[=&lt;format&gt;]\r
314 </term>\r
315 <listitem>\r
316 <simpara>\r
317         Specify how differences in submodules are shown.  When <emphasis>--submodule</emphasis>\r
318         or <emphasis>--submodule=log</emphasis> is given, the <emphasis>log</emphasis> format is used.  This format lists\r
319         the commits in the range like <xref linkend="git-submodule(1)" /> <emphasis>summary</emphasis> does.\r
320         Omitting the <emphasis>--submodule</emphasis> option or specifying <emphasis>--submodule=short</emphasis>,\r
321         uses the <emphasis>short</emphasis> format. This format just shows the names of the commits\r
322         at the beginning and end of the range.\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.\r
558 </simpara>\r
559 </listitem>\r
560 </varlistentry>\r
561 <varlistentry>\r
562 <term>\r
563 -C[&lt;n&gt;]\r
564 </term>\r
565 <term>\r
566 --find-copies[=&lt;n&gt;]\r
567 </term>\r
568 <listitem>\r
569 <simpara>\r
570         Detect copies as well as renames.  See also <emphasis>--find-copies-harder</emphasis>.\r
571         If <emphasis>n</emphasis> is specified, it has the same meaning as for <emphasis>-M&lt;n&gt;</emphasis>.\r
572 </simpara>\r
573 </listitem>\r
574 </varlistentry>\r
575 <varlistentry>\r
576 <term>\r
577 --find-copies-harder\r
578 </term>\r
579 <listitem>\r
580 <simpara>\r
581         For performance reasons, by default, <emphasis>-C</emphasis> option finds copies only\r
582         if the original file of the copy was modified in the same\r
583         changeset.  This flag makes the command\r
584         inspect unmodified files as candidates for the source of\r
585         copy.  This is a very expensive operation for large\r
586         projects, so use it with caution.  Giving more than one\r
587         <emphasis>-C</emphasis> option has the same effect.\r
588 </simpara>\r
589 </listitem>\r
590 </varlistentry>\r
591 <varlistentry>\r
592 <term>\r
593 -D\r
594 </term>\r
595 <term>\r
596 --irreversible-delete\r
597 </term>\r
598 <listitem>\r
599 <simpara>\r
600         Omit the preimage for deletes, i.e. print only the header but not\r
601         the diff between the preimage and <emphasis>/dev/null</emphasis>. The resulting patch\r
602         is not meant to be applied with <emphasis>patch</emphasis> nor <emphasis>git apply</emphasis>; this is\r
603         solely for people who want to just concentrate on reviewing the\r
604         text after the change. In addition, the output obviously lack\r
605         enough information to apply such a patch in reverse, even manually,\r
606         hence the name of the option.\r
607 </simpara>\r
608 <simpara>When used together with <emphasis>-B</emphasis>, omit also the preimage in the deletion part\r
609 of a delete/create pair.</simpara>\r
610 </listitem>\r
611 </varlistentry>\r
612 <varlistentry>\r
613 <term>\r
614 -l&lt;num&gt;\r
615 </term>\r
616 <listitem>\r
617 <simpara>\r
618         The <emphasis>-M</emphasis> and <emphasis>-C</emphasis> options require O(n^2) processing time where n\r
619         is the number of potential rename/copy targets.  This\r
620         option prevents rename/copy detection from running if\r
621         the number of rename/copy targets exceeds the specified\r
622         number.\r
623 </simpara>\r
624 </listitem>\r
625 </varlistentry>\r
626 <varlistentry>\r
627 <term>\r
628 --diff-filter=[(A|C|D|M|R|T|U|X|B)&#8230;[*]]\r
629 </term>\r
630 <listitem>\r
631 <simpara>\r
632         Select only files that are Added (<emphasis>A</emphasis>), Copied (<emphasis>C</emphasis>),\r
633         Deleted (<emphasis>D</emphasis>), Modified (<emphasis>M</emphasis>), Renamed (<emphasis>R</emphasis>), have their\r
634         type (i.e. regular file, symlink, submodule, &#8230;) changed (<emphasis>T</emphasis>),\r
635         are Unmerged (<emphasis>U</emphasis>), are\r
636         Unknown (<emphasis>X</emphasis>), or have had their pairing Broken (<emphasis>B</emphasis>).\r
637         Any combination of the filter characters (including none) can be used.\r
638         When <emphasis>*</emphasis> (All-or-none) is added to the combination, all\r
639         paths are selected if there is any file that matches\r
640         other criteria in the comparison; if there is no file\r
641         that matches other criteria, nothing is selected.\r
642 </simpara>\r
643 </listitem>\r
644 </varlistentry>\r
645 <varlistentry>\r
646 <term>\r
647 -S&lt;string&gt;\r
648 </term>\r
649 <listitem>\r
650 <simpara>\r
651         Look for differences that introduce or remove an instance of\r
652         &lt;string&gt;. Note that this is different than the string simply\r
653         appearing in diff output; see the <emphasis>pickaxe</emphasis> entry in\r
654         <xref linkend="gitdiffcore(7)" /> for more details.\r
655 </simpara>\r
656 </listitem>\r
657 </varlistentry>\r
658 <varlistentry>\r
659 <term>\r
660 -G&lt;regex&gt;\r
661 </term>\r
662 <listitem>\r
663 <simpara>\r
664         Look for differences whose added or removed line matches\r
665         the given &lt;regex&gt;.\r
666 </simpara>\r
667 </listitem>\r
668 </varlistentry>\r
669 <varlistentry>\r
670 <term>\r
671 --pickaxe-all\r
672 </term>\r
673 <listitem>\r
674 <simpara>\r
675         When <emphasis>-S</emphasis> or <emphasis>-G</emphasis> finds a change, show all the changes in that\r
676         changeset, not just the files that contain the change\r
677         in &lt;string&gt;.\r
678 </simpara>\r
679 </listitem>\r
680 </varlistentry>\r
681 <varlistentry>\r
682 <term>\r
683 --pickaxe-regex\r
684 </term>\r
685 <listitem>\r
686 <simpara>\r
687         Make the &lt;string&gt; not a plain string but an extended POSIX\r
688         regex to match.\r
689 </simpara>\r
690 </listitem>\r
691 </varlistentry>\r
692 <varlistentry>\r
693 <term>\r
694 -O&lt;orderfile&gt;\r
695 </term>\r
696 <listitem>\r
697 <simpara>\r
698         Output the patch in the order specified in the\r
699         &lt;orderfile&gt;, which has one shell glob pattern per line.\r
700 </simpara>\r
701 </listitem>\r
702 </varlistentry>\r
703 <varlistentry>\r
704 <term>\r
705 -R\r
706 </term>\r
707 <listitem>\r
708 <simpara>\r
709         Swap two inputs; that is, show differences from index or\r
710         on-disk file to tree contents.\r
711 </simpara>\r
712 </listitem>\r
713 </varlistentry>\r
714 <varlistentry>\r
715 <term>\r
716 --relative[=&lt;path&gt;]\r
717 </term>\r
718 <listitem>\r
719 <simpara>\r
720         When run from a subdirectory of the project, it can be\r
721         told to exclude changes outside the directory and show\r
722         pathnames relative to it with this option.  When you are\r
723         not in a subdirectory (e.g. in a bare repository), you\r
724         can name which subdirectory to make the output relative\r
725         to by giving a &lt;path&gt; as an argument.\r
726 </simpara>\r
727 </listitem>\r
728 </varlistentry>\r
729 <varlistentry>\r
730 <term>\r
731 -a\r
732 </term>\r
733 <term>\r
734 --text\r
735 </term>\r
736 <listitem>\r
737 <simpara>\r
738         Treat all files as text.\r
739 </simpara>\r
740 </listitem>\r
741 </varlistentry>\r
742 <varlistentry>\r
743 <term>\r
744 --ignore-space-at-eol\r
745 </term>\r
746 <listitem>\r
747 <simpara>\r
748         Ignore changes in whitespace at EOL.\r
749 </simpara>\r
750 </listitem>\r
751 </varlistentry>\r
752 <varlistentry>\r
753 <term>\r
754 -b\r
755 </term>\r
756 <term>\r
757 --ignore-space-change\r
758 </term>\r
759 <listitem>\r
760 <simpara>\r
761         Ignore changes in amount of whitespace.  This ignores whitespace\r
762         at line end, and considers all other sequences of one or\r
763         more whitespace characters to be equivalent.\r
764 </simpara>\r
765 </listitem>\r
766 </varlistentry>\r
767 <varlistentry>\r
768 <term>\r
769 -w\r
770 </term>\r
771 <term>\r
772 --ignore-all-space\r
773 </term>\r
774 <listitem>\r
775 <simpara>\r
776         Ignore whitespace when comparing lines.  This ignores\r
777         differences even if one line has whitespace where the other\r
778         line has none.\r
779 </simpara>\r
780 </listitem>\r
781 </varlistentry>\r
782 <varlistentry>\r
783 <term>\r
784 --inter-hunk-context=&lt;lines&gt;\r
785 </term>\r
786 <listitem>\r
787 <simpara>\r
788         Show the context between diff hunks, up to the specified number\r
789         of lines, thereby fusing hunks that are close to each other.\r
790 </simpara>\r
791 </listitem>\r
792 </varlistentry>\r
793 <varlistentry>\r
794 <term>\r
795 -W\r
796 </term>\r
797 <term>\r
798 --function-context\r
799 </term>\r
800 <listitem>\r
801 <simpara>\r
802         Show whole surrounding functions of changes.\r
803 </simpara>\r
804 </listitem>\r
805 </varlistentry>\r
806 <varlistentry>\r
807 <term>\r
808 --exit-code\r
809 </term>\r
810 <listitem>\r
811 <simpara>\r
812         Make the program exit with codes similar to diff(1).\r
813         That is, it exits with 1 if there were differences and\r
814         0 means no differences.\r
815 </simpara>\r
816 </listitem>\r
817 </varlistentry>\r
818 <varlistentry>\r
819 <term>\r
820 --quiet\r
821 </term>\r
822 <listitem>\r
823 <simpara>\r
824         Disable all output of the program. Implies <emphasis>--exit-code</emphasis>.\r
825 </simpara>\r
826 </listitem>\r
827 </varlistentry>\r
828 <varlistentry>\r
829 <term>\r
830 --ext-diff\r
831 </term>\r
832 <listitem>\r
833 <simpara>\r
834         Allow an external diff helper to be executed. If you set an\r
835         external diff driver with <xref linkend="gitattributes(5)" />, you need\r
836         to use this option with <xref linkend="git-log(1)" /> and friends.\r
837 </simpara>\r
838 </listitem>\r
839 </varlistentry>\r
840 <varlistentry>\r
841 <term>\r
842 --no-ext-diff\r
843 </term>\r
844 <listitem>\r
845 <simpara>\r
846         Disallow external diff drivers.\r
847 </simpara>\r
848 </listitem>\r
849 </varlistentry>\r
850 <varlistentry>\r
851 <term>\r
852 --textconv\r
853 </term>\r
854 <term>\r
855 --no-textconv\r
856 </term>\r
857 <listitem>\r
858 <simpara>\r
859         Allow (or disallow) external text conversion filters to be run\r
860         when comparing binary files. See <xref linkend="gitattributes(5)" /> for\r
861         details. Because textconv filters are typically a one-way\r
862         conversion, the resulting diff is suitable for human\r
863         consumption, but cannot be applied. For this reason, textconv\r
864         filters are enabled by default only for <xref linkend="git-diff(1)" /> and\r
865         <xref linkend="git-log(1)" />, but not for <xref linkend="git-format-patch(1)" /> or\r
866         diff plumbing commands.\r
867 </simpara>\r
868 </listitem>\r
869 </varlistentry>\r
870 <varlistentry>\r
871 <term>\r
872 --ignore-submodules[=&lt;when&gt;]\r
873 </term>\r
874 <listitem>\r
875 <simpara>\r
876         Ignore changes to submodules in the diff generation. &lt;when&gt; can be\r
877         either "none", "untracked", "dirty" or "all", which is the default\r
878         Using "none" will consider the submodule modified when it either contains\r
879         untracked or modified files or its HEAD differs from the commit recorded\r
880         in the superproject and can be used to override any settings of the\r
881         <emphasis>ignore</emphasis> option in <xref linkend="git-config(1)" /> or <xref linkend="gitmodules(5)" />. When\r
882         "untracked" is used submodules are not considered dirty when they only\r
883         contain untracked content (but they are still scanned for modified\r
884         content). Using "dirty" ignores all changes to the work tree of submodules,\r
885         only changes to the commits stored in the superproject are shown (this was\r
886         the behavior until 1.7.0). Using "all" hides all changes to submodules.\r
887 </simpara>\r
888 </listitem>\r
889 </varlistentry>\r
890 <varlistentry>\r
891 <term>\r
892 --src-prefix=&lt;prefix&gt;\r
893 </term>\r
894 <listitem>\r
895 <simpara>\r
896         Show the given source prefix instead of "a/".\r
897 </simpara>\r
898 </listitem>\r
899 </varlistentry>\r
900 <varlistentry>\r
901 <term>\r
902 --dst-prefix=&lt;prefix&gt;\r
903 </term>\r
904 <listitem>\r
905 <simpara>\r
906         Show the given destination prefix instead of "b/".\r
907 </simpara>\r
908 </listitem>\r
909 </varlistentry>\r
910 <varlistentry>\r
911 <term>\r
912 --no-prefix\r
913 </term>\r
914 <listitem>\r
915 <simpara>\r
916         Do not show any source or destination prefix.\r
917 </simpara>\r
918 </listitem>\r
919 </varlistentry>\r
920 </variablelist>\r
921 <simpara>For more detailed explanation on these common options, see also\r
922 <xref linkend="gitdiffcore(7)" />.</simpara>\r
923 <variablelist>\r
924 <varlistentry>\r
925 <term>\r
926 -1 --base\r
927 </term>\r
928 <term>\r
929 -2 --ours\r
930 </term>\r
931 <term>\r
932 -3 --theirs\r
933 </term>\r
934 <term>\r
935 -0\r
936 </term>\r
937 <listitem>\r
938 <simpara>\r
939         Diff against the "base" version, "our branch" or "their\r
940         branch" respectively.  With these options, diffs for\r
941         merged entries are not shown.\r
942 </simpara>\r
943 <simpara>The default is to diff against our branch (-2) and the\r
944 cleanly resolved paths.  The option -0 can be given to\r
945 omit diff output for unmerged entries and just show "Unmerged".</simpara>\r
946 </listitem>\r
947 </varlistentry>\r
948 <varlistentry>\r
949 <term>\r
950 -c\r
951 </term>\r
952 <term>\r
953 --cc\r
954 </term>\r
955 <listitem>\r
956 <simpara>\r
957         This compares stage 2 (our branch), stage 3 (their\r
958         branch) and the working tree file and outputs a combined\r
959         diff, similar to the way <emphasis>diff-tree</emphasis> shows a merge\r
960         commit with these flags.\r
961 </simpara>\r
962 </listitem>\r
963 </varlistentry>\r
964 <varlistentry>\r
965 <term>\r
966 -q\r
967 </term>\r
968 <listitem>\r
969 <simpara>\r
970         Remain silent even on nonexistent files\r
971 </simpara>\r
972 </listitem>\r
973 </varlistentry>\r
974 </variablelist>\r
975 </simplesect>\r
976 <simplesect id="_raw_output_format">\r
977 <title>Raw output format</title>\r
978 <simpara>The raw output format from "git-diff-index", "git-diff-tree",\r
979 "git-diff-files" and "git diff --raw" are very similar.</simpara>\r
980 <simpara>These commands all compare two sets of things; what is\r
981 compared differs:</simpara>\r
982 <variablelist>\r
983 <varlistentry>\r
984 <term>\r
985 git-diff-index &lt;tree-ish&gt;\r
986 </term>\r
987 <listitem>\r
988 <simpara>\r
989         compares the &lt;tree-ish&gt; and the files on the filesystem.\r
990 </simpara>\r
991 </listitem>\r
992 </varlistentry>\r
993 <varlistentry>\r
994 <term>\r
995 git-diff-index --cached &lt;tree-ish&gt;\r
996 </term>\r
997 <listitem>\r
998 <simpara>\r
999         compares the &lt;tree-ish&gt; and the index.\r
1000 </simpara>\r
1001 </listitem>\r
1002 </varlistentry>\r
1003 <varlistentry>\r
1004 <term>\r
1005 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]\r
1006 </term>\r
1007 <listitem>\r
1008 <simpara>\r
1009         compares the trees named by the two arguments.\r
1010 </simpara>\r
1011 </listitem>\r
1012 </varlistentry>\r
1013 <varlistentry>\r
1014 <term>\r
1015 git-diff-files [&lt;pattern&gt;&#8230;]\r
1016 </term>\r
1017 <listitem>\r
1018 <simpara>\r
1019         compares the index and the files on the filesystem.\r
1020 </simpara>\r
1021 </listitem>\r
1022 </varlistentry>\r
1023 </variablelist>\r
1024 <simpara>The "git-diff-tree" command begins its output by printing the hash of\r
1025 what is being compared. After that, all the commands print one output\r
1026 line per changed file.</simpara>\r
1027 <simpara>An output line is formatted this way:</simpara>\r
1028 <screen>in-place edit  :100644 100644 bcd1234... 0123456... M file0\r
1029 copy-edit      :100644 100644 abcd123... 1234567... C68 file1 file2\r
1030 rename-edit    :100644 100644 abcd123... 1234567... R86 file1 file3\r
1031 create         :000000 100644 0000000... 1234567... A file4\r
1032 delete         :100644 000000 1234567... 0000000... D file5\r
1033 unmerged       :000000 000000 0000000... 0000000... U file6</screen>\r
1034 <simpara>That is, from the left to the right:</simpara>\r
1035 <orderedlist numeration="arabic">\r
1036 <listitem>\r
1037 <simpara>\r
1038 a colon.\r
1039 </simpara>\r
1040 </listitem>\r
1041 <listitem>\r
1042 <simpara>\r
1043 mode for "src"; 000000 if creation or unmerged.\r
1044 </simpara>\r
1045 </listitem>\r
1046 <listitem>\r
1047 <simpara>\r
1048 a space.\r
1049 </simpara>\r
1050 </listitem>\r
1051 <listitem>\r
1052 <simpara>\r
1053 mode for "dst"; 000000 if deletion or unmerged.\r
1054 </simpara>\r
1055 </listitem>\r
1056 <listitem>\r
1057 <simpara>\r
1058 a space.\r
1059 </simpara>\r
1060 </listitem>\r
1061 <listitem>\r
1062 <simpara>\r
1063 sha1 for "src"; 0{40} if creation or unmerged.\r
1064 </simpara>\r
1065 </listitem>\r
1066 <listitem>\r
1067 <simpara>\r
1068 a space.\r
1069 </simpara>\r
1070 </listitem>\r
1071 <listitem>\r
1072 <simpara>\r
1073 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".\r
1074 </simpara>\r
1075 </listitem>\r
1076 <listitem>\r
1077 <simpara>\r
1078 a space.\r
1079 </simpara>\r
1080 </listitem>\r
1081 <listitem>\r
1082 <simpara>\r
1083 status, followed by optional "score" number.\r
1084 </simpara>\r
1085 </listitem>\r
1086 <listitem>\r
1087 <simpara>\r
1088 a tab or a NUL when <emphasis>-z</emphasis> option is used.\r
1089 </simpara>\r
1090 </listitem>\r
1091 <listitem>\r
1092 <simpara>\r
1093 path for "src"\r
1094 </simpara>\r
1095 </listitem>\r
1096 <listitem>\r
1097 <simpara>\r
1098 a tab or a NUL when <emphasis>-z</emphasis> option is used; only exists for C or R.\r
1099 </simpara>\r
1100 </listitem>\r
1101 <listitem>\r
1102 <simpara>\r
1103 path for "dst"; only exists for C or R.\r
1104 </simpara>\r
1105 </listitem>\r
1106 <listitem>\r
1107 <simpara>\r
1108 an LF or a NUL when <emphasis>-z</emphasis> option is used, to terminate the record.\r
1109 </simpara>\r
1110 </listitem>\r
1111 </orderedlist>\r
1112 <simpara>Possible status letters are:</simpara>\r
1113 <itemizedlist>\r
1114 <listitem>\r
1115 <simpara>\r
1116 A: addition of a file\r
1117 </simpara>\r
1118 </listitem>\r
1119 <listitem>\r
1120 <simpara>\r
1121 C: copy of a file into a new one\r
1122 </simpara>\r
1123 </listitem>\r
1124 <listitem>\r
1125 <simpara>\r
1126 D: deletion of a file\r
1127 </simpara>\r
1128 </listitem>\r
1129 <listitem>\r
1130 <simpara>\r
1131 M: modification of the contents or mode of a file\r
1132 </simpara>\r
1133 </listitem>\r
1134 <listitem>\r
1135 <simpara>\r
1136 R: renaming of a file\r
1137 </simpara>\r
1138 </listitem>\r
1139 <listitem>\r
1140 <simpara>\r
1141 T: change in the type of the file\r
1142 </simpara>\r
1143 </listitem>\r
1144 <listitem>\r
1145 <simpara>\r
1146 U: file is unmerged (you must complete the merge before it can\r
1147 be committed)\r
1148 </simpara>\r
1149 </listitem>\r
1150 <listitem>\r
1151 <simpara>\r
1152 X: "unknown" change type (most probably a bug, please report it)\r
1153 </simpara>\r
1154 </listitem>\r
1155 </itemizedlist>\r
1156 <simpara>Status letters C and R are always followed by a score (denoting the\r
1157 percentage of similarity between the source and target of the move or\r
1158 copy), and are the only ones to be so.</simpara>\r
1159 <simpara>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem\r
1160 and it is out of sync with the index.</simpara>\r
1161 <simpara>Example:</simpara>\r
1162 <screen>:100644 100644 5be4a4...... 000000...... M file.c</screen>\r
1163 <simpara>When <emphasis>-z</emphasis> option is not used, TAB, LF, and backslash characters\r
1164 in pathnames are represented as <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, and <emphasis>\\</emphasis>,\r
1165 respectively.</simpara>\r
1166 </simplesect>\r
1167 <simplesect id="_diff_format_for_merges">\r
1168 <title>diff format for merges</title>\r
1169 <simpara>"git-diff-tree", "git-diff-files" and "git-diff --raw"\r
1170 can take <emphasis>-c</emphasis> or <emphasis>--cc</emphasis> option\r
1171 to generate diff output also for merge commits.  The output differs\r
1172 from the format described above in the following way:</simpara>\r
1173 <orderedlist numeration="arabic">\r
1174 <listitem>\r
1175 <simpara>\r
1176 there is a colon for each parent\r
1177 </simpara>\r
1178 </listitem>\r
1179 <listitem>\r
1180 <simpara>\r
1181 there are more "src" modes and "src" sha1\r
1182 </simpara>\r
1183 </listitem>\r
1184 <listitem>\r
1185 <simpara>\r
1186 status is concatenated status characters for each parent\r
1187 </simpara>\r
1188 </listitem>\r
1189 <listitem>\r
1190 <simpara>\r
1191 no optional "score" number\r
1192 </simpara>\r
1193 </listitem>\r
1194 <listitem>\r
1195 <simpara>\r
1196 single path, only for "dst"\r
1197 </simpara>\r
1198 </listitem>\r
1199 </orderedlist>\r
1200 <simpara>Example:</simpara>\r
1201 <screen>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM      describe.c</screen>\r
1202 <simpara>Note that <emphasis>combined diff</emphasis> lists only files which were modified from\r
1203 all parents.</simpara>\r
1204 </simplesect>\r
1205 <simplesect id="_generating_patches_with_p">\r
1206 <title>Generating patches with -p</title>\r
1207 <simpara>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run\r
1208 with a <emphasis>-p</emphasis> option, "git diff" without the <emphasis>--raw</emphasis> option, or\r
1209 "git log" with the "-p" option, they\r
1210 do not produce the output described above; instead they produce a\r
1211 patch file.  You can customize the creation of such patches via the\r
1212 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</simpara>\r
1213 <simpara>What the -p option produces is slightly different from the traditional\r
1214 diff format:</simpara>\r
1215 <orderedlist numeration="arabic">\r
1216 <listitem>\r
1217 <simpara>\r
1218 It is preceded with a "git diff" header that looks like this:\r
1219 </simpara>\r
1220 <literallayout class="monospaced">diff --git a/file1 b/file2</literallayout>\r
1221 <simpara>The <emphasis>a/</emphasis> and <emphasis>b/</emphasis> filenames are the same unless rename/copy is\r
1222 involved.  Especially, even for a creation or a deletion,\r
1223 <emphasis>/dev/null</emphasis> is <emphasis>not</emphasis> used in place of the <emphasis>a/</emphasis> or <emphasis>b/</emphasis> filenames.</simpara>\r
1224 <simpara>When rename/copy is involved, <emphasis>file1</emphasis> and <emphasis>file2</emphasis> show the\r
1225 name of the source file of the rename/copy and the name of\r
1226 the file that rename/copy produces, respectively.</simpara>\r
1227 </listitem>\r
1228 <listitem>\r
1229 <simpara>\r
1230 It is followed by one or more extended header lines:\r
1231 </simpara>\r
1232 <literallayout class="monospaced">old mode &lt;mode&gt;\r
1233 new mode &lt;mode&gt;\r
1234 deleted file mode &lt;mode&gt;\r
1235 new file mode &lt;mode&gt;\r
1236 copy from &lt;path&gt;\r
1237 copy to &lt;path&gt;\r
1238 rename from &lt;path&gt;\r
1239 rename to &lt;path&gt;\r
1240 similarity index &lt;number&gt;\r
1241 dissimilarity index &lt;number&gt;\r
1242 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</literallayout>\r
1243 <simpara>File modes are printed as 6-digit octal numbers including the file type\r
1244 and file permission bits.</simpara>\r
1245 <simpara>Path names in extended headers do not include the <emphasis>a/</emphasis> and <emphasis>b/</emphasis> prefixes.</simpara>\r
1246 <simpara>The similarity index is the percentage of unchanged lines, and\r
1247 the dissimilarity index is the percentage of changed lines.  It\r
1248 is a rounded down integer, followed by a percent sign.  The\r
1249 similarity index value of 100% is thus reserved for two equal\r
1250 files, while 100% dissimilarity means that no line from the old\r
1251 file made it into the new one.</simpara>\r
1252 <simpara>The index line includes the SHA-1 checksum before and after the change.\r
1253 The &lt;mode&gt; is included if the file mode does not change; otherwise,\r
1254 separate lines indicate the old and the new mode.</simpara>\r
1255 </listitem>\r
1256 <listitem>\r
1257 <simpara>\r
1258 TAB, LF, double quote and backslash characters in pathnames\r
1259     are represented as <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, <emphasis>\"</emphasis> and <emphasis>\\</emphasis>, respectively.\r
1260     If there is need for such substitution then the whole\r
1261     pathname is put in double quotes.\r
1262 </simpara>\r
1263 </listitem>\r
1264 <listitem>\r
1265 <simpara>\r
1266 All the <emphasis>file1</emphasis> files in the output refer to files before the\r
1267     commit, and all the <emphasis>file2</emphasis> files refer to files after the commit.\r
1268     It is incorrect to apply each change to each file sequentially.  For\r
1269     example, this patch will swap a and b:\r
1270 </simpara>\r
1271 <literallayout class="monospaced">diff --git a/a b/b\r
1272 rename from a\r
1273 rename to b\r
1274 diff --git a/b b/a\r
1275 rename from b\r
1276 rename to a</literallayout>\r
1277 </listitem>\r
1278 </orderedlist>\r
1279 </simplesect>\r
1280 <simplesect id="_combined_diff_format">\r
1281 <title>combined diff format</title>\r
1282 <simpara>Any diff-generating command can take the -c` or <emphasis>--cc</emphasis> option to\r
1283 produce a <emphasis>combined diff</emphasis> when showing a merge. This is the default\r
1284 format when showing merges with <xref linkend="git-diff(1)" /> or\r
1285 <xref linkend="git-show(1)" />. Note also that you can give the `-m option to any\r
1286 of these commands to force generation of diffs with individual parents\r
1287 of a merge.</simpara>\r
1288 <simpara>A <emphasis>combined diff</emphasis> format looks like this:</simpara>\r
1289 <screen>diff --combined describe.c\r
1290 index fabadb8,cc95eb0..4866510\r
1291 --- a/describe.c\r
1292 +++ b/describe.c\r
1293 @@@ -98,20 -98,12 +98,20 @@@\r
1294         return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;\r
1295   }\r
1297 - static void describe(char *arg)\r
1298  -static void describe(struct commit *cmit, int last_one)\r
1299 ++static void describe(char *arg, int last_one)\r
1300   {\r
1301  +      unsigned char sha1[20];\r
1302  +      struct commit *cmit;\r
1303         struct commit_list *list;\r
1304         static int initialized = 0;\r
1305         struct commit_name *n;\r
1307  +      if (get_sha1(arg, sha1) &lt; 0)\r
1308  +              usage(describe_usage);\r
1309  +      cmit = lookup_commit_reference(sha1);\r
1310  +      if (!cmit)\r
1311  +              usage(describe_usage);\r
1312  +\r
1313         if (!initialized) {\r
1314                 initialized = 1;\r
1315                 for_each_ref(get_name);</screen>\r
1316 <orderedlist numeration="arabic">\r
1317 <listitem>\r
1318 <simpara>\r
1319 It is preceded with a "git diff" header, that looks like\r
1320      this (when <emphasis>-c</emphasis> option is used):\r
1321 </simpara>\r
1322 <literallayout class="monospaced">diff --combined file</literallayout>\r
1323 <simpara>or like this (when <emphasis>--cc</emphasis> option is used):</simpara>\r
1324 <literallayout class="monospaced">diff --cc file</literallayout>\r
1325 </listitem>\r
1326 <listitem>\r
1327 <simpara>\r
1328 It is followed by one or more extended header lines\r
1329      (this example shows a merge with two parents):\r
1330 </simpara>\r
1331 <literallayout class="monospaced">index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;\r
1332 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;\r
1333 new file mode &lt;mode&gt;\r
1334 deleted file mode &lt;mode&gt;,&lt;mode&gt;</literallayout>\r
1335 <simpara>The <emphasis>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</emphasis> line appears only if at least one of\r
1336 the &lt;mode&gt; is different from the rest. Extended headers with\r
1337 information about detected contents movement (renames and\r
1338 copying detection) are designed to work with diff of two\r
1339 &lt;tree-ish&gt; and are not used by combined diff format.</simpara>\r
1340 </listitem>\r
1341 <listitem>\r
1342 <simpara>\r
1343 It is followed by two-line from-file/to-file header\r
1344 </simpara>\r
1345 <literallayout class="monospaced">--- a/file\r
1346 +++ b/file</literallayout>\r
1347 <simpara>Similar to two-line header for traditional <emphasis>unified</emphasis> diff\r
1348 format, <emphasis>/dev/null</emphasis> is used to signal created or deleted\r
1349 files.</simpara>\r
1350 </listitem>\r
1351 <listitem>\r
1352 <simpara>\r
1353 Chunk header format is modified to prevent people from\r
1354      accidentally feeding it to <emphasis>patch -p1</emphasis>. Combined diff format\r
1355      was created for review of merge commit changes, and was not\r
1356      meant for apply. The change is similar to the change in the\r
1357      extended <emphasis>index</emphasis> header:\r
1358 </simpara>\r
1359 <literallayout class="monospaced">@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</literallayout>\r
1360 <simpara>There are (number of parents + 1) <emphasis>@</emphasis> characters in the chunk\r
1361 header for combined diff format.</simpara>\r
1362 </listitem>\r
1363 </orderedlist>\r
1364 <simpara>Unlike the traditional <emphasis>unified</emphasis> diff format, which shows two\r
1365 files A and B with a single column that has <emphasis>-</emphasis> (minus --\r
1366 appears in A but removed in B), <emphasis>+</emphasis> (plus -- missing in A but\r
1367 added to B), or <emphasis>" "</emphasis> (space -- unchanged) prefix, this format\r
1368 compares two or more files file1, file2,&#8230; with one file X, and\r
1369 shows how X differs from each of fileN.  One column for each of\r
1370 fileN is prepended to the output line to note how X's line is\r
1371 different from it.</simpara>\r
1372 <simpara>A <emphasis>-</emphasis> character in the column N means that the line appears in\r
1373 fileN but it does not appear in the result.  A <emphasis>+</emphasis> character\r
1374 in the column N means that the line appears in the result,\r
1375 and fileN does not have that line (in other words, the line was\r
1376 added, from the point of view of that parent).</simpara>\r
1377 <simpara>In the above example output, the function signature was changed\r
1378 from both files (hence two <emphasis>-</emphasis> removals from both file1 and\r
1379 file2, plus <emphasis>++</emphasis> to mean one line that was added does not appear\r
1380 in either file1 nor file2).  Also eight other lines are the same\r
1381 from file1 but do not appear in file2 (hence prefixed with <emphasis>+</emphasis>).</simpara>\r
1382 <simpara>When shown by <emphasis>git diff-tree -c</emphasis>, it compares the parents of a\r
1383 merge commit with the merge result (i.e. file1..fileN are the\r
1384 parents).  When shown by <emphasis>git diff-files -c</emphasis>, it compares the\r
1385 two unresolved merge parents with the working tree file\r
1386 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka\r
1387 "their version").</simpara>\r
1388 </simplesect>\r
1389 <simplesect id="_other_diff_formats">\r
1390 <title>other diff formats</title>\r
1391 <simpara>The <emphasis>--summary</emphasis> option describes newly added, deleted, renamed and\r
1392 copied files.  The <emphasis>--stat</emphasis> option adds diffstat(1) graph to the\r
1393 output.  These options can be combined with other options, such as\r
1394 <emphasis>-p</emphasis>, and are meant for human consumption.</simpara>\r
1395 <simpara>When showing a change that involves a rename or a copy, <emphasis>--stat</emphasis> output\r
1396 formats the pathnames compactly by combining common prefix and suffix of\r
1397 the pathnames.  For example, a change that moves <emphasis>arch/i386/Makefile</emphasis> to\r
1398 <emphasis>arch/x86/Makefile</emphasis> while modifying 4 lines will be shown like this:</simpara>\r
1399 <screen>arch/{i386 =&gt; x86}/Makefile    |   4 +--</screen>\r
1400 <simpara>The <emphasis>--numstat</emphasis> option gives the diffstat(1) information but is designed\r
1401 for easier machine consumption.  An entry in <emphasis>--numstat</emphasis> output looks\r
1402 like this:</simpara>\r
1403 <screen>1       2       README\r
1404 3       1       arch/{i386 =&gt; x86}/Makefile</screen>\r
1405 <simpara>That is, from left to right:</simpara>\r
1406 <orderedlist numeration="arabic">\r
1407 <listitem>\r
1408 <simpara>\r
1409 the number of added lines;\r
1410 </simpara>\r
1411 </listitem>\r
1412 <listitem>\r
1413 <simpara>\r
1414 a tab;\r
1415 </simpara>\r
1416 </listitem>\r
1417 <listitem>\r
1418 <simpara>\r
1419 the number of deleted lines;\r
1420 </simpara>\r
1421 </listitem>\r
1422 <listitem>\r
1423 <simpara>\r
1424 a tab;\r
1425 </simpara>\r
1426 </listitem>\r
1427 <listitem>\r
1428 <simpara>\r
1429 pathname (possibly with rename/copy information);\r
1430 </simpara>\r
1431 </listitem>\r
1432 <listitem>\r
1433 <simpara>\r
1434 a newline.\r
1435 </simpara>\r
1436 </listitem>\r
1437 </orderedlist>\r
1438 <simpara>When <emphasis>-z</emphasis> output option is in effect, the output is formatted this way:</simpara>\r
1439 <screen>1       2       README NUL\r
1440 3       1       NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</screen>\r
1441 <simpara>That is:</simpara>\r
1442 <orderedlist numeration="arabic">\r
1443 <listitem>\r
1444 <simpara>\r
1445 the number of added lines;\r
1446 </simpara>\r
1447 </listitem>\r
1448 <listitem>\r
1449 <simpara>\r
1450 a tab;\r
1451 </simpara>\r
1452 </listitem>\r
1453 <listitem>\r
1454 <simpara>\r
1455 the number of deleted lines;\r
1456 </simpara>\r
1457 </listitem>\r
1458 <listitem>\r
1459 <simpara>\r
1460 a tab;\r
1461 </simpara>\r
1462 </listitem>\r
1463 <listitem>\r
1464 <simpara>\r
1465 a NUL (only exists if renamed/copied);\r
1466 </simpara>\r
1467 </listitem>\r
1468 <listitem>\r
1469 <simpara>\r
1470 pathname in preimage;\r
1471 </simpara>\r
1472 </listitem>\r
1473 <listitem>\r
1474 <simpara>\r
1475 a NUL (only exists if renamed/copied);\r
1476 </simpara>\r
1477 </listitem>\r
1478 <listitem>\r
1479 <simpara>\r
1480 pathname in postimage (only exists if renamed/copied);\r
1481 </simpara>\r
1482 </listitem>\r
1483 <listitem>\r
1484 <simpara>\r
1485 a NUL.\r
1486 </simpara>\r
1487 </listitem>\r
1488 </orderedlist>\r
1489 <simpara>The extra <emphasis>NUL</emphasis> before the preimage path in renamed case is to allow\r
1490 scripts that read the output to tell if the current record being read is\r
1491 a single-path record or a rename/copy record without reading ahead.\r
1492 After reading added and deleted lines, reading up to <emphasis>NUL</emphasis> would yield\r
1493 the pathname, but if that is <emphasis>NUL</emphasis>, the record will show two paths.</simpara>\r
1494 </simplesect>\r
1495 <simplesect id="_git">\r
1496 <title>GIT</title>\r
1497 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>\r
1498 </simplesect>\r
1499 </article>\r