Autogenerated HTML docs for v1.6.4-rc1
[git/jnareb-git.git] / git-diff-tree.html
blob156da7d6e47f324d0509b5668c574ac1ce7ad24e
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.2.5" />
7 <style type="text/css">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-diff-tree(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-diff-tree(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-diff-tree -
317 Compares the content and mode of blobs found via two tree objects
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="verseblock">
324 <div class="content"><em>git diff-tree</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
325 [-t] [-r] [-c | --cc] [--root] [&lt;common diff options&gt;]
326 &lt;tree-ish&gt; [&lt;tree-ish&gt;] [&lt;path&gt;&#8230;]</div></div>
327 </div>
328 <h2 id="_description">DESCRIPTION</h2>
329 <div class="sectionbody">
330 <div class="para"><p>Compares the content and mode of the blobs found via two tree objects.</p></div>
331 <div class="para"><p>If there is only one &lt;tree-ish&gt; given, the commit is compared with its parents
332 (see --stdin below).</p></div>
333 <div class="para"><p>Note that <em>git-diff-tree</em> can use the tree encapsulated in a commit object.</p></div>
334 </div>
335 <h2 id="_options">OPTIONS</h2>
336 <div class="sectionbody">
337 <div class="vlist"><dl>
338 <dt>
340 </dt>
341 <dt>
343 </dt>
344 <dd>
346 Generate patch (see section on generating patches).
348 </p>
349 </dd>
350 <dt>
351 -U&lt;n&gt;
352 </dt>
353 <dt>
354 --unified=&lt;n&gt;
355 </dt>
356 <dd>
358 Generate diffs with &lt;n&gt; lines of context instead of
359 the usual three. Implies "-p".
360 </p>
361 </dd>
362 <dt>
363 --raw
364 </dt>
365 <dd>
367 Generate the raw format.
368 This is the default.
369 </p>
370 </dd>
371 <dt>
372 --patch-with-raw
373 </dt>
374 <dd>
376 Synonym for "-p --raw".
377 </p>
378 </dd>
379 <dt>
380 --patience
381 </dt>
382 <dd>
384 Generate a diff using the "patience diff" algorithm.
385 </p>
386 </dd>
387 <dt>
388 --stat[=width[,name-width]]
389 </dt>
390 <dd>
392 Generate a diffstat. You can override the default
393 output width for 80-column terminal by "--stat=width".
394 The width of the filename part can be controlled by
395 giving another width to it separated by a comma.
396 </p>
397 </dd>
398 <dt>
399 --numstat
400 </dt>
401 <dd>
403 Similar to --stat, but shows number of added and
404 deleted lines in decimal notation and pathname without
405 abbreviation, to make it more machine friendly. For
406 binary files, outputs two <tt>-</tt> instead of saying
407 <tt>0 0</tt>.
408 </p>
409 </dd>
410 <dt>
411 --shortstat
412 </dt>
413 <dd>
415 Output only the last line of the --stat format containing total
416 number of modified files, as well as number of added and deleted
417 lines.
418 </p>
419 </dd>
420 <dt>
421 --dirstat[=limit]
422 </dt>
423 <dd>
425 Output the distribution of relative amount of changes (number of lines added or
426 removed) for each sub-directory. Directories with changes below
427 a cut-off percent (3% by default) are not shown. The cut-off percent
428 can be set with "--dirstat=limit". Changes in a child directory is not
429 counted for the parent directory, unless "--cumulative" is used.
430 </p>
431 </dd>
432 <dt>
433 --dirstat-by-file[=limit]
434 </dt>
435 <dd>
437 Same as --dirstat, but counts changed files instead of lines.
438 </p>
439 </dd>
440 <dt>
441 --summary
442 </dt>
443 <dd>
445 Output a condensed summary of extended header information
446 such as creations, renames and mode changes.
447 </p>
448 </dd>
449 <dt>
450 --patch-with-stat
451 </dt>
452 <dd>
454 Synonym for "-p --stat".
456 </p>
457 </dd>
458 <dt>
460 </dt>
461 <dd>
463 NUL-line termination on output. This affects the --raw
464 output field terminator. Also output from commands such
465 as "git-log" will be delimited with NUL between commits.
466 </p>
467 </dd>
468 <dt>
469 --name-only
470 </dt>
471 <dd>
473 Show only names of changed files.
474 </p>
475 </dd>
476 <dt>
477 --name-status
478 </dt>
479 <dd>
481 Show only names and status of changed files. See the description
482 of the <tt>--diff-filter</tt> option on what the status letters mean.
483 </p>
484 </dd>
485 <dt>
486 --color
487 </dt>
488 <dd>
490 Show colored diff.
491 </p>
492 </dd>
493 <dt>
494 --no-color
495 </dt>
496 <dd>
498 Turn off colored diff, even when the configuration file
499 gives the default to color output.
500 </p>
501 </dd>
502 <dt>
503 --color-words[=&lt;regex&gt;]
504 </dt>
505 <dd>
507 Show colored word diff, i.e., color words which have changed.
508 By default, words are separated by whitespace.
509 </p>
510 <div class="para"><p>When a &lt;regex&gt; is specified, every non-overlapping match of the
511 &lt;regex&gt; is considered a word. Anything between these matches is
512 considered whitespace and ignored(!) for the purposes of finding
513 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
514 expression to make sure that it matches all non-whitespace characters.
515 A match that contains a newline is silently truncated(!) at the
516 newline.</p></div>
517 <div class="para"><p>The regex can also be set via a diff driver or configuration option, see
518 <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly
519 overrides any diff driver or configuration setting. Diff drivers
520 override configuration settings.</p></div>
521 </dd>
522 <dt>
523 --no-renames
524 </dt>
525 <dd>
527 Turn off rename detection, even when the configuration
528 file gives the default to do so.
529 </p>
530 </dd>
531 <dt>
532 --check
533 </dt>
534 <dd>
536 Warn if changes introduce trailing whitespace
537 or an indent that uses a space before a tab. Exits with
538 non-zero status if problems are found. Not compatible with
539 --exit-code.
540 </p>
541 </dd>
542 <dt>
543 --full-index
544 </dt>
545 <dd>
547 Instead of the first handful of characters, show the full
548 pre- and post-image blob object names on the "index"
549 line when generating patch format output.
550 </p>
551 </dd>
552 <dt>
553 --binary
554 </dt>
555 <dd>
557 In addition to --full-index, output "binary diff" that
558 can be applied with "git apply".
559 </p>
560 </dd>
561 <dt>
562 --abbrev[=&lt;n&gt;]
563 </dt>
564 <dd>
566 Instead of showing the full 40-byte hexadecimal object
567 name in diff-raw format output and diff-tree header
568 lines, show only a partial prefix. This is
569 independent of --full-index option above, which controls
570 the diff-patch output format. Non default number of
571 digits can be specified with --abbrev=&lt;n&gt;.
572 </p>
573 </dd>
574 <dt>
576 </dt>
577 <dd>
579 Break complete rewrite changes into pairs of delete and create.
580 </p>
581 </dd>
582 <dt>
584 </dt>
585 <dd>
587 Detect renames.
588 </p>
589 </dd>
590 <dt>
592 </dt>
593 <dd>
595 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
596 </p>
597 </dd>
598 <dt>
599 --diff-filter=[ACDMRTUXB*]
600 </dt>
601 <dd>
603 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
604 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
605 type (i.e. regular file, symlink, submodule, &#8230;) changed (<tt>T</tt>),
606 are Unmerged (<tt>U</tt>), are
607 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
608 Any combination of the filter characters may be used.
609 When <tt>*</tt> (All-or-none) is added to the combination, all
610 paths are selected if there is any file that matches
611 other criteria in the comparison; if there is no file
612 that matches other criteria, nothing is selected.
613 </p>
614 </dd>
615 <dt>
616 --find-copies-harder
617 </dt>
618 <dd>
620 For performance reasons, by default, <tt>-C</tt> option finds copies only
621 if the original file of the copy was modified in the same
622 changeset. This flag makes the command
623 inspect unmodified files as candidates for the source of
624 copy. This is a very expensive operation for large
625 projects, so use it with caution. Giving more than one
626 <tt>-C</tt> option has the same effect.
627 </p>
628 </dd>
629 <dt>
630 -l&lt;num&gt;
631 </dt>
632 <dd>
634 -M and -C options require O(n^2) processing time where n
635 is the number of potential rename/copy targets. This
636 option prevents rename/copy detection from running if
637 the number of rename/copy targets exceeds the specified
638 number.
639 </p>
640 </dd>
641 <dt>
642 -S&lt;string&gt;
643 </dt>
644 <dd>
646 Look for differences that introduce or remove an instance of
647 &lt;string&gt;. Note that this is different than the string simply
648 appearing in diff output; see the <em>pickaxe</em> entry in
649 <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details.
650 </p>
651 </dd>
652 <dt>
653 --pickaxe-all
654 </dt>
655 <dd>
657 When -S finds a change, show all the changes in that
658 changeset, not just the files that contain the change
659 in &lt;string&gt;.
660 </p>
661 </dd>
662 <dt>
663 --pickaxe-regex
664 </dt>
665 <dd>
667 Make the &lt;string&gt; not a plain string but an extended POSIX
668 regex to match.
669 </p>
670 </dd>
671 <dt>
672 -O&lt;orderfile&gt;
673 </dt>
674 <dd>
676 Output the patch in the order specified in the
677 &lt;orderfile&gt;, which has one shell glob pattern per line.
678 </p>
679 </dd>
680 <dt>
682 </dt>
683 <dd>
685 Swap two inputs; that is, show differences from index or
686 on-disk file to tree contents.
687 </p>
688 </dd>
689 <dt>
690 --relative[=&lt;path&gt;]
691 </dt>
692 <dd>
694 When run from a subdirectory of the project, it can be
695 told to exclude changes outside the directory and show
696 pathnames relative to it with this option. When you are
697 not in a subdirectory (e.g. in a bare repository), you
698 can name which subdirectory to make the output relative
699 to by giving a &lt;path&gt; as an argument.
700 </p>
701 </dd>
702 <dt>
704 </dt>
705 <dt>
706 --text
707 </dt>
708 <dd>
710 Treat all files as text.
711 </p>
712 </dd>
713 <dt>
714 --ignore-space-at-eol
715 </dt>
716 <dd>
718 Ignore changes in whitespace at EOL.
719 </p>
720 </dd>
721 <dt>
723 </dt>
724 <dt>
725 --ignore-space-change
726 </dt>
727 <dd>
729 Ignore changes in amount of whitespace. This ignores whitespace
730 at line end, and considers all other sequences of one or
731 more whitespace characters to be equivalent.
732 </p>
733 </dd>
734 <dt>
736 </dt>
737 <dt>
738 --ignore-all-space
739 </dt>
740 <dd>
742 Ignore whitespace when comparing lines. This ignores
743 differences even if one line has whitespace where the other
744 line has none.
745 </p>
746 </dd>
747 <dt>
748 --inter-hunk-context=&lt;lines&gt;
749 </dt>
750 <dd>
752 Show the context between diff hunks, up to the specified number
753 of lines, thereby fusing hunks that are close to each other.
754 </p>
755 </dd>
756 <dt>
757 --exit-code
758 </dt>
759 <dd>
761 Make the program exit with codes similar to diff(1).
762 That is, it exits with 1 if there were differences and
763 0 means no differences.
764 </p>
765 </dd>
766 <dt>
767 --quiet
768 </dt>
769 <dd>
771 Disable all output of the program. Implies --exit-code.
772 </p>
773 </dd>
774 <dt>
775 --ext-diff
776 </dt>
777 <dd>
779 Allow an external diff helper to be executed. If you set an
780 external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need
781 to use this option with <a href="git-log.html">git-log(1)</a> and friends.
782 </p>
783 </dd>
784 <dt>
785 --no-ext-diff
786 </dt>
787 <dd>
789 Disallow external diff drivers.
790 </p>
791 </dd>
792 <dt>
793 --ignore-submodules
794 </dt>
795 <dd>
797 Ignore changes to submodules in the diff generation.
798 </p>
799 </dd>
800 <dt>
801 --src-prefix=&lt;prefix&gt;
802 </dt>
803 <dd>
805 Show the given source prefix instead of "a/".
806 </p>
807 </dd>
808 <dt>
809 --dst-prefix=&lt;prefix&gt;
810 </dt>
811 <dd>
813 Show the given destination prefix instead of "b/".
814 </p>
815 </dd>
816 <dt>
817 --no-prefix
818 </dt>
819 <dd>
821 Do not show any source or destination prefix.
822 </p>
823 </dd>
824 </dl></div>
825 <div class="para"><p>For more detailed explanation on these common options, see also
826 <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div>
827 <div class="vlist"><dl>
828 <dt>
829 &lt;tree-ish&gt;
830 </dt>
831 <dd>
833 The id of a tree object.
834 </p>
835 </dd>
836 <dt>
837 &lt;path&gt;&#8230;
838 </dt>
839 <dd>
841 If provided, the results are limited to a subset of files
842 matching one of these prefix strings.
843 i.e., file matches <tt>/^&lt;pattern1&gt;|&lt;pattern2&gt;|&#8230;/</tt>
844 Note that this parameter does not provide any wildcard or regexp
845 features.
846 </p>
847 </dd>
848 <dt>
850 </dt>
851 <dd>
853 recurse into sub-trees
854 </p>
855 </dd>
856 <dt>
858 </dt>
859 <dd>
861 show tree entry itself as well as subtrees. Implies -r.
862 </p>
863 </dd>
864 <dt>
865 --root
866 </dt>
867 <dd>
869 When <em>--root</em> is specified the initial commit will be shown as a big
870 creation event. This is equivalent to a diff against the NULL tree.
871 </p>
872 </dd>
873 <dt>
874 --stdin
875 </dt>
876 <dd>
878 When <em>--stdin</em> is specified, the command does not take
879 &lt;tree-ish&gt; arguments from the command line. Instead, it
880 reads lines containing either two &lt;tree&gt;, one &lt;commit&gt;, or a
881 list of &lt;commit&gt; from its standard input. (Use a single space
882 as separator.)
883 </p>
884 <div class="para"><p>When two trees are given, it compares the first tree with the second.
885 When a single commit is given, it compares the commit with its
886 parents. The remaining commits, when given, are used as if they are
887 parents of the first commit.</p></div>
888 <div class="para"><p>When comparing two trees, the ID of both trees (separated by a space
889 and terminated by a newline) is printed before the difference. When
890 comparing commits, the ID of the first (or only) commit, followed by a
891 newline, is printed.</p></div>
892 <div class="para"><p>The following flags further affect the behavior when comparing
893 commits (but not trees).</p></div>
894 </dd>
895 <dt>
897 </dt>
898 <dd>
900 By default, <em>git-diff-tree --stdin</em> does not show
901 differences for merge commits. With this flag, it shows
902 differences to that commit from all of its parents. See
903 also <em>-c</em>.
904 </p>
905 </dd>
906 <dt>
908 </dt>
909 <dd>
911 By default, <em>git-diff-tree --stdin</em> shows differences,
912 either in machine-readable form (without <em>-p</em>) or in patch
913 form (with <em>-p</em>). This output can be suppressed. It is
914 only useful with <em>-v</em> flag.
915 </p>
916 </dd>
917 <dt>
919 </dt>
920 <dd>
922 This flag causes <em>git-diff-tree --stdin</em> to also show
923 the commit message before the differences.
924 </p>
925 </dd>
926 <dt>
927 --pretty[=<em>&lt;format&gt;</em>]
928 </dt>
929 <dt>
930 --format[=<em>&lt;format&gt;</em>]
931 </dt>
932 <dd>
934 Pretty-print the contents of the commit logs in a given format,
935 where <em>&lt;format&gt;</em> can be one of <em>oneline</em>, <em>short</em>, <em>medium</em>,
936 <em>full</em>, <em>fuller</em>, <em>email</em>, <em>raw</em> and <em>format:&lt;string&gt;</em>.
937 When omitted, the format defaults to <em>medium</em>.
938 </p>
939 <div class="para"><p>Note: you can specify the default pretty format in the repository
940 configuration (see <a href="git-config.html">git-config(1)</a>).</p></div>
941 </dd>
942 <dt>
943 --abbrev-commit
944 </dt>
945 <dd>
947 Instead of showing the full 40-byte hexadecimal commit object
948 name, show only a partial prefix. Non default number of
949 digits can be specified with "--abbrev=&lt;n&gt;" (which also modifies
950 diff output, if it is displayed).
951 </p>
952 <div class="para"><p>This should make "--pretty=oneline" a whole lot more readable for
953 people using 80-column terminals.</p></div>
954 </dd>
955 <dt>
956 --oneline
957 </dt>
958 <dd>
960 This is a shorthand for "--pretty=oneline --abbrev-commit"
961 used together.
962 </p>
963 </dd>
964 <dt>
965 --encoding[=&lt;encoding&gt;]
966 </dt>
967 <dd>
969 The commit objects record the encoding used for the log message
970 in their encoding header; this option can be used to tell the
971 command to re-code the commit log message in the encoding
972 preferred by the user. For non plumbing commands this
973 defaults to UTF-8.
974 </p>
975 </dd>
976 <dt>
977 --no-commit-id
978 </dt>
979 <dd>
981 <em>git-diff-tree</em> outputs a line with the commit ID when
982 applicable. This flag suppressed the commit ID output.
983 </p>
984 </dd>
985 <dt>
987 </dt>
988 <dd>
990 This flag changes the way a merge commit is displayed
991 (which means it is useful only when the command is given
992 one &lt;tree-ish&gt;, or <em>--stdin</em>). It shows the differences
993 from each of the parents to the merge result simultaneously
994 instead of showing pairwise diff between a parent and the
995 result one at a time (which is what the <em>-m</em> option does).
996 Furthermore, it lists only files which were modified
997 from all parents.
998 </p>
999 </dd>
1000 <dt>
1001 --cc
1002 </dt>
1003 <dd>
1005 This flag changes the way a merge commit patch is displayed,
1006 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
1007 and <em>-p</em> options and further compresses the patch output
1008 by omitting uninteresting hunks whose the contents in the parents
1009 have only two variants and the merge result picks one of them
1010 without modification. When all hunks are uninteresting, the commit
1011 itself and the commit log message is not shown, just like in any other
1012 "empty diff" case.
1013 </p>
1014 </dd>
1015 <dt>
1016 --always
1017 </dt>
1018 <dd>
1020 Show the commit itself and the commit log message even
1021 if the diff itself is empty.
1022 </p>
1023 </dd>
1024 </dl></div>
1025 </div>
1026 <h2 id="_pretty_formats">PRETTY FORMATS</h2>
1027 <div class="sectionbody">
1028 <div class="para"><p>If the commit is a merge, and if the pretty-format
1029 is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
1030 inserted before the <em>Author:</em> line. This line begins with
1031 "Merge: " and the sha1s of ancestral commits are printed,
1032 separated by spaces. Note that the listed commits may not
1033 necessarily be the list of the <strong>direct</strong> parent commits if you
1034 have limited your view of history: for example, if you are
1035 only interested in changes related to a certain directory or
1036 file.</p></div>
1037 <div class="para"><p>Here are some additional details for each format:</p></div>
1038 <div class="ilist"><ul>
1039 <li>
1041 <em>oneline</em>
1042 </p>
1043 <div class="literalblock">
1044 <div class="content">
1045 <pre><tt>&lt;sha1&gt; &lt;title line&gt;</tt></pre>
1046 </div></div>
1047 <div class="para"><p>This is designed to be as compact as possible.</p></div>
1048 </li>
1049 <li>
1051 <em>short</em>
1052 </p>
1053 <div class="literalblock">
1054 <div class="content">
1055 <pre><tt>commit &lt;sha1&gt;
1056 Author: &lt;author&gt;</tt></pre>
1057 </div></div>
1058 <div class="literalblock">
1059 <div class="content">
1060 <pre><tt>&lt;title line&gt;</tt></pre>
1061 </div></div>
1062 </li>
1063 <li>
1065 <em>medium</em>
1066 </p>
1067 <div class="literalblock">
1068 <div class="content">
1069 <pre><tt>commit &lt;sha1&gt;
1070 Author: &lt;author&gt;
1071 Date: &lt;author date&gt;</tt></pre>
1072 </div></div>
1073 <div class="literalblock">
1074 <div class="content">
1075 <pre><tt>&lt;title line&gt;</tt></pre>
1076 </div></div>
1077 <div class="literalblock">
1078 <div class="content">
1079 <pre><tt>&lt;full commit message&gt;</tt></pre>
1080 </div></div>
1081 </li>
1082 <li>
1084 <em>full</em>
1085 </p>
1086 <div class="literalblock">
1087 <div class="content">
1088 <pre><tt>commit &lt;sha1&gt;
1089 Author: &lt;author&gt;
1090 Commit: &lt;committer&gt;</tt></pre>
1091 </div></div>
1092 <div class="literalblock">
1093 <div class="content">
1094 <pre><tt>&lt;title line&gt;</tt></pre>
1095 </div></div>
1096 <div class="literalblock">
1097 <div class="content">
1098 <pre><tt>&lt;full commit message&gt;</tt></pre>
1099 </div></div>
1100 </li>
1101 <li>
1103 <em>fuller</em>
1104 </p>
1105 <div class="literalblock">
1106 <div class="content">
1107 <pre><tt>commit &lt;sha1&gt;
1108 Author: &lt;author&gt;
1109 AuthorDate: &lt;author date&gt;
1110 Commit: &lt;committer&gt;
1111 CommitDate: &lt;committer date&gt;</tt></pre>
1112 </div></div>
1113 <div class="literalblock">
1114 <div class="content">
1115 <pre><tt>&lt;title line&gt;</tt></pre>
1116 </div></div>
1117 <div class="literalblock">
1118 <div class="content">
1119 <pre><tt>&lt;full commit message&gt;</tt></pre>
1120 </div></div>
1121 </li>
1122 <li>
1124 <em>email</em>
1125 </p>
1126 <div class="literalblock">
1127 <div class="content">
1128 <pre><tt>From &lt;sha1&gt; &lt;date&gt;
1129 From: &lt;author&gt;
1130 Date: &lt;author date&gt;
1131 Subject: [PATCH] &lt;title line&gt;</tt></pre>
1132 </div></div>
1133 <div class="literalblock">
1134 <div class="content">
1135 <pre><tt>&lt;full commit message&gt;</tt></pre>
1136 </div></div>
1137 </li>
1138 <li>
1140 <em>raw</em>
1141 </p>
1142 <div class="para"><p>The <em>raw</em> format shows the entire commit exactly as
1143 stored in the commit object. Notably, the SHA1s are
1144 displayed in full, regardless of whether --abbrev or
1145 --no-abbrev are used, and <em>parents</em> information show the
1146 true parent commits, without taking grafts nor history
1147 simplification into account.</p></div>
1148 </li>
1149 <li>
1151 <em>format:</em>
1152 </p>
1153 <div class="para"><p>The <em>format:</em> format allows you to specify which information
1154 you want to show. It works a little bit like printf format,
1155 with the notable exception that you get a newline with <em>%n</em>
1156 instead of <em>\n</em>.</p></div>
1157 <div class="para"><p>E.g, <em>format:"The author of %h was %an, %ar%nThe title was &gt;&gt;%s&lt;&lt;%n"</em>
1158 would show something like this:</p></div>
1159 <div class="listingblock">
1160 <div class="content">
1161 <pre><tt>The author of fe6e0ee was Junio C Hamano, 23 hours ago
1162 The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;
1163 </tt></pre>
1164 </div></div>
1165 <div class="para"><p>The placeholders are:</p></div>
1166 <div class="ilist"><ul>
1167 <li>
1169 <em>%H</em>: commit hash
1170 </p>
1171 </li>
1172 <li>
1174 <em>%h</em>: abbreviated commit hash
1175 </p>
1176 </li>
1177 <li>
1179 <em>%T</em>: tree hash
1180 </p>
1181 </li>
1182 <li>
1184 <em>%t</em>: abbreviated tree hash
1185 </p>
1186 </li>
1187 <li>
1189 <em>%P</em>: parent hashes
1190 </p>
1191 </li>
1192 <li>
1194 <em>%p</em>: abbreviated parent hashes
1195 </p>
1196 </li>
1197 <li>
1199 <em>%an</em>: author name
1200 </p>
1201 </li>
1202 <li>
1204 <em>%aN</em>: author name (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
1205 </p>
1206 </li>
1207 <li>
1209 <em>%ae</em>: author email
1210 </p>
1211 </li>
1212 <li>
1214 <em>%aE</em>: author email (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
1215 </p>
1216 </li>
1217 <li>
1219 <em>%ad</em>: author date (format respects --date= option)
1220 </p>
1221 </li>
1222 <li>
1224 <em>%aD</em>: author date, RFC2822 style
1225 </p>
1226 </li>
1227 <li>
1229 <em>%ar</em>: author date, relative
1230 </p>
1231 </li>
1232 <li>
1234 <em>%at</em>: author date, UNIX timestamp
1235 </p>
1236 </li>
1237 <li>
1239 <em>%ai</em>: author date, ISO 8601 format
1240 </p>
1241 </li>
1242 <li>
1244 <em>%cn</em>: committer name
1245 </p>
1246 </li>
1247 <li>
1249 <em>%cN</em>: committer name (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
1250 </p>
1251 </li>
1252 <li>
1254 <em>%ce</em>: committer email
1255 </p>
1256 </li>
1257 <li>
1259 <em>%cE</em>: committer email (respecting .mailmap, see <a href="git-shortlog.html">git-shortlog(1)</a> or <a href="git-blame.html">git-blame(1)</a>)
1260 </p>
1261 </li>
1262 <li>
1264 <em>%cd</em>: committer date
1265 </p>
1266 </li>
1267 <li>
1269 <em>%cD</em>: committer date, RFC2822 style
1270 </p>
1271 </li>
1272 <li>
1274 <em>%cr</em>: committer date, relative
1275 </p>
1276 </li>
1277 <li>
1279 <em>%ct</em>: committer date, UNIX timestamp
1280 </p>
1281 </li>
1282 <li>
1284 <em>%ci</em>: committer date, ISO 8601 format
1285 </p>
1286 </li>
1287 <li>
1289 <em>%d</em>: ref names, like the --decorate option of <a href="git-log.html">git-log(1)</a>
1290 </p>
1291 </li>
1292 <li>
1294 <em>%e</em>: encoding
1295 </p>
1296 </li>
1297 <li>
1299 <em>%s</em>: subject
1300 </p>
1301 </li>
1302 <li>
1304 <em>%f</em>: sanitized subject line, suitable for a filename
1305 </p>
1306 </li>
1307 <li>
1309 <em>%b</em>: body
1310 </p>
1311 </li>
1312 <li>
1314 <em>%Cred</em>: switch color to red
1315 </p>
1316 </li>
1317 <li>
1319 <em>%Cgreen</em>: switch color to green
1320 </p>
1321 </li>
1322 <li>
1324 <em>%Cblue</em>: switch color to blue
1325 </p>
1326 </li>
1327 <li>
1329 <em>%Creset</em>: reset color
1330 </p>
1331 </li>
1332 <li>
1334 <em>%C(&#8230;)</em>: color specification, as described in color.branch.* config option
1335 </p>
1336 </li>
1337 <li>
1339 <em>%m</em>: left, right or boundary mark
1340 </p>
1341 </li>
1342 <li>
1344 <em>%n</em>: newline
1345 </p>
1346 </li>
1347 <li>
1349 <em>%x00</em>: print a byte from a hex code
1350 </p>
1351 </li>
1352 </ul></div>
1353 </li>
1354 <li>
1356 <em>tformat:</em>
1357 </p>
1358 <div class="para"><p>The <em>tformat:</em> format works exactly like <em>format:</em>, except that it
1359 provides "terminator" semantics instead of "separator" semantics. In
1360 other words, each commit has the message terminator character (usually a
1361 newline) appended, rather than a separator placed between entries.
1362 This means that the final entry of a single-line format will be properly
1363 terminated with a new line, just as the "oneline" format does.
1364 For example:</p></div>
1365 <div class="listingblock">
1366 <div class="content">
1367 <pre><tt>$ git log -2 --pretty=format:%h 4da45bef \
1368 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1369 4da45be
1370 7134973 -- NO NEWLINE
1372 $ git log -2 --pretty=tformat:%h 4da45bef \
1373 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
1374 4da45be
1375 7134973</tt></pre>
1376 </div></div>
1377 <div class="para"><p>In addition, any unrecognized string that has a <tt>%</tt> in it is interpreted
1378 as if it has <tt>tformat:</tt> in front of it. For example, these two are
1379 equivalent:</p></div>
1380 <div class="listingblock">
1381 <div class="content">
1382 <pre><tt>$ git log -2 --pretty=tformat:%h 4da45bef
1383 $ git log -2 --pretty=%h 4da45bef</tt></pre>
1384 </div></div>
1385 </li>
1386 </ul></div>
1387 </div>
1388 <h2 id="_limiting_output">Limiting Output</h2>
1389 <div class="sectionbody">
1390 <div class="para"><p>If you're only interested in differences in a subset of files, for
1391 example some architecture-specific files, you might do:</p></div>
1392 <div class="literalblock">
1393 <div class="content">
1394 <pre><tt>git diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; arch/ia64 include/asm-ia64</tt></pre>
1395 </div></div>
1396 <div class="para"><p>and it will only show you what changed in those two directories.</p></div>
1397 <div class="para"><p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p></div>
1398 <div class="literalblock">
1399 <div class="content">
1400 <pre><tt>git diff-tree -r &lt;tree-ish&gt; &lt;tree-ish&gt; kernel/sched.c</tt></pre>
1401 </div></div>
1402 <div class="para"><p>and it will ignore all differences to other files.</p></div>
1403 <div class="para"><p>The pattern is always the prefix, and is matched exactly. There are no
1404 wildcards. Even stricter, it has to match a complete path component.
1405 I.e. "foo" does not pick up <tt>foobar.h</tt>. "foo" does match <tt>foo/bar.h</tt>
1406 so it can be used to name subdirectories.</p></div>
1407 <div class="para"><p>An example of normal usage is:</p></div>
1408 <div class="literalblock">
1409 <div class="content">
1410 <pre><tt>torvalds@ppc970:~/git&gt; git diff-tree 5319e4......
1411 *100664-&gt;100664 blob ac348b.......-&gt;a01513....... git-fsck-objects.c</tt></pre>
1412 </div></div>
1413 <div class="para"><p>which tells you that the last commit changed just one file (it's from
1414 this one:</p></div>
1415 <div class="listingblock">
1416 <div class="content">
1417 <pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1418 tree 5319e4d609cdd282069cc4dce33c1db559539b03
1419 parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1420 author Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1421 committer Linus Torvalds &lt;torvalds@ppc970.osdl.org&gt; Sat Apr 9 12:02:30 2005
1423 Make "git-fsck-objects" print out all the root commits it finds.
1425 Once I do the reference tracking, I'll also make it print out all the
1426 HEAD commits it finds, which is even more interesting.</tt></pre>
1427 </div></div>
1428 <div class="para"><p>in case you care).</p></div>
1429 </div>
1430 <h2 id="_output_format">Output format</h2>
1431 <div class="sectionbody">
1432 <div class="para"><p>The output format from "git-diff-index", "git-diff-tree",
1433 "git-diff-files" and "git diff --raw" are very similar.</p></div>
1434 <div class="para"><p>These commands all compare two sets of things; what is
1435 compared differs:</p></div>
1436 <div class="vlist"><dl>
1437 <dt>
1438 git-diff-index &lt;tree-ish&gt;
1439 </dt>
1440 <dd>
1442 compares the &lt;tree-ish&gt; and the files on the filesystem.
1443 </p>
1444 </dd>
1445 <dt>
1446 git-diff-index --cached &lt;tree-ish&gt;
1447 </dt>
1448 <dd>
1450 compares the &lt;tree-ish&gt; and the index.
1451 </p>
1452 </dd>
1453 <dt>
1454 git-diff-tree [-r] &lt;tree-ish-1&gt; &lt;tree-ish-2&gt; [&lt;pattern&gt;&#8230;]
1455 </dt>
1456 <dd>
1458 compares the trees named by the two arguments.
1459 </p>
1460 </dd>
1461 <dt>
1462 git-diff-files [&lt;pattern&gt;&#8230;]
1463 </dt>
1464 <dd>
1466 compares the index and the files on the filesystem.
1467 </p>
1468 </dd>
1469 </dl></div>
1470 <div class="para"><p>An output line is formatted this way:</p></div>
1471 <div class="listingblock">
1472 <div class="content">
1473 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1474 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1475 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1476 create :000000 100644 0000000... 1234567... A file4
1477 delete :100644 000000 1234567... 0000000... D file5
1478 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1479 </div></div>
1480 <div class="para"><p>That is, from the left to the right:</p></div>
1481 <div class="olist"><ol>
1482 <li>
1484 a colon.
1485 </p>
1486 </li>
1487 <li>
1489 mode for "src"; 000000 if creation or unmerged.
1490 </p>
1491 </li>
1492 <li>
1494 a space.
1495 </p>
1496 </li>
1497 <li>
1499 mode for "dst"; 000000 if deletion or unmerged.
1500 </p>
1501 </li>
1502 <li>
1504 a space.
1505 </p>
1506 </li>
1507 <li>
1509 sha1 for "src"; 0{40} if creation or unmerged.
1510 </p>
1511 </li>
1512 <li>
1514 a space.
1515 </p>
1516 </li>
1517 <li>
1519 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
1520 </p>
1521 </li>
1522 <li>
1524 a space.
1525 </p>
1526 </li>
1527 <li>
1529 status, followed by optional "score" number.
1530 </p>
1531 </li>
1532 <li>
1534 a tab or a NUL when <em>-z</em> option is used.
1535 </p>
1536 </li>
1537 <li>
1539 path for "src"
1540 </p>
1541 </li>
1542 <li>
1544 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1545 </p>
1546 </li>
1547 <li>
1549 path for "dst"; only exists for C or R.
1550 </p>
1551 </li>
1552 <li>
1554 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1555 </p>
1556 </li>
1557 </ol></div>
1558 <div class="para"><p>Possible status letters are:</p></div>
1559 <div class="ilist"><ul>
1560 <li>
1562 A: addition of a file
1563 </p>
1564 </li>
1565 <li>
1567 C: copy of a file into a new one
1568 </p>
1569 </li>
1570 <li>
1572 D: deletion of a file
1573 </p>
1574 </li>
1575 <li>
1577 M: modification of the contents or mode of a file
1578 </p>
1579 </li>
1580 <li>
1582 R: renaming of a file
1583 </p>
1584 </li>
1585 <li>
1587 T: change in the type of the file
1588 </p>
1589 </li>
1590 <li>
1592 U: file is unmerged (you must complete the merge before it can
1593 be committed)
1594 </p>
1595 </li>
1596 <li>
1598 X: "unknown" change type (most probably a bug, please report it)
1599 </p>
1600 </li>
1601 </ul></div>
1602 <div class="para"><p>Status letters C and R are always followed by a score (denoting the
1603 percentage of similarity between the source and target of the move or
1604 copy), and are the only ones to be so.</p></div>
1605 <div class="para"><p>&lt;sha1&gt; is shown as all 0's if a file is new on the filesystem
1606 and it is out of sync with the index.</p></div>
1607 <div class="para"><p>Example:</p></div>
1608 <div class="listingblock">
1609 <div class="content">
1610 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
1611 </div></div>
1612 <div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
1613 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
1614 respectively.</p></div>
1615 </div>
1616 <h2 id="_diff_format_for_merges">diff format for merges</h2>
1617 <div class="sectionbody">
1618 <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw"
1619 can take <em>-c</em> or <em>--cc</em> option
1620 to generate diff output also for merge commits. The output differs
1621 from the format described above in the following way:</p></div>
1622 <div class="olist"><ol>
1623 <li>
1625 there is a colon for each parent
1626 </p>
1627 </li>
1628 <li>
1630 there are more "src" modes and "src" sha1
1631 </p>
1632 </li>
1633 <li>
1635 status is concatenated status characters for each parent
1636 </p>
1637 </li>
1638 <li>
1640 no optional "score" number
1641 </p>
1642 </li>
1643 <li>
1645 single path, only for "dst"
1646 </p>
1647 </li>
1648 </ol></div>
1649 <div class="para"><p>Example:</p></div>
1650 <div class="listingblock">
1651 <div class="content">
1652 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
1653 </div></div>
1654 <div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from
1655 all parents.</p></div>
1656 </div>
1657 <h2 id="_generating_patches_with_p">Generating patches with -p</h2>
1658 <div class="sectionbody">
1659 <div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
1660 with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or
1661 "git log" with the "-p" option, they
1662 do not produce the output described above; instead they produce a
1663 patch file. You can customize the creation of such patches via the
1664 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
1665 <div class="para"><p>What the -p option produces is slightly different from the traditional
1666 diff format.</p></div>
1667 <div class="olist"><ol>
1668 <li>
1670 It is preceded with a "git diff" header, that looks like
1671 this:
1672 </p>
1673 <div class="literalblock">
1674 <div class="content">
1675 <pre><tt>diff --git a/file1 b/file2</tt></pre>
1676 </div></div>
1677 <div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
1678 involved. Especially, even for a creation or a deletion,
1679 <tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
1680 <div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
1681 name of the source file of the rename/copy and the name of
1682 the file that rename/copy produces, respectively.</p></div>
1683 </li>
1684 <li>
1686 It is followed by one or more extended header lines:
1687 </p>
1688 <div class="literalblock">
1689 <div class="content">
1690 <pre><tt>old mode &lt;mode&gt;
1691 new mode &lt;mode&gt;
1692 deleted file mode &lt;mode&gt;
1693 new file mode &lt;mode&gt;
1694 copy from &lt;path&gt;
1695 copy to &lt;path&gt;
1696 rename from &lt;path&gt;
1697 rename to &lt;path&gt;
1698 similarity index &lt;number&gt;
1699 dissimilarity index &lt;number&gt;
1700 index &lt;hash&gt;..&lt;hash&gt; &lt;mode&gt;</tt></pre>
1701 </div></div>
1702 </li>
1703 <li>
1705 TAB, LF, double quote and backslash characters in pathnames
1706 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively.
1707 If there is need for such substitution then the whole
1708 pathname is put in double quotes.
1709 </p>
1710 </li>
1711 </ol></div>
1712 <div class="para"><p>The similarity index is the percentage of unchanged lines, and
1713 the dissimilarity index is the percentage of changed lines. It
1714 is a rounded down integer, followed by a percent sign. The
1715 similarity index value of 100% is thus reserved for two equal
1716 files, while 100% dissimilarity means that no line from the old
1717 file made it into the new one.</p></div>
1718 </div>
1719 <h2 id="_combined_diff_format">combined diff format</h2>
1720 <div class="sectionbody">
1721 <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or
1722 <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit
1723 with "git log -p", this is the default format.
1724 A <em>combined diff</em> format looks like this:</p></div>
1725 <div class="listingblock">
1726 <div class="content">
1727 <pre><tt>diff --combined describe.c
1728 index fabadb8,cc95eb0..4866510
1729 --- a/describe.c
1730 +++ b/describe.c
1731 @@@ -98,20 -98,12 +98,20 @@@
1732 return (a_date &gt; b_date) ? -1 : (a_date == b_date) ? 0 : 1;
1735 - static void describe(char *arg)
1736 -static void describe(struct commit *cmit, int last_one)
1737 ++static void describe(char *arg, int last_one)
1739 + unsigned char sha1[20];
1740 + struct commit *cmit;
1741 struct commit_list *list;
1742 static int initialized = 0;
1743 struct commit_name *n;
1745 + if (get_sha1(arg, sha1) &lt; 0)
1746 + usage(describe_usage);
1747 + cmit = lookup_commit_reference(sha1);
1748 + if (!cmit)
1749 + usage(describe_usage);
1751 if (!initialized) {
1752 initialized = 1;
1753 for_each_ref(get_name);</tt></pre>
1754 </div></div>
1755 <div class="olist"><ol>
1756 <li>
1758 It is preceded with a "git diff" header, that looks like
1759 this (when <em>-c</em> option is used):
1760 </p>
1761 <div class="literalblock">
1762 <div class="content">
1763 <pre><tt>diff --combined file</tt></pre>
1764 </div></div>
1765 <div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div>
1766 <div class="literalblock">
1767 <div class="content">
1768 <pre><tt>diff --cc file</tt></pre>
1769 </div></div>
1770 </li>
1771 <li>
1773 It is followed by one or more extended header lines
1774 (this example shows a merge with two parents):
1775 </p>
1776 <div class="literalblock">
1777 <div class="content">
1778 <pre><tt>index &lt;hash&gt;,&lt;hash&gt;..&lt;hash&gt;
1779 mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;
1780 new file mode &lt;mode&gt;
1781 deleted file mode &lt;mode&gt;,&lt;mode&gt;</tt></pre>
1782 </div></div>
1783 <div class="para"><p>The <tt>mode &lt;mode&gt;,&lt;mode&gt;..&lt;mode&gt;</tt> line appears only if at least one of
1784 the &lt;mode&gt; is different from the rest. Extended headers with
1785 information about detected contents movement (renames and
1786 copying detection) are designed to work with diff of two
1787 &lt;tree-ish&gt; and are not used by combined diff format.</p></div>
1788 </li>
1789 <li>
1791 It is followed by two-line from-file/to-file header
1792 </p>
1793 <div class="literalblock">
1794 <div class="content">
1795 <pre><tt>--- a/file
1796 +++ b/file</tt></pre>
1797 </div></div>
1798 <div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff
1799 format, <tt>/dev/null</tt> is used to signal created or deleted
1800 files.</p></div>
1801 </li>
1802 <li>
1804 Chunk header format is modified to prevent people from
1805 accidentally feeding it to <tt>patch -p1</tt>. Combined diff format
1806 was created for review of merge commit changes, and was not
1807 meant for apply. The change is similar to the change in the
1808 extended <em>index</em> header:
1809 </p>
1810 <div class="literalblock">
1811 <div class="content">
1812 <pre><tt>@@@ &lt;from-file-range&gt; &lt;from-file-range&gt; &lt;to-file-range&gt; @@@</tt></pre>
1813 </div></div>
1814 <div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk
1815 header for combined diff format.</p></div>
1816 </li>
1817 </ol></div>
1818 <div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two
1819 files A and B with a single column that has <tt>-</tt> (minus &#8212;
1820 appears in A but removed in B), <tt>+</tt> (plus &#8212; missing in A but
1821 added to B), or <tt>" "</tt> (space &#8212; unchanged) prefix, this format
1822 compares two or more files file1, file2,&#8230; with one file X, and
1823 shows how X differs from each of fileN. One column for each of
1824 fileN is prepended to the output line to note how X's line is
1825 different from it.</p></div>
1826 <div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in
1827 fileN but it does not appear in the result. A <tt>+</tt> character
1828 in the column N means that the line appears in the result,
1829 and fileN does not have that line (in other words, the line was
1830 added, from the point of view of that parent).</p></div>
1831 <div class="para"><p>In the above example output, the function signature was changed
1832 from both files (hence two <tt>-</tt> removals from both file1 and
1833 file2, plus <tt>++</tt> to mean one line that was added does not appear
1834 in either file1 nor file2). Also eight other lines are the same
1835 from file1 but do not appear in file2 (hence prefixed with <tt>&#43;</tt>).</p></div>
1836 <div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a
1837 merge commit with the merge result (i.e. file1..fileN are the
1838 parents). When shown by <tt>git diff-files -c</tt>, it compares the
1839 two unresolved merge parents with the working tree file
1840 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
1841 "their version").</p></div>
1842 </div>
1843 <h2 id="_other_diff_formats">other diff formats</h2>
1844 <div class="sectionbody">
1845 <div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and
1846 copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the
1847 output. These options can be combined with other options, such as
1848 <tt>-p</tt>, and are meant for human consumption.</p></div>
1849 <div class="para"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output
1850 formats the pathnames compactly by combining common prefix and suffix of
1851 the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to
1852 <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div>
1853 <div class="listingblock">
1854 <div class="content">
1855 <pre><tt>arch/{i386 =&gt; x86}/Makefile | 4 +--</tt></pre>
1856 </div></div>
1857 <div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed
1858 for easier machine consumption. An entry in <tt>--numstat</tt> output looks
1859 like this:</p></div>
1860 <div class="listingblock">
1861 <div class="content">
1862 <pre><tt>1 2 README
1863 3 1 arch/{i386 =&gt; x86}/Makefile</tt></pre>
1864 </div></div>
1865 <div class="para"><p>That is, from left to right:</p></div>
1866 <div class="olist"><ol>
1867 <li>
1869 the number of added lines;
1870 </p>
1871 </li>
1872 <li>
1874 a tab;
1875 </p>
1876 </li>
1877 <li>
1879 the number of deleted lines;
1880 </p>
1881 </li>
1882 <li>
1884 a tab;
1885 </p>
1886 </li>
1887 <li>
1889 pathname (possibly with rename/copy information);
1890 </p>
1891 </li>
1892 <li>
1894 a newline.
1895 </p>
1896 </li>
1897 </ol></div>
1898 <div class="para"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div>
1899 <div class="listingblock">
1900 <div class="content">
1901 <pre><tt>1 2 README NUL
1902 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre>
1903 </div></div>
1904 <div class="para"><p>That is:</p></div>
1905 <div class="olist"><ol>
1906 <li>
1908 the number of added lines;
1909 </p>
1910 </li>
1911 <li>
1913 a tab;
1914 </p>
1915 </li>
1916 <li>
1918 the number of deleted lines;
1919 </p>
1920 </li>
1921 <li>
1923 a tab;
1924 </p>
1925 </li>
1926 <li>
1928 a NUL (only exists if renamed/copied);
1929 </p>
1930 </li>
1931 <li>
1933 pathname in preimage;
1934 </p>
1935 </li>
1936 <li>
1938 a NUL (only exists if renamed/copied);
1939 </p>
1940 </li>
1941 <li>
1943 pathname in postimage (only exists if renamed/copied);
1944 </p>
1945 </li>
1946 <li>
1948 a NUL.
1949 </p>
1950 </li>
1951 </ol></div>
1952 <div class="para"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow
1953 scripts that read the output to tell if the current record being read is
1954 a single-path record or a rename/copy record without reading ahead.
1955 After reading added and deleted lines, reading up to <tt>NUL</tt> would yield
1956 the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div>
1957 </div>
1958 <h2 id="_author">Author</h2>
1959 <div class="sectionbody">
1960 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
1961 </div>
1962 <h2 id="_documentation">Documentation</h2>
1963 <div class="sectionbody">
1964 <div class="para"><p>Documentation by David Greaves, Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
1965 </div>
1966 <h2 id="_git">GIT</h2>
1967 <div class="sectionbody">
1968 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1969 </div>
1970 <div id="footer">
1971 <div id="footer-text">
1972 Last updated 2009-07-01 02:30:48 UTC
1973 </div>
1974 </div>
1975 </body>
1976 </html>