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">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.4.5" />
7 <title>git-diff-tree(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-diff-tree(
1) Manual Page
409 <div class=
"sectionbody">
411 Compares the content and mode of blobs found via two tree objects
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git diff-tree
</em> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
419 [-t] [-r] [-c | --cc] [--root] [
<common diff options
>]
420 <tree-ish
> [
<tree-ish
>] [
<path
>…]
</div>
421 <div class=
"verseblock-attribution">
424 <h2 id=
"_description">DESCRIPTION
</h2>
425 <div class=
"sectionbody">
426 <div class=
"paragraph"><p>Compares the content and mode of the blobs found via two tree objects.
</p></div>
427 <div class=
"paragraph"><p>If there is only one
<tree-ish
> given, the commit is compared with its parents
428 (see --stdin below).
</p></div>
429 <div class=
"paragraph"><p>Note that
<em>git diff-tree
</em> can use the tree encapsulated in a commit object.
</p></div>
431 <h2 id=
"_options">OPTIONS
</h2>
432 <div class=
"sectionbody">
433 <div class=
"dlist"><dl>
445 Generate patch (see section on generating patches).
457 Generate diffs with
<n
> lines of context instead of
467 Generate the raw format.
476 Synonym for
<tt>-p --raw
</tt>.
484 Generate a diff using the
"patience diff" algorithm.
488 --stat[=
<width
>[,
<name-width
>]]
492 Generate a diffstat. You can override the default
493 output width for
80-column terminal by
<tt>--stat=
<width
></tt>.
494 The width of the filename part can be controlled by
495 giving another width to it separated by a comma.
503 Similar to
<tt>--stat
</tt>, but shows number of added and
504 deleted lines in decimal notation and pathname without
505 abbreviation, to make it more machine friendly. For
506 binary files, outputs two
<tt>-
</tt> instead of saying
515 Output only the last line of the
<tt>--stat
</tt> format containing total
516 number of modified files, as well as number of added and deleted
521 --dirstat[=
<param1,param2,
…>]
525 Output the distribution of relative amount of changes for each
526 sub-directory. The behavior of
<tt>--dirstat
</tt> can be customized by
527 passing it a comma separated list of parameters.
528 The defaults are controlled by the
<tt>diff.dirstat
</tt> configuration
529 variable (see
<a href=
"git-config.html">git-config(
1)
</a>).
530 The following parameters are available:
532 <div class=
"dlist"><dl>
538 Compute the dirstat numbers by counting the lines that have been
539 removed from the source, or added to the destination. This ignores
540 the amount of pure code movements within a file. In other words,
541 rearranging lines in a file is not counted as much as other changes.
542 This is the default behavior when no parameter is given.
550 Compute the dirstat numbers by doing the regular line-based diff
551 analysis, and summing the removed/added line counts. (For binary
552 files, count
64-byte chunks instead, since binary files have no
553 natural concept of lines). This is a more expensive
<tt>--dirstat
</tt>
554 behavior than the
<tt>changes
</tt> behavior, but it does count rearranged
555 lines within a file as much as other changes. The resulting output
556 is consistent with what you get from the other
<tt>--*stat
</tt> options.
564 Compute the dirstat numbers by counting the number of files changed.
565 Each changed file counts equally in the dirstat analysis. This is
566 the computationally cheapest
<tt>--dirstat
</tt> behavior, since it does
567 not have to look at the file contents at all.
575 Count changes in a child directory for the parent directory as well.
576 Note that when using
<tt>cumulative
</tt>, the sum of the percentages
577 reported may exceed
100%. The default (non-cumulative) behavior can
578 be specified with the
<tt>noncumulative
</tt> parameter.
586 An integer parameter specifies a cut-off percent (
3% by default).
587 Directories contributing less than this percentage of the changes
588 are not shown in the output.
592 <div class=
"paragraph"><p>Example: The following will count changed files, while ignoring
593 directories with less than
10% of the total amount of changed files,
594 and accumulating child directory counts in the parent directories:
595 <tt>--dirstat=files,
10,cumulative
</tt>.
</p></div>
602 Output a condensed summary of extended header information
603 such as creations, renames and mode changes.
611 Synonym for
<tt>-p --stat
</tt>.
619 When
<tt>--raw
</tt>,
<tt>--numstat
</tt>,
<tt>--name-only
</tt> or
<tt>--name-status
</tt> has been
620 given, do not munge pathnames and use NULs as output field terminators.
622 <div class=
"paragraph"><p>Without this option, each pathname output will have TAB, LF, double quotes,
623 and backslash characters replaced with
<tt>\t
</tt>,
<tt>\n
</tt>,
<tt>\
"</tt>, and <tt>\\</tt>,
624 respectively, and the pathname will be enclosed in double quotes if
625 any of those replacements occurred.</p></div>
632 Show only names of changed files.
640 Show only names and status of changed files. See the description
641 of the <tt>--diff-filter</tt> option on what the status letters mean.
645 --submodule[=<format>]
649 Chose the output format for submodule differences. <format> can be one of
650 <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format
651 is used when this option is not given. <em>log</em> is the default value for this
652 option and lists the commits in that commit range like the <em>summary</em>
653 option of <a href="git-submodule.html
">git-submodule(1)</a> does.
657 --color[=<when>]
662 The value must be <tt>always</tt> (the default for <tt><when></tt>), <tt>never</tt>, or <tt>auto</tt>.
663 The default value is <tt>never</tt>.
671 Turn off colored diff.
672 It is the same as <tt>--color=never</tt>.
676 --word-diff[=<mode>]
680 Show a word diff, using the <mode> to delimit changed words.
681 By default, words are delimited by whitespace; see
682 <tt>--word-diff-regex</tt> below. The <mode> defaults to <em>plain</em>, and
685 <div class="dlist
"><dl>
691 Highlight changed words using only colors. Implies <tt>--color</tt>.
699 Show words as <tt>[-removed-]</tt> and <tt>{<tt>added</tt>}</tt>. Makes no
700 attempts to escape the delimiters if they appear in the input,
701 so the output may be ambiguous.
709 Use a special line-based format intended for script
710 consumption. Added/removed/unchanged runs are printed in the
711 usual unified diff format, starting with a <tt>+</tt>/<tt>-</tt>/` `
712 character at the beginning of the line and extending to the
713 end of the line. Newlines in the input are represented by a
714 tilde <tt>~</tt> on a line of its own.
722 Disable word diff again.
726 <div class="paragraph
"><p>Note that despite the name of the first mode, color is used to
727 highlight the changed parts in all modes if enabled.</p></div>
730 --word-diff-regex=<regex>
734 Use <regex> to decide what a word is, instead of considering
735 runs of non-whitespace to be a word. Also implies
736 <tt>--word-diff</tt> unless it was already enabled.
738 <div class="paragraph
"><p>Every non-overlapping match of the
739 <regex> is considered a word. Anything between these matches is
740 considered whitespace and ignored(!) for the purposes of finding
741 differences. You may want to append <tt>|[^[:space:]]</tt> to your regular
742 expression to make sure that it matches all non-whitespace characters.
743 A match that contains a newline is silently truncated(!) at the
745 <div class="paragraph
"><p>The regex can also be set via a diff driver or configuration option, see
746 <a href="gitattributes.html
">gitattributes(1)</a> or <a href="git-config.html
">git-config(1)</a>. Giving it explicitly
747 overrides any diff driver or configuration setting. Diff drivers
748 override configuration settings.</p></div>
751 --color-words[=<regex>]
755 Equivalent to <tt>--word-diff=color</tt> plus (if a regex was
756 specified) <tt>--word-diff-regex=<regex></tt>.
764 Turn off rename detection, even when the configuration
765 file gives the default to do so.
773 Warn if changes introduce trailing whitespace
774 or an indent that uses a space before a tab. Exits with
775 non-zero status if problems are found. Not compatible with
784 Instead of the first handful of characters, show the full
785 pre- and post-image blob object names on the "index
"
786 line when generating patch format output.
794 In addition to <tt>--full-index</tt>, output a binary diff that
795 can be applied with <tt>git-apply</tt>.
803 Instead of showing the full 40-byte hexadecimal object
804 name in diff-raw format output and diff-tree header
805 lines, show only a partial prefix. This is
806 independent of the <tt>--full-index</tt> option above, which controls
807 the diff-patch output format. Non default number of
808 digits can be specified with <tt>--abbrev=<n></tt>.
812 -B[<n>][/<m>]
815 --break-rewrites[=[<n>][/<m>]]
819 Break complete rewrite changes into pairs of delete and
820 create. This serves two purposes:
822 <div class="paragraph
"><p>It affects the way a change that amounts to a total rewrite of a file
823 not as a series of deletion and insertion mixed together with a very
824 few lines that happen to match textually as the context, but as a
825 single deletion of everything old followed by a single insertion of
826 everything new, and the number <tt>m</tt> controls this aspect of the -B
827 option (defaults to 60%). <tt>-B/70%</tt> specifies that less than 30% of the
828 original should remain in the result for git to consider it a total
829 rewrite (i.e. otherwise the resulting patch will be a series of
830 deletion and insertion mixed together with context lines).</p></div>
831 <div class="paragraph
"><p>When used with -M, a totally-rewritten file is also considered as the
832 source of a rename (usually -M only considers a file that disappeared
833 as the source of a rename), and the number <tt>n</tt> controls this aspect of
834 the -B option (defaults to 50%). <tt>-B20%</tt> specifies that a change with
835 addition and deletion compared to 20% or more of the file’s size are
836 eligible for being picked up as a possible source of a rename to
837 another file.</p></div>
843 --find-renames[=<n>]
848 If <tt>n</tt> is specified, it is a threshold on the similarity
849 index (i.e. amount of addition/deletions compared to the
850 file’s size). For example, <tt>-M90%</tt> means git should consider a
851 delete/add pair to be a rename if more than 90% of the file
852 hasn’t changed.
859 --find-copies[=<n>]
863 Detect copies as well as renames. See also <tt>--find-copies-harder</tt>.
864 If <tt>n</tt> is specified, it has the same meaning as for <tt>-M<n></tt>.
872 For performance reasons, by default, <tt>-C</tt> option finds copies only
873 if the original file of the copy was modified in the same
874 changeset. This flag makes the command
875 inspect unmodified files as candidates for the source of
876 copy. This is a very expensive operation for large
877 projects, so use it with caution. Giving more than one
878 <tt>-C</tt> option has the same effect.
885 --irreversible-delete
889 Omit the preimage for deletes, i.e. print only the header but not
890 the diff between the preimage and <tt>/dev/null</tt>. The resulting patch
891 is not meant to be applied with <tt>patch</tt> nor <tt>git apply</tt>; this is
892 solely for people who want to just concentrate on reviewing the
893 text after the change. In addition, the output obviously lack
894 enough information to apply such a patch in reverse, even manually,
895 hence the name of the option.
897 <div class="paragraph
"><p>When used together with <tt>-B</tt>, omit also the preimage in the deletion part
898 of a delete/create pair.</p></div>
905 The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n
906 is the number of potential rename/copy targets. This
907 option prevents rename/copy detection from running if
908 the number of rename/copy targets exceeds the specified
913 --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
917 Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>),
918 Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their
919 type (i.e. regular file, symlink, submodule, …) changed (<tt>T</tt>),
920 are Unmerged (<tt>U</tt>), are
921 Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>).
922 Any combination of the filter characters (including none) can be used.
923 When <tt>*</tt> (All-or-none) is added to the combination, all
924 paths are selected if there is any file that matches
925 other criteria in the comparison; if there is no file
926 that matches other criteria, nothing is selected.
934 Look for differences that introduce or remove an instance of
935 <string>. Note that this is different than the string simply
936 appearing in diff output; see the <em>pickaxe</em> entry in
937 <a href="gitdiffcore.html
">gitdiffcore(7)</a> for more details.
945 Look for differences whose added or removed line matches
946 the given <regex>.
954 When <tt>-S</tt> or <tt>-G</tt> finds a change, show all the changes in that
955 changeset, not just the files that contain the change
964 Make the <string> not a plain string but an extended POSIX
973 Output the patch in the order specified in the
974 <orderfile>, which has one shell glob pattern per line.
982 Swap two inputs; that is, show differences from index or
983 on-disk file to tree contents.
987 --relative[=<path>]
991 When run from a subdirectory of the project, it can be
992 told to exclude changes outside the directory and show
993 pathnames relative to it with this option. When you are
994 not in a subdirectory (e.g. in a bare repository), you
995 can name which subdirectory to make the output relative
996 to by giving a <path> as an argument.
1002 <dt class="hdlist1
">
1007 Treat all files as text.
1010 <dt class="hdlist1
">
1011 --ignore-space-at-eol
1015 Ignore changes in whitespace at EOL.
1018 <dt class="hdlist1
">
1021 <dt class="hdlist1
">
1022 --ignore-space-change
1026 Ignore changes in amount of whitespace. This ignores whitespace
1027 at line end, and considers all other sequences of one or
1028 more whitespace characters to be equivalent.
1031 <dt class="hdlist1
">
1034 <dt class="hdlist1
">
1039 Ignore whitespace when comparing lines. This ignores
1040 differences even if one line has whitespace where the other
1044 <dt class="hdlist1
">
1045 --inter-hunk-context=<lines>
1049 Show the context between diff hunks, up to the specified number
1050 of lines, thereby fusing hunks that are close to each other.
1053 <dt class="hdlist1
">
1058 Make the program exit with codes similar to diff(1).
1059 That is, it exits with 1 if there were differences and
1060 0 means no differences.
1063 <dt class="hdlist1
">
1068 Disable all output of the program. Implies <tt>--exit-code</tt>.
1071 <dt class="hdlist1
">
1076 Allow an external diff helper to be executed. If you set an
1077 external diff driver with <a href="gitattributes.html
">gitattributes(5)</a>, you need
1078 to use this option with <a href="git-log.html
">git-log(1)</a> and friends.
1081 <dt class="hdlist1
">
1086 Disallow external diff drivers.
1089 <dt class="hdlist1
">
1090 --ignore-submodules[=<when>]
1094 Ignore changes to submodules in the diff generation. <when> can be
1095 either "none
", "untracked
", "dirty
" or "all
", which is the default
1096 Using "none
" will consider the submodule modified when it either contains
1097 untracked or modified files or its HEAD differs from the commit recorded
1098 in the superproject and can be used to override any settings of the
1099 <em>ignore</em> option in <a href="git-config.html
">git-config(1)</a> or <a href="gitmodules.html
">gitmodules(5)</a>. When
1100 "untracked
" is used submodules are not considered dirty when they only
1101 contain untracked content (but they are still scanned for modified
1102 content). Using "dirty
" ignores all changes to the work tree of submodules,
1103 only changes to the commits stored in the superproject are shown (this was
1104 the behavior until 1.7.0). Using "all
" hides all changes to submodules.
1107 <dt class="hdlist1
">
1108 --src-prefix=<prefix>
1112 Show the given source prefix instead of "a/
".
1115 <dt class="hdlist1
">
1116 --dst-prefix=<prefix>
1120 Show the given destination prefix instead of "b/
".
1123 <dt class="hdlist1
">
1128 Do not show any source or destination prefix.
1132 <div class="paragraph
"><p>For more detailed explanation on these common options, see also
1133 <a href="gitdiffcore.html
">gitdiffcore(7)</a>.</p></div>
1134 <div class="dlist
"><dl>
1135 <dt class="hdlist1
">
1140 The id of a tree object.
1143 <dt class="hdlist1
">
1148 If provided, the results are limited to a subset of files
1149 matching one of these prefix strings.
1150 i.e., file matches <tt>/^<pattern1>|<pattern2>|…/</tt>
1151 Note that this parameter does not provide any wildcard or regexp
1155 <dt class="hdlist1
">
1160 recurse into sub-trees
1163 <dt class="hdlist1
">
1168 show tree entry itself as well as subtrees. Implies -r.
1171 <dt class="hdlist1
">
1176 When <em>--root</em> is specified the initial commit will be shown as a big
1177 creation event. This is equivalent to a diff against the NULL tree.
1180 <dt class="hdlist1
">
1185 When <em>--stdin</em> is specified, the command does not take
1186 <tree-ish> arguments from the command line. Instead, it
1187 reads lines containing either two <tree>, one <commit>, or a
1188 list of <commit> from its standard input. (Use a single space
1191 <div class="paragraph
"><p>When two trees are given, it compares the first tree with the second.
1192 When a single commit is given, it compares the commit with its
1193 parents. The remaining commits, when given, are used as if they are
1194 parents of the first commit.</p></div>
1195 <div class="paragraph
"><p>When comparing two trees, the ID of both trees (separated by a space
1196 and terminated by a newline) is printed before the difference. When
1197 comparing commits, the ID of the first (or only) commit, followed by a
1198 newline, is printed.</p></div>
1199 <div class="paragraph
"><p>The following flags further affect the behavior when comparing
1200 commits (but not trees).</p></div>
1202 <dt class="hdlist1
">
1207 By default, <em>git diff-tree --stdin</em> does not show
1208 differences for merge commits. With this flag, it shows
1209 differences to that commit from all of its parents. See
1213 <dt class="hdlist1
">
1218 By default, <em>git diff-tree --stdin</em> shows differences,
1219 either in machine-readable form (without <em>-p</em>) or in patch
1220 form (with <em>-p</em>). This output can be suppressed. It is
1221 only useful with <em>-v</em> flag.
1224 <dt class="hdlist1
">
1229 This flag causes <em>git diff-tree --stdin</em> to also show
1230 the commit message before the differences.
1233 <dt class="hdlist1
">
1234 --pretty[=<format>]
1236 <dt class="hdlist1
">
1237 --format=<format>
1241 Pretty-print the contents of the commit logs in a given format,
1242 where <em><format></em> can be one of <em>oneline</em>, <em>short</em>, <em>medium</em>,
1243 <em>full</em>, <em>fuller</em>, <em>email</em>, <em>raw</em> and <em>format:<string></em>. See
1244 the "PRETTY FORMATS
" section for some additional details for each
1245 format. When omitted, the format defaults to <em>medium</em>.
1247 <div class="paragraph
"><p>Note: you can specify the default pretty format in the repository
1248 configuration (see <a href="git-config.html
">git-config(1)</a>).</p></div>
1250 <dt class="hdlist1
">
1255 Instead of showing the full 40-byte hexadecimal commit object
1256 name, show only a partial prefix. Non default number of
1257 digits can be specified with "--abbrev=
<n
>" (which also modifies
1258 diff output, if it is displayed).
1260 <div class="paragraph
"><p>This should make "--pretty=oneline
" a whole lot more readable for
1261 people using 80-column terminals.</p></div>
1263 <dt class="hdlist1
">
1268 Show the full 40-byte hexadecimal commit object name. This negates
1269 <tt>--abbrev-commit</tt> and those options which imply it such as
1270 "--oneline
". It also overrides the <em>log.abbrevCommit</em> variable.
1273 <dt class="hdlist1
">
1278 This is a shorthand for "--pretty=oneline --abbrev-commit
"
1282 <dt class="hdlist1
">
1283 --encoding[=<encoding>]
1287 The commit objects record the encoding used for the log message
1288 in their encoding header; this option can be used to tell the
1289 command to re-code the commit log message in the encoding
1290 preferred by the user. For non plumbing commands this
1294 <dt class="hdlist1
">
1295 --notes[=<ref>]
1299 Show the notes (see <a href="git-notes.html
">git-notes(1)</a>) that annotate the
1300 commit, when showing the commit log message. This is the default
1301 for <tt>git log</tt>, <tt>git show</tt> and <tt>git whatchanged</tt> commands when
1302 there is no <tt>--pretty</tt>, <tt>--format</tt> nor <tt>--oneline</tt> option given
1303 on the command line.
1305 <div class="paragraph
"><p>By default, the notes shown are from the notes refs listed in the
1306 <em>core.notesRef</em> and <em>notes.displayRef</em> variables (or corresponding
1307 environment overrides). See <a href="git-config.html
">git-config(1)</a> for more details.</p></div>
1308 <div class="paragraph
"><p>With an optional <em><ref></em> argument, show this notes ref instead of the
1309 default notes ref(s). The ref is taken to be in <tt>refs/notes/</tt> if it
1310 is not qualified.</p></div>
1311 <div class="paragraph
"><p>Multiple --notes options can be combined to control which notes are
1312 being displayed. Examples: "--notes=foo
" will show only notes from
1313 "refs/notes/foo
"; "--notes=foo --notes
" will show both notes from
1314 "refs/notes/foo
" and from the default notes ref(s).</p></div>
1316 <dt class="hdlist1
">
1321 Do not show notes. This negates the above <tt>--notes</tt> option, by
1322 resetting the list of notes refs from which notes are shown.
1323 Options are parsed in the order given on the command line, so e.g.
1324 "--notes --notes=foo --no-notes --notes=bar
" will only show notes
1325 from "refs/notes/bar
".
1328 <dt class="hdlist1
">
1329 --show-notes[=<ref>]
1331 <dt class="hdlist1
">
1332 --[no-]standard-notes
1336 These options are deprecated. Use the above --notes/--no-notes
1340 <dt class="hdlist1
">
1345 <em>git diff-tree</em> outputs a line with the commit ID when
1346 applicable. This flag suppressed the commit ID output.
1349 <dt class="hdlist1
">
1354 This flag changes the way a merge commit is displayed
1355 (which means it is useful only when the command is given
1356 one <tree-ish>, or <em>--stdin</em>). It shows the differences
1357 from each of the parents to the merge result simultaneously
1358 instead of showing pairwise diff between a parent and the
1359 result one at a time (which is what the <em>-m</em> option does).
1360 Furthermore, it lists only files which were modified
1364 <dt class="hdlist1
">
1369 This flag changes the way a merge commit patch is displayed,
1370 in a similar way to the <em>-c</em> option. It implies the <em>-c</em>
1371 and <em>-p</em> options and further compresses the patch output
1372 by omitting uninteresting hunks whose the contents in the parents
1373 have only two variants and the merge result picks one of them
1374 without modification. When all hunks are uninteresting, the commit
1375 itself and the commit log message is not shown, just like in any other
1379 <dt class="hdlist1
">
1384 Show the commit itself and the commit log message even
1385 if the diff itself is empty.
1390 <h2 id="_pretty_formats
">PRETTY FORMATS</h2>
1391 <div class="sectionbody
">
1392 <div class="paragraph
"><p>If the commit is a merge, and if the pretty-format
1393 is not <em>oneline</em>, <em>email</em> or <em>raw</em>, an additional line is
1394 inserted before the <em>Author:</em> line. This line begins with
1395 "Merge:
" and the sha1s of ancestral commits are printed,
1396 separated by spaces. Note that the listed commits may not
1397 necessarily be the list of the <strong>direct</strong> parent commits if you
1398 have limited your view of history: for example, if you are
1399 only interested in changes related to a certain directory or
1401 <div class="paragraph
"><p>There are several built-in formats, and you can define
1402 additional formats by setting a pretty.<name>
1403 config option to either another format name, or a
1404 <em>format:</em> string, as described below (see
1405 <a href="git-config.html
">git-config(1)</a>). Here are the details of the
1406 built-in formats:</p></div>
1407 <div class="ulist
"><ul>
1412 <div class="literalblock
">
1413 <div class="content
">
1414 <pre><tt><sha1> <title line></tt></pre>
1416 <div class="paragraph
"><p>This is designed to be as compact as possible.</p></div>
1422 <div class="literalblock
">
1423 <div class="content
">
1424 <pre><tt>commit <sha1>
1425 Author: <author></tt></pre>
1427 <div class="literalblock
">
1428 <div class="content
">
1429 <pre><tt><title line></tt></pre>
1436 <div class="literalblock
">
1437 <div class="content
">
1438 <pre><tt>commit <sha1>
1439 Author: <author>
1440 Date: <author date></tt></pre>
1442 <div class="literalblock
">
1443 <div class="content
">
1444 <pre><tt><title line></tt></pre>
1446 <div class="literalblock
">
1447 <div class="content
">
1448 <pre><tt><full commit message></tt></pre>
1455 <div class="literalblock
">
1456 <div class="content
">
1457 <pre><tt>commit <sha1>
1458 Author: <author>
1459 Commit: <committer></tt></pre>
1461 <div class="literalblock
">
1462 <div class="content
">
1463 <pre><tt><title line></tt></pre>
1465 <div class="literalblock
">
1466 <div class="content
">
1467 <pre><tt><full commit message></tt></pre>
1474 <div class="literalblock
">
1475 <div class="content
">
1476 <pre><tt>commit <sha1>
1477 Author: <author>
1478 AuthorDate: <author date>
1479 Commit: <committer>
1480 CommitDate: <committer date></tt></pre>
1482 <div class="literalblock
">
1483 <div class="content
">
1484 <pre><tt><title line></tt></pre>
1486 <div class="literalblock
">
1487 <div class="content
">
1488 <pre><tt><full commit message></tt></pre>
1495 <div class="literalblock
">
1496 <div class="content
">
1497 <pre><tt>From <sha1> <date>
1498 From: <author>
1499 Date: <author date>
1500 Subject: [PATCH] <title line></tt></pre>
1502 <div class="literalblock
">
1503 <div class="content
">
1504 <pre><tt><full commit message></tt></pre>
1511 <div class="paragraph
"><p>The <em>raw</em> format shows the entire commit exactly as
1512 stored in the commit object. Notably, the SHA1s are
1513 displayed in full, regardless of whether --abbrev or
1514 --no-abbrev are used, and <em>parents</em> information show the
1515 true parent commits, without taking grafts nor history
1516 simplification into account.</p></div>
1520 <em>format:<string></em>
1522 <div class="paragraph
"><p>The <em>format:<string></em> format allows you to specify which information
1523 you want to show. It works a little bit like printf format,
1524 with the notable exception that you get a newline with <em>%n</em>
1525 instead of <em>\n</em>.</p></div>
1526 <div class="paragraph
"><p>E.g, <em>format:"The author of %h was %an, %ar%nThe title was
>>%s
<<%n
"</em>
1527 would show something like this:</p></div>
1528 <div class="listingblock
">
1529 <div class="content
">
1530 <pre><tt>The author of fe6e0ee was Junio C Hamano, 23 hours ago
1531 The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</tt></pre>
1533 <div class="paragraph
"><p>The placeholders are:</p></div>
1534 <div class="ulist
"><ul>
1537 <em>%H</em>: commit hash
1542 <em>%h</em>: abbreviated commit hash
1547 <em>%T</em>: tree hash
1552 <em>%t</em>: abbreviated tree hash
1557 <em>%P</em>: parent hashes
1562 <em>%p</em>: abbreviated parent hashes
1567 <em>%an</em>: author name
1572 <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>)
1577 <em>%ae</em>: author email
1582 <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>)
1587 <em>%ad</em>: author date (format respects --date= option)
1592 <em>%aD</em>: author date, RFC2822 style
1597 <em>%ar</em>: author date, relative
1602 <em>%at</em>: author date, UNIX timestamp
1607 <em>%ai</em>: author date, ISO 8601 format
1612 <em>%cn</em>: committer name
1617 <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>)
1622 <em>%ce</em>: committer email
1627 <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>)
1632 <em>%cd</em>: committer date
1637 <em>%cD</em>: committer date, RFC2822 style
1642 <em>%cr</em>: committer date, relative
1647 <em>%ct</em>: committer date, UNIX timestamp
1652 <em>%ci</em>: committer date, ISO 8601 format
1657 <em>%d</em>: ref names, like the --decorate option of <a href="git-log.html
">git-log(1)</a>
1662 <em>%e</em>: encoding
1667 <em>%s</em>: subject
1672 <em>%f</em>: sanitized subject line, suitable for a filename
1682 <em>%B</em>: raw body (unwrapped subject and body)
1687 <em>%N</em>: commit notes
1692 <em>%gD</em>: reflog selector, e.g., <tt>refs/stash@{1}</tt>
1697 <em>%gd</em>: shortened reflog selector, e.g., <tt>stash@{1}</tt>
1702 <em>%gs</em>: reflog subject
1707 <em>%Cred</em>: switch color to red
1712 <em>%Cgreen</em>: switch color to green
1717 <em>%Cblue</em>: switch color to blue
1722 <em>%Creset</em>: reset color
1727 <em>%C(…)</em>: color specification, as described in color.branch.* config option
1732 <em>%m</em>: left, right or boundary mark
1737 <em>%n</em>: newline
1742 <em>%%</em>: a raw <em>%</em>
1747 <em>%x00</em>: print a byte from a hex code
1752 <em>%w([<w>[,<i1>[,<i2>]]])</em>: switch line wrapping, like the -w option of
1753 <a href="git-shortlog.html
">git-shortlog(1)</a>.
1759 <div class="admonitionblock
">
1762 <div class="title
">Note</div>
1764 <td class="content
">Some placeholders may depend on other options given to the
1765 revision traversal engine. For example, the <tt>%g*</tt> reflog options will
1766 insert an empty string unless we are traversing reflog entries (e.g., by
1767 <tt>git log -g</tt>). The <tt>%d</tt> placeholder will use the "short
" decoration
1768 format if <tt>--decorate</tt> was not already provided on the command line.</td>
1771 <div class="paragraph
"><p>If you add a <tt>+</tt> (plus sign) after <em>%</em> of a placeholder, a line-feed
1772 is inserted immediately before the expansion if and only if the
1773 placeholder expands to a non-empty string.</p></div>
1774 <div class="paragraph
"><p>If you add a <tt>-</tt> (minus sign) after <em>%</em> of a placeholder, line-feeds that
1775 immediately precede the expansion are deleted if and only if the
1776 placeholder expands to an empty string.</p></div>
1777 <div class="paragraph
"><p>If you add a ` ` (space) after <em>%</em> of a placeholder, a space
1778 is inserted immediately before the expansion if and only if the
1779 placeholder expands to a non-empty string.</p></div>
1780 <div class="ulist
"><ul>
1785 <div class="paragraph
"><p>The <em>tformat:</em> format works exactly like <em>format:</em>, except that it
1786 provides "terminator
" semantics instead of "separator
" semantics. In
1787 other words, each commit has the message terminator character (usually a
1788 newline) appended, rather than a separator placed between entries.
1789 This means that the final entry of a single-line format will be properly
1790 terminated with a new line, just as the "oneline
" format does.
1791 For example:</p></div>
1792 <div class="listingblock
">
1793 <div class="content
">
1794 <pre><tt>$ git log -2 --pretty=format:%h 4da45bef \
1795 | perl -pe '$_ .= " -- NO NEWLINE\n
" unless /\n/'
1797 7134973 -- NO NEWLINE
1799 $ git log -2 --pretty=tformat:%h 4da45bef \
1800 | perl -pe '$_ .= " -- NO NEWLINE\n
" unless /\n/'
1804 <div class="paragraph
"><p>In addition, any unrecognized string that has a <tt>%</tt> in it is interpreted
1805 as if it has <tt>tformat:</tt> in front of it. For example, these two are
1806 equivalent:</p></div>
1807 <div class="listingblock
">
1808 <div class="content
">
1809 <pre><tt>$ git log -2 --pretty=tformat:%h 4da45bef
1810 $ git log -2 --pretty=%h 4da45bef</tt></pre>
1815 <h2 id="_limiting_output
">Limiting Output</h2>
1816 <div class="sectionbody
">
1817 <div class="paragraph
"><p>If you’re only interested in differences in a subset of files, for
1818 example some architecture-specific files, you might do:</p></div>
1819 <div class="literalblock
">
1820 <div class="content
">
1821 <pre><tt>git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64</tt></pre>
1823 <div class="paragraph
"><p>and it will only show you what changed in those two directories.</p></div>
1824 <div class="paragraph
"><p>Or if you are searching for what changed in just <tt>kernel/sched.c</tt>, just do</p></div>
1825 <div class="literalblock
">
1826 <div class="content
">
1827 <pre><tt>git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c</tt></pre>
1829 <div class="paragraph
"><p>and it will ignore all differences to other files.</p></div>
1830 <div class="paragraph
"><p>The pattern is always the prefix, and is matched exactly. There are no
1831 wildcards. Even stricter, it has to match a complete path component.
1832 I.e. "foo
" does not pick up <tt>foobar.h</tt>. "foo
" does match <tt>foo/bar.h</tt>
1833 so it can be used to name subdirectories.</p></div>
1834 <div class="paragraph
"><p>An example of normal usage is:</p></div>
1835 <div class="literalblock
">
1836 <div class="content
">
1837 <pre><tt>torvalds@ppc970:~/git> git diff-tree --abbrev 5319e4
1838 :100664 100664 ac348b... a01513... git-fsck-objects.c</tt></pre>
1840 <div class="paragraph
"><p>which tells you that the last commit changed just one file (it’s from
1842 <div class="listingblock
">
1843 <div class="content
">
1844 <pre><tt>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
1845 tree 5319e4d609cdd282069cc4dce33c1db559539b03
1846 parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
1847 author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
1848 committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
1850 Make "git-fsck-objects
" print out all the root commits it finds.
1852 Once I do the reference tracking, I'll also make it print out all the
1853 HEAD commits it finds, which is even more interesting.</tt></pre>
1855 <div class="paragraph
"><p>in case you care).</p></div>
1857 <h2 id="_raw_output_format
">Raw output format</h2>
1858 <div class="sectionbody
">
1859 <div class="paragraph
"><p>The raw output format from "git-diff-index
", "git-diff-tree
",
1860 "git-diff-files
" and "git diff --raw
" are very similar.</p></div>
1861 <div class="paragraph
"><p>These commands all compare two sets of things; what is
1862 compared differs:</p></div>
1863 <div class="dlist
"><dl>
1864 <dt class="hdlist1
">
1865 git-diff-index <tree-ish>
1869 compares the <tree-ish> and the files on the filesystem.
1872 <dt class="hdlist1
">
1873 git-diff-index --cached <tree-ish>
1877 compares the <tree-ish> and the index.
1880 <dt class="hdlist1
">
1881 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
1885 compares the trees named by the two arguments.
1888 <dt class="hdlist1
">
1889 git-diff-files [<pattern>…]
1893 compares the index and the files on the filesystem.
1897 <div class="paragraph
"><p>The "git-diff-tree
" command begins its output by printing the hash of
1898 what is being compared. After that, all the commands print one output
1899 line per changed file.</p></div>
1900 <div class="paragraph
"><p>An output line is formatted this way:</p></div>
1901 <div class="listingblock
">
1902 <div class="content
">
1903 <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0
1904 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
1905 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
1906 create :000000 100644 0000000... 1234567... A file4
1907 delete :100644 000000 1234567... 0000000... D file5
1908 unmerged :000000 000000 0000000... 0000000... U file6</tt></pre>
1910 <div class="paragraph
"><p>That is, from the left to the right:</p></div>
1911 <div class="olist arabic
"><ol class="arabic
">
1919 mode for "src
"; 000000 if creation or unmerged.
1929 mode for "dst
"; 000000 if deletion or unmerged.
1939 sha1 for "src
"; 0{40} if creation or unmerged.
1949 sha1 for "dst
"; 0{40} if creation, unmerged or "look at work tree
".
1959 status, followed by optional "score
" number.
1964 a tab or a NUL when <em>-z</em> option is used.
1974 a tab or a NUL when <em>-z</em> option is used; only exists for C or R.
1979 path for "dst
"; only exists for C or R.
1984 an LF or a NUL when <em>-z</em> option is used, to terminate the record.
1988 <div class="paragraph
"><p>Possible status letters are:</p></div>
1989 <div class="ulist
"><ul>
1992 A: addition of a file
1997 C: copy of a file into a new one
2002 D: deletion of a file
2007 M: modification of the contents or mode of a file
2012 R: renaming of a file
2017 T: change in the type of the file
2022 U: file is unmerged (you must complete the merge before it can
2028 X: "unknown
" change type (most probably a bug, please report it)
2032 <div class="paragraph
"><p>Status letters C and R are always followed by a score (denoting the
2033 percentage of similarity between the source and target of the move or
2034 copy), and are the only ones to be so.</p></div>
2035 <div class="paragraph
"><p><sha1> is shown as all 0’s if a file is new on the filesystem
2036 and it is out of sync with the index.</p></div>
2037 <div class="paragraph
"><p>Example:</p></div>
2038 <div class="listingblock
">
2039 <div class="content
">
2040 <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre>
2042 <div class="paragraph
"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters
2043 in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>,
2044 respectively.</p></div>
2046 <h2 id="_diff_format_for_merges
">diff format for merges</h2>
2047 <div class="sectionbody
">
2048 <div class="paragraph
"><p>"git-diff-tree
", "git-diff-files
" and "git-diff --raw
"
2049 can take <em>-c</em> or <em>--cc</em> option
2050 to generate diff output also for merge commits. The output differs
2051 from the format described above in the following way:</p></div>
2052 <div class="olist arabic
"><ol class="arabic
">
2055 there is a colon for each parent
2060 there are more "src
" modes and "src
" sha1
2065 status is concatenated status characters for each parent
2070 no optional "score
" number
2075 single path, only for "dst
"
2079 <div class="paragraph
"><p>Example:</p></div>
2080 <div class="listingblock
">
2081 <div class="content
">
2082 <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre>
2084 <div class="paragraph
"><p>Note that <em>combined diff</em> lists only files which were modified from
2085 all parents.</p></div>
2087 <h2 id="_generating_patches_with_p
">Generating patches with -p</h2>
2088 <div class="sectionbody
">
2089 <div class="paragraph
"><p>When "git-diff-index
", "git-diff-tree
", or "git-diff-files
" are run
2090 with a <em>-p</em> option, "git diff
" without the <em>--raw</em> option, or
2091 "git log
" with the "-p
" option, they
2092 do not produce the output described above; instead they produce a
2093 patch file. You can customize the creation of such patches via the
2094 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div>
2095 <div class="paragraph
"><p>What the -p option produces is slightly different from the traditional
2096 diff format:</p></div>
2097 <div class="olist arabic
"><ol class="arabic
">
2100 It is preceded with a "git diff
" header that looks like this:
2102 <div class="literalblock
">
2103 <div class="content
">
2104 <pre><tt>diff --git a/file1 b/file2</tt></pre>
2106 <div class="paragraph
"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is
2107 involved. Especially, even for a creation or a deletion,
2108 <tt>/dev/null</tt> is <em>not</em> used in place of the <tt>a/</tt> or <tt>b/</tt> filenames.</p></div>
2109 <div class="paragraph
"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the
2110 name of the source file of the rename/copy and the name of
2111 the file that rename/copy produces, respectively.</p></div>
2115 It is followed by one or more extended header lines:
2117 <div class="literalblock
">
2118 <div class="content
">
2119 <pre><tt>old mode <mode>
2120 new mode <mode>
2121 deleted file mode <mode>
2122 new file mode <mode>
2123 copy from <path>
2124 copy to <path>
2125 rename from <path>
2126 rename to <path>
2127 similarity index <number>
2128 dissimilarity index <number>
2129 index <hash>..<hash> <mode></tt></pre>
2131 <div class="paragraph
"><p>File modes are printed as 6-digit octal numbers including the file type
2132 and file permission bits.</p></div>
2133 <div class="paragraph
"><p>Path names in extended headers do not include the <tt>a/</tt> and <tt>b/</tt> prefixes.</p></div>
2134 <div class="paragraph
"><p>The similarity index is the percentage of unchanged lines, and
2135 the dissimilarity index is the percentage of changed lines. It
2136 is a rounded down integer, followed by a percent sign. The
2137 similarity index value of 100% is thus reserved for two equal
2138 files, while 100% dissimilarity means that no line from the old
2139 file made it into the new one.</p></div>
2140 <div class="paragraph
"><p>The index line includes the SHA-1 checksum before and after the change.
2141 The <mode> is included if the file mode does not change; otherwise,
2142 separate lines indicate the old and the new mode.</p></div>
2146 TAB, LF, double quote and backslash characters in pathnames
2147 are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and
<tt>\\
</tt>, respectively.
2148 If there is need for such substitution then the whole
2149 pathname is put in double quotes.
2154 All the
<tt>file1
</tt> files in the output refer to files before the
2155 commit, and all the
<tt>file2
</tt> files refer to files after the commit.
2156 It is incorrect to apply each change to each file sequentially. For
2157 example, this patch will swap a and b:
2159 <div class=
"literalblock">
2160 <div class=
"content">
2161 <pre><tt>diff --git a/a b/b
2166 rename to a
</tt></pre>
2171 <h2 id=
"_combined_diff_format">combined diff format
</h2>
2172 <div class=
"sectionbody">
2173 <div class=
"paragraph"><p>Any diff-generating command can take the
‘-c` or
<tt>--cc
</tt> option to
2174 produce a
<em>combined diff
</em> when showing a merge. This is the default
2175 format when showing merges with
<a href=
"git-diff.html">git-diff(
1)
</a> or
2176 <a href=
"git-show.html">git-show(
1)
</a>. Note also that you can give the `-m
’ option to any
2177 of these commands to force generation of diffs with individual parents
2178 of a merge.
</p></div>
2179 <div class=
"paragraph"><p>A
<em>combined diff
</em> format looks like this:
</p></div>
2180 <div class=
"listingblock">
2181 <div class=
"content">
2182 <pre><tt>diff --combined describe.c
2183 index fabadb8,cc95eb0.
.4866510
2186 @@@ -
98,
20 -
98,
12 +
98,
20 @@@
2187 return (a_date
> b_date) ? -
1 : (a_date == b_date) ?
0 :
1;
2190 - static void describe(char *arg)
2191 -static void describe(struct commit *cmit, int last_one)
2192 ++static void describe(char *arg, int last_one)
2194 + unsigned char sha1[
20];
2195 + struct commit *cmit;
2196 struct commit_list *list;
2197 static int initialized =
0;
2198 struct commit_name *n;
2200 + if (get_sha1(arg, sha1)
< 0)
2201 + usage(describe_usage);
2202 + cmit = lookup_commit_reference(sha1);
2204 + usage(describe_usage);
2208 for_each_ref(get_name);
</tt></pre>
2210 <div class=
"olist arabic"><ol class=
"arabic">
2213 It is preceded with a
"git diff" header, that looks like
2214 this (when
<em>-c
</em> option is used):
2216 <div class=
"literalblock">
2217 <div class=
"content">
2218 <pre><tt>diff --combined file
</tt></pre>
2220 <div class=
"paragraph"><p>or like this (when
<em>--cc
</em> option is used):
</p></div>
2221 <div class=
"literalblock">
2222 <div class=
"content">
2223 <pre><tt>diff --cc file
</tt></pre>
2228 It is followed by one or more extended header lines
2229 (this example shows a merge with two parents):
2231 <div class=
"literalblock">
2232 <div class=
"content">
2233 <pre><tt>index
<hash
>,
<hash
>..
<hash
>
2234 mode
<mode
>,
<mode
>..
<mode
>
2235 new file mode
<mode
>
2236 deleted file mode
<mode
>,
<mode
></tt></pre>
2238 <div class=
"paragraph"><p>The
<tt>mode
<mode
>,
<mode
>..
<mode
></tt> line appears only if at least one of
2239 the
<mode
> is different from the rest. Extended headers with
2240 information about detected contents movement (renames and
2241 copying detection) are designed to work with diff of two
2242 <tree-ish
> and are not used by combined diff format.
</p></div>
2246 It is followed by two-line from-file/to-file header
2248 <div class=
"literalblock">
2249 <div class=
"content">
2251 +++ b/file
</tt></pre>
2253 <div class=
"paragraph"><p>Similar to two-line header for traditional
<em>unified
</em> diff
2254 format,
<tt>/dev/null
</tt> is used to signal created or deleted
2259 Chunk header format is modified to prevent people from
2260 accidentally feeding it to
<tt>patch -p1
</tt>. Combined diff format
2261 was created for review of merge commit changes, and was not
2262 meant for apply. The change is similar to the change in the
2263 extended
<em>index
</em> header:
2265 <div class=
"literalblock">
2266 <div class=
"content">
2267 <pre><tt>@@@
<from-file-range
> <from-file-range
> <to-file-range
> @@@
</tt></pre>
2269 <div class=
"paragraph"><p>There are (number of parents +
1)
<tt>@
</tt> characters in the chunk
2270 header for combined diff format.
</p></div>
2273 <div class=
"paragraph"><p>Unlike the traditional
<em>unified
</em> diff format, which shows two
2274 files A and B with a single column that has
<tt>-
</tt> (minus
 — appears in A but removed in B),
<tt>+
</tt> (plus
 — missing in A but
2275 added to B), or
<tt>" "</tt> (space
 — unchanged) prefix, this format
2276 compares two or more files file1, file2,
… with one file X, and
2277 shows how X differs from each of fileN. One column for each of
2278 fileN is prepended to the output line to note how X
’s line is
2279 different from it.
</p></div>
2280 <div class=
"paragraph"><p>A
<tt>-
</tt> character in the column N means that the line appears in
2281 fileN but it does not appear in the result. A
<tt>+
</tt> character
2282 in the column N means that the line appears in the result,
2283 and fileN does not have that line (in other words, the line was
2284 added, from the point of view of that parent).
</p></div>
2285 <div class=
"paragraph"><p>In the above example output, the function signature was changed
2286 from both files (hence two
<tt>-
</tt> removals from both file1 and
2287 file2, plus
<tt>++
</tt> to mean one line that was added does not appear
2288 in either file1 nor file2). Also eight other lines are the same
2289 from file1 but do not appear in file2 (hence prefixed with
<tt>+</tt>).
</p></div>
2290 <div class=
"paragraph"><p>When shown by
<tt>git diff-tree -c
</tt>, it compares the parents of a
2291 merge commit with the merge result (i.e. file1..fileN are the
2292 parents). When shown by
<tt>git diff-files -c
</tt>, it compares the
2293 two unresolved merge parents with the working tree file
2294 (i.e. file1 is stage
2 aka
"our version", file2 is stage
3 aka
2295 "their version").
</p></div>
2297 <h2 id=
"_other_diff_formats">other diff formats
</h2>
2298 <div class=
"sectionbody">
2299 <div class=
"paragraph"><p>The
<tt>--summary
</tt> option describes newly added, deleted, renamed and
2300 copied files. The
<tt>--stat
</tt> option adds diffstat(
1) graph to the
2301 output. These options can be combined with other options, such as
2302 <tt>-p
</tt>, and are meant for human consumption.
</p></div>
2303 <div class=
"paragraph"><p>When showing a change that involves a rename or a copy,
<tt>--stat
</tt> output
2304 formats the pathnames compactly by combining common prefix and suffix of
2305 the pathnames. For example, a change that moves
<tt>arch/i386/Makefile
</tt> to
2306 <tt>arch/x86/Makefile
</tt> while modifying
4 lines will be shown like this:
</p></div>
2307 <div class=
"listingblock">
2308 <div class=
"content">
2309 <pre><tt>arch/{i386 =
> x86}/Makefile |
4 +--
</tt></pre>
2311 <div class=
"paragraph"><p>The
<tt>--numstat
</tt> option gives the diffstat(
1) information but is designed
2312 for easier machine consumption. An entry in
<tt>--numstat
</tt> output looks
2313 like this:
</p></div>
2314 <div class=
"listingblock">
2315 <div class=
"content">
2317 3 1 arch/{i386 =
> x86}/Makefile
</tt></pre>
2319 <div class=
"paragraph"><p>That is, from left to right:
</p></div>
2320 <div class=
"olist arabic"><ol class=
"arabic">
2323 the number of added lines;
2333 the number of deleted lines;
2343 pathname (possibly with rename/copy information);
2352 <div class=
"paragraph"><p>When
<tt>-z
</tt> output option is in effect, the output is formatted this way:
</p></div>
2353 <div class=
"listingblock">
2354 <div class=
"content">
2355 <pre><tt>1 2 README NUL
2356 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
</tt></pre>
2358 <div class=
"paragraph"><p>That is:
</p></div>
2359 <div class=
"olist arabic"><ol class=
"arabic">
2362 the number of added lines;
2372 the number of deleted lines;
2382 a NUL (only exists if renamed/copied);
2387 pathname in preimage;
2392 a NUL (only exists if renamed/copied);
2397 pathname in postimage (only exists if renamed/copied);
2406 <div class=
"paragraph"><p>The extra
<tt>NUL
</tt> before the preimage path in renamed case is to allow
2407 scripts that read the output to tell if the current record being read is
2408 a single-path record or a rename/copy record without reading ahead.
2409 After reading added and deleted lines, reading up to
<tt>NUL
</tt> would yield
2410 the pathname, but if that is
<tt>NUL
</tt>, the record will show two paths.
</p></div>
2412 <h2 id=
"_git">GIT
</h2>
2413 <div class=
"sectionbody">
2414 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
2417 <div id=
"footer-text">
2418 Last updated
2011-
05-
31 19:
53:
01 UTC