1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
\r
4 <article lang="en" id="git-diff-tree(1)">
\r
6 <title>git-diff-tree(1)</title>
\r
8 <primary>git-diff-tree(1)</primary>
\r
11 <simplesect id="_name">
\r
13 <simpara>git-diff-tree - Compares the content and mode of blobs found via two tree objects</simpara>
\r
15 <simplesect id="_synopsis">
\r
16 <title>SYNOPSIS</title>
\r
18 <literallayout><emphasis>git diff-tree</emphasis> [--stdin] [-m] [-s] [-v] [--no-commit-id] [--pretty]
\r
19 [-t] [-r] [-c | --cc] [--root] [<common diff options>]
\r
20 <tree-ish> [<tree-ish>] [<path>…]</literallayout>
\r
23 <simplesect id="_description">
\r
24 <title>DESCRIPTION</title>
\r
25 <simpara>Compares the content and mode of the blobs found via two tree objects.</simpara>
\r
26 <simpara>If there is only one <tree-ish> given, the commit is compared with its parents
\r
27 (see --stdin below).</simpara>
\r
28 <simpara>Note that <emphasis>git diff-tree</emphasis> can use the tree encapsulated in a commit object.</simpara>
\r
30 <simplesect id="_options">
\r
31 <title>OPTIONS</title>
\r
45 Generate patch (see section on generating patches).
\r
59 Generate diffs with <n> lines of context instead of
\r
61 Implies <emphasis>-p</emphasis>.
\r
71 Generate the raw format.
\r
72 This is the default.
\r
82 Synonym for <emphasis>-p --raw</emphasis>.
\r
92 Spend extra time to make sure the smallest possible
\r
103 Generate a diff using the "patience diff" algorithm.
\r
113 Generate a diff using the "histogram diff" algorithm.
\r
119 --stat[=<width>[,<name-width>[,<count>]]]
\r
123 Generate a diffstat. By default, as much space as necessary
\r
124 will be used for the filename part, and the rest for the graph
\r
125 part. Maximum width defaults to terminal width, or 80 columns
\r
126 if not connected to a terminal, and can be overriden by
\r
127 <emphasis><width></emphasis>. The width of the filename part can be limited by
\r
128 giving another width <emphasis><name-width></emphasis> after a comma. The width
\r
129 of the graph part can be limited by using
\r
130 <emphasis>--stat-graph-width=<width></emphasis> (affects all commands generating
\r
131 a stat graph) or by setting <emphasis>diff.statGraphWidth=<width></emphasis>
\r
132 (does not affect <emphasis>git format-patch</emphasis>).
\r
133 By giving a third parameter <emphasis><count></emphasis>, you can limit the
\r
134 output to the first <emphasis><count></emphasis> lines, followed by <emphasis>...</emphasis> if
\r
137 <simpara>These parameters can also be set individually with <emphasis>--stat-width=<width></emphasis>,
\r
138 <emphasis>--stat-name-width=<name-width></emphasis> and <emphasis>--stat-count=<count></emphasis>.</simpara>
\r
147 Similar to <emphasis>--stat</emphasis>, but shows number of added and
\r
148 deleted lines in decimal notation and pathname without
\r
149 abbreviation, to make it more machine friendly. For
\r
150 binary files, outputs two <emphasis>-</emphasis> instead of saying
\r
151 <emphasis>0 0</emphasis>.
\r
161 Output only the last line of the <emphasis>--stat</emphasis> format containing total
\r
162 number of modified files, as well as number of added and deleted
\r
169 --dirstat[=<param1,param2,…>]
\r
173 Output the distribution of relative amount of changes for each
\r
174 sub-directory. The behavior of <emphasis>--dirstat</emphasis> can be customized by
\r
175 passing it a comma separated list of parameters.
\r
176 The defaults are controlled by the <emphasis>diff.dirstat</emphasis> configuration
\r
177 variable (see <xref linkend="git-config(1)" />).
\r
178 The following parameters are available:
\r
183 <emphasis>changes</emphasis>
\r
187 Compute the dirstat numbers by counting the lines that have been
\r
188 removed from the source, or added to the destination. This ignores
\r
189 the amount of pure code movements within a file. In other words,
\r
190 rearranging lines in a file is not counted as much as other changes.
\r
191 This is the default behavior when no parameter is given.
\r
197 <emphasis>lines</emphasis>
\r
201 Compute the dirstat numbers by doing the regular line-based diff
\r
202 analysis, and summing the removed/added line counts. (For binary
\r
203 files, count 64-byte chunks instead, since binary files have no
\r
204 natural concept of lines). This is a more expensive <emphasis>--dirstat</emphasis>
\r
205 behavior than the <emphasis>changes</emphasis> behavior, but it does count rearranged
\r
206 lines within a file as much as other changes. The resulting output
\r
207 is consistent with what you get from the other <emphasis>--*stat</emphasis> options.
\r
213 <emphasis>files</emphasis>
\r
217 Compute the dirstat numbers by counting the number of files changed.
\r
218 Each changed file counts equally in the dirstat analysis. This is
\r
219 the computationally cheapest <emphasis>--dirstat</emphasis> behavior, since it does
\r
220 not have to look at the file contents at all.
\r
226 <emphasis>cumulative</emphasis>
\r
230 Count changes in a child directory for the parent directory as well.
\r
231 Note that when using <emphasis>cumulative</emphasis>, the sum of the percentages
\r
232 reported may exceed 100%. The default (non-cumulative) behavior can
\r
233 be specified with the <emphasis>noncumulative</emphasis> parameter.
\r
243 An integer parameter specifies a cut-off percent (3% by default).
\r
244 Directories contributing less than this percentage of the changes
\r
245 are not shown in the output.
\r
250 <simpara>Example: The following will count changed files, while ignoring
\r
251 directories with less than 10% of the total amount of changed files,
\r
252 and accumulating child directory counts in the parent directories:
\r
253 <emphasis>--dirstat=files,10,cumulative</emphasis>.</simpara>
\r
262 Output a condensed summary of extended header information
\r
263 such as creations, renames and mode changes.
\r
273 Synonym for <emphasis>-p --stat</emphasis>.
\r
283 When <emphasis>--raw</emphasis>, <emphasis>--numstat</emphasis>, <emphasis>--name-only</emphasis> or <emphasis>--name-status</emphasis> has been
\r
284 given, do not munge pathnames and use NULs as output field terminators.
\r
286 <simpara>Without this option, each pathname output will have TAB, LF, double quotes,
\r
287 and backslash characters replaced with <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, <emphasis>\"</emphasis>, and <emphasis>\\</emphasis>,
\r
288 respectively, and the pathname will be enclosed in double quotes if
\r
289 any of those replacements occurred.</simpara>
\r
298 Show only names of changed files.
\r
308 Show only names and status of changed files. See the description
\r
309 of the <emphasis>--diff-filter</emphasis> option on what the status letters mean.
\r
315 --submodule[=<format>]
\r
319 Specify how differences in submodules are shown. When <emphasis>--submodule</emphasis>
\r
320 or <emphasis>--submodule=log</emphasis> is given, the <emphasis>log</emphasis> format is used. This format lists
\r
321 the commits in the range like <xref linkend="git-submodule(1)" /> <emphasis>summary</emphasis> does.
\r
322 Omitting the <emphasis>--submodule</emphasis> option or specifying <emphasis>--submodule=short</emphasis>,
\r
323 uses the <emphasis>short</emphasis> format. This format just shows the names of the commits
\r
324 at the beginning and end of the range.
\r
330 --color[=<when>]
\r
335 The value must be <emphasis>always</emphasis> (the default for <emphasis><when></emphasis>), <emphasis>never</emphasis>, or <emphasis>auto</emphasis>.
\r
336 The default value is <emphasis>never</emphasis>.
\r
346 Turn off colored diff.
\r
347 It is the same as <emphasis>--color=never</emphasis>.
\r
353 --word-diff[=<mode>]
\r
357 Show a word diff, using the <mode> to delimit changed words.
\r
358 By default, words are delimited by whitespace; see
\r
359 <emphasis>--word-diff-regex</emphasis> below. The <mode> defaults to <emphasis>plain</emphasis>, and
\r
369 Highlight changed words using only colors. Implies <emphasis>--color</emphasis>.
\r
379 Show words as <emphasis>[-removed-]</emphasis> and <emphasis>{+added+}</emphasis>. Makes no
\r
380 attempts to escape the delimiters if they appear in the input,
\r
381 so the output may be ambiguous.
\r
391 Use a special line-based format intended for script
\r
392 consumption. Added/removed/unchanged runs are printed in the
\r
393 usual unified diff format, starting with a <emphasis>+</emphasis>/<emphasis>-</emphasis>/` `
\r
394 character at the beginning of the line and extending to the
\r
395 end of the line. Newlines in the input are represented by a
\r
396 tilde <emphasis>~</emphasis> on a line of its own.
\r
406 Disable word diff again.
\r
411 <simpara>Note that despite the name of the first mode, color is used to
\r
412 highlight the changed parts in all modes if enabled.</simpara>
\r
417 --word-diff-regex=<regex>
\r
421 Use <regex> to decide what a word is, instead of considering
\r
422 runs of non-whitespace to be a word. Also implies
\r
423 <emphasis>--word-diff</emphasis> unless it was already enabled.
\r
425 <simpara>Every non-overlapping match of the
\r
426 <regex> is considered a word. Anything between these matches is
\r
427 considered whitespace and ignored(!) for the purposes of finding
\r
428 differences. You may want to append <emphasis>|[^[:space:]]</emphasis> to your regular
\r
429 expression to make sure that it matches all non-whitespace characters.
\r
430 A match that contains a newline is silently truncated(!) at the
\r
432 <simpara>The regex can also be set via a diff driver or configuration option, see
\r
433 <xref linkend="gitattributes(1)" /> or <xref linkend="git-config(1)" />. Giving it explicitly
\r
434 overrides any diff driver or configuration setting. Diff drivers
\r
435 override configuration settings.</simpara>
\r
440 --color-words[=<regex>]
\r
444 Equivalent to <emphasis>--word-diff=color</emphasis> plus (if a regex was
\r
445 specified) <emphasis>--word-diff-regex=<regex></emphasis>.
\r
455 Turn off rename detection, even when the configuration
\r
456 file gives the default to do so.
\r
466 Warn if changes introduce whitespace errors. What are
\r
467 considered whitespace errors is controlled by <emphasis>core.whitespace</emphasis>
\r
468 configuration. By default, trailing whitespaces (including
\r
469 lines that solely consist of whitespaces) and a space character
\r
470 that is immediately followed by a tab character inside the
\r
471 initial indent of the line are considered whitespace errors.
\r
472 Exits with non-zero status if problems are found. Not compatible
\r
483 Instead of the first handful of characters, show the full
\r
484 pre- and post-image blob object names on the "index"
\r
485 line when generating patch format output.
\r
495 In addition to <emphasis>--full-index</emphasis>, output a binary diff that
\r
496 can be applied with <emphasis>git-apply</emphasis>.
\r
502 --abbrev[=<n>]
\r
506 Instead of showing the full 40-byte hexadecimal object
\r
507 name in diff-raw format output and diff-tree header
\r
508 lines, show only a partial prefix. This is
\r
509 independent of the <emphasis>--full-index</emphasis> option above, which controls
\r
510 the diff-patch output format. Non default number of
\r
511 digits can be specified with <emphasis>--abbrev=<n></emphasis>.
\r
517 -B[<n>][/<m>]
\r
520 --break-rewrites[=[<n>][/<m>]]
\r
524 Break complete rewrite changes into pairs of delete and
\r
525 create. This serves two purposes:
\r
527 <simpara>It affects the way a change that amounts to a total rewrite of a file
\r
528 not as a series of deletion and insertion mixed together with a very
\r
529 few lines that happen to match textually as the context, but as a
\r
530 single deletion of everything old followed by a single insertion of
\r
531 everything new, and the number <emphasis>m</emphasis> controls this aspect of the -B
\r
532 option (defaults to 60%). <emphasis>-B/70%</emphasis> specifies that less than 30% of the
\r
533 original should remain in the result for git to consider it a total
\r
534 rewrite (i.e. otherwise the resulting patch will be a series of
\r
535 deletion and insertion mixed together with context lines).</simpara>
\r
536 <simpara>When used with -M, a totally-rewritten file is also considered as the
\r
537 source of a rename (usually -M only considers a file that disappeared
\r
538 as the source of a rename), and the number <emphasis>n</emphasis> controls this aspect of
\r
539 the -B option (defaults to 50%). <emphasis>-B20%</emphasis> specifies that a change with
\r
540 addition and deletion compared to 20% or more of the file's size are
\r
541 eligible for being picked up as a possible source of a rename to
\r
542 another file.</simpara>
\r
550 --find-renames[=<n>]
\r
555 If <emphasis>n</emphasis> is specified, it is a threshold on the similarity
\r
556 index (i.e. amount of addition/deletions compared to the
\r
557 file's size). For example, <emphasis>-M90%</emphasis> means git should consider a
\r
558 delete/add pair to be a rename if more than 90% of the file
\r
568 --find-copies[=<n>]
\r
572 Detect copies as well as renames. See also <emphasis>--find-copies-harder</emphasis>.
\r
573 If <emphasis>n</emphasis> is specified, it has the same meaning as for <emphasis>-M<n></emphasis>.
\r
579 --find-copies-harder
\r
583 For performance reasons, by default, <emphasis>-C</emphasis> option finds copies only
\r
584 if the original file of the copy was modified in the same
\r
585 changeset. This flag makes the command
\r
586 inspect unmodified files as candidates for the source of
\r
587 copy. This is a very expensive operation for large
\r
588 projects, so use it with caution. Giving more than one
\r
589 <emphasis>-C</emphasis> option has the same effect.
\r
598 --irreversible-delete
\r
602 Omit the preimage for deletes, i.e. print only the header but not
\r
603 the diff between the preimage and <emphasis>/dev/null</emphasis>. The resulting patch
\r
604 is not meant to be applied with <emphasis>patch</emphasis> nor <emphasis>git apply</emphasis>; this is
\r
605 solely for people who want to just concentrate on reviewing the
\r
606 text after the change. In addition, the output obviously lack
\r
607 enough information to apply such a patch in reverse, even manually,
\r
608 hence the name of the option.
\r
610 <simpara>When used together with <emphasis>-B</emphasis>, omit also the preimage in the deletion part
\r
611 of a delete/create pair.</simpara>
\r
620 The <emphasis>-M</emphasis> and <emphasis>-C</emphasis> options require O(n^2) processing time where n
\r
621 is the number of potential rename/copy targets. This
\r
622 option prevents rename/copy detection from running if
\r
623 the number of rename/copy targets exceeds the specified
\r
630 --diff-filter=[(A|C|D|M|R|T|U|X|B)…[*]]
\r
634 Select only files that are Added (<emphasis>A</emphasis>), Copied (<emphasis>C</emphasis>),
\r
635 Deleted (<emphasis>D</emphasis>), Modified (<emphasis>M</emphasis>), Renamed (<emphasis>R</emphasis>), have their
\r
636 type (i.e. regular file, symlink, submodule, …) changed (<emphasis>T</emphasis>),
\r
637 are Unmerged (<emphasis>U</emphasis>), are
\r
638 Unknown (<emphasis>X</emphasis>), or have had their pairing Broken (<emphasis>B</emphasis>).
\r
639 Any combination of the filter characters (including none) can be used.
\r
640 When <emphasis>*</emphasis> (All-or-none) is added to the combination, all
\r
641 paths are selected if there is any file that matches
\r
642 other criteria in the comparison; if there is no file
\r
643 that matches other criteria, nothing is selected.
\r
653 Look for differences that introduce or remove an instance of
\r
654 <string>. Note that this is different than the string simply
\r
655 appearing in diff output; see the <emphasis>pickaxe</emphasis> entry in
\r
656 <xref linkend="gitdiffcore(7)" /> for more details.
\r
666 Look for differences whose added or removed line matches
\r
667 the given <regex>.
\r
677 When <emphasis>-S</emphasis> or <emphasis>-G</emphasis> finds a change, show all the changes in that
\r
678 changeset, not just the files that contain the change
\r
689 Make the <string> not a plain string but an extended POSIX
\r
696 -O<orderfile>
\r
700 Output the patch in the order specified in the
\r
701 <orderfile>, which has one shell glob pattern per line.
\r
711 Swap two inputs; that is, show differences from index or
\r
712 on-disk file to tree contents.
\r
718 --relative[=<path>]
\r
722 When run from a subdirectory of the project, it can be
\r
723 told to exclude changes outside the directory and show
\r
724 pathnames relative to it with this option. When you are
\r
725 not in a subdirectory (e.g. in a bare repository), you
\r
726 can name which subdirectory to make the output relative
\r
727 to by giving a <path> as an argument.
\r
740 Treat all files as text.
\r
746 --ignore-space-at-eol
\r
750 Ignore changes in whitespace at EOL.
\r
759 --ignore-space-change
\r
763 Ignore changes in amount of whitespace. This ignores whitespace
\r
764 at line end, and considers all other sequences of one or
\r
765 more whitespace characters to be equivalent.
\r
778 Ignore whitespace when comparing lines. This ignores
\r
779 differences even if one line has whitespace where the other
\r
786 --inter-hunk-context=<lines>
\r
790 Show the context between diff hunks, up to the specified number
\r
791 of lines, thereby fusing hunks that are close to each other.
\r
804 Show whole surrounding functions of changes.
\r
814 Make the program exit with codes similar to diff(1).
\r
815 That is, it exits with 1 if there were differences and
\r
816 0 means no differences.
\r
826 Disable all output of the program. Implies <emphasis>--exit-code</emphasis>.
\r
836 Allow an external diff helper to be executed. If you set an
\r
837 external diff driver with <xref linkend="gitattributes(5)" />, you need
\r
838 to use this option with <xref linkend="git-log(1)" /> and friends.
\r
848 Disallow external diff drivers.
\r
861 Allow (or disallow) external text conversion filters to be run
\r
862 when comparing binary files. See <xref linkend="gitattributes(5)" /> for
\r
863 details. Because textconv filters are typically a one-way
\r
864 conversion, the resulting diff is suitable for human
\r
865 consumption, but cannot be applied. For this reason, textconv
\r
866 filters are enabled by default only for <xref linkend="git-diff(1)" /> and
\r
867 <xref linkend="git-log(1)" />, but not for <xref linkend="git-format-patch(1)" /> or
\r
868 diff plumbing commands.
\r
874 --ignore-submodules[=<when>]
\r
878 Ignore changes to submodules in the diff generation. <when> can be
\r
879 either "none", "untracked", "dirty" or "all", which is the default
\r
880 Using "none" will consider the submodule modified when it either contains
\r
881 untracked or modified files or its HEAD differs from the commit recorded
\r
882 in the superproject and can be used to override any settings of the
\r
883 <emphasis>ignore</emphasis> option in <xref linkend="git-config(1)" /> or <xref linkend="gitmodules(5)" />. When
\r
884 "untracked" is used submodules are not considered dirty when they only
\r
885 contain untracked content (but they are still scanned for modified
\r
886 content). Using "dirty" ignores all changes to the work tree of submodules,
\r
887 only changes to the commits stored in the superproject are shown (this was
\r
888 the behavior until 1.7.0). Using "all" hides all changes to submodules.
\r
894 --src-prefix=<prefix>
\r
898 Show the given source prefix instead of "a/".
\r
904 --dst-prefix=<prefix>
\r
908 Show the given destination prefix instead of "b/".
\r
918 Do not show any source or destination prefix.
\r
923 <simpara>For more detailed explanation on these common options, see also
\r
924 <xref linkend="gitdiffcore(7)" />.</simpara>
\r
932 The id of a tree object.
\r
938 <path>…
\r
942 If provided, the results are limited to a subset of files
\r
943 matching one of these prefix strings.
\r
944 i.e., file matches <emphasis>/^<pattern1>|<pattern2>|.../</emphasis>
\r
945 Note that this parameter does not provide any wildcard or regexp
\r
956 recurse into sub-trees
\r
966 show tree entry itself as well as subtrees. Implies -r.
\r
976 When <emphasis>--root</emphasis> is specified the initial commit will be shown as a big
\r
977 creation event. This is equivalent to a diff against the NULL tree.
\r
987 When <emphasis>--stdin</emphasis> is specified, the command does not take
\r
988 <tree-ish> arguments from the command line. Instead, it
\r
989 reads lines containing either two <tree>, one <commit>, or a
\r
990 list of <commit> from its standard input. (Use a single space
\r
993 <simpara>When two trees are given, it compares the first tree with the second.
\r
994 When a single commit is given, it compares the commit with its
\r
995 parents. The remaining commits, when given, are used as if they are
\r
996 parents of the first commit.</simpara>
\r
997 <simpara>When comparing two trees, the ID of both trees (separated by a space
\r
998 and terminated by a newline) is printed before the difference. When
\r
999 comparing commits, the ID of the first (or only) commit, followed by a
\r
1000 newline, is printed.</simpara>
\r
1001 <simpara>The following flags further affect the behavior when comparing
\r
1002 commits (but not trees).</simpara>
\r
1011 By default, <emphasis>git diff-tree --stdin</emphasis> does not show
\r
1012 differences for merge commits. With this flag, it shows
\r
1013 differences to that commit from all of its parents. See
\r
1014 also <emphasis>-c</emphasis>.
\r
1024 By default, <emphasis>git diff-tree --stdin</emphasis> shows differences,
\r
1025 either in machine-readable form (without <emphasis>-p</emphasis>) or in patch
\r
1026 form (with <emphasis>-p</emphasis>). This output can be suppressed. It is
\r
1027 only useful with <emphasis>-v</emphasis> flag.
\r
1037 This flag causes <emphasis>git diff-tree --stdin</emphasis> to also show
\r
1038 the commit message before the differences.
\r
1044 --pretty[=<format>]
\r
1047 --format=<format>
\r
1051 Pretty-print the contents of the commit logs in a given format,
\r
1052 where <emphasis><format></emphasis> can be one of <emphasis>oneline</emphasis>, <emphasis>short</emphasis>, <emphasis>medium</emphasis>,
\r
1053 <emphasis>full</emphasis>, <emphasis>fuller</emphasis>, <emphasis>email</emphasis>, <emphasis>raw</emphasis> and <emphasis>format:<string></emphasis>. See
\r
1054 the "PRETTY FORMATS" section for some additional details for each
\r
1055 format. When omitted, the format defaults to <emphasis>medium</emphasis>.
\r
1057 <simpara>Note: you can specify the default pretty format in the repository
\r
1058 configuration (see <xref linkend="git-config(1)" />).</simpara>
\r
1067 Instead of showing the full 40-byte hexadecimal commit object
\r
1068 name, show only a partial prefix. Non default number of
\r
1069 digits can be specified with "--abbrev=<n>" (which also modifies
\r
1070 diff output, if it is displayed).
\r
1072 <simpara>This should make "--pretty=oneline" a whole lot more readable for
\r
1073 people using 80-column terminals.</simpara>
\r
1078 --no-abbrev-commit
\r
1082 Show the full 40-byte hexadecimal commit object name. This negates
\r
1083 <emphasis>--abbrev-commit</emphasis> and those options which imply it such as
\r
1084 "--oneline". It also overrides the <emphasis>log.abbrevCommit</emphasis> variable.
\r
1094 This is a shorthand for "--pretty=oneline --abbrev-commit"
\r
1101 --encoding[=<encoding>]
\r
1105 The commit objects record the encoding used for the log message
\r
1106 in their encoding header; this option can be used to tell the
\r
1107 command to re-code the commit log message in the encoding
\r
1108 preferred by the user. For non plumbing commands this
\r
1109 defaults to UTF-8.
\r
1115 --notes[=<ref>]
\r
1119 Show the notes (see <xref linkend="git-notes(1)" />) that annotate the
\r
1120 commit, when showing the commit log message. This is the default
\r
1121 for <emphasis>git log</emphasis>, <emphasis>git show</emphasis> and <emphasis>git whatchanged</emphasis> commands when
\r
1122 there is no <emphasis>--pretty</emphasis>, <emphasis>--format</emphasis> nor <emphasis>--oneline</emphasis> option given
\r
1123 on the command line.
\r
1125 <simpara>By default, the notes shown are from the notes refs listed in the
\r
1126 <emphasis>core.notesRef</emphasis> and <emphasis>notes.displayRef</emphasis> variables (or corresponding
\r
1127 environment overrides). See <xref linkend="git-config(1)" /> for more details.</simpara>
\r
1128 <simpara>With an optional <emphasis><ref></emphasis> argument, show this notes ref instead of the
\r
1129 default notes ref(s). The ref is taken to be in <emphasis>refs/notes/</emphasis> if it
\r
1130 is not qualified.</simpara>
\r
1131 <simpara>Multiple --notes options can be combined to control which notes are
\r
1132 being displayed. Examples: "--notes=foo" will show only notes from
\r
1133 "refs/notes/foo"; "--notes=foo --notes" will show both notes from
\r
1134 "refs/notes/foo" and from the default notes ref(s).</simpara>
\r
1143 Do not show notes. This negates the above <emphasis>--notes</emphasis> option, by
\r
1144 resetting the list of notes refs from which notes are shown.
\r
1145 Options are parsed in the order given on the command line, so e.g.
\r
1146 "--notes --notes=foo --no-notes --notes=bar" will only show notes
\r
1147 from "refs/notes/bar".
\r
1153 --show-notes[=<ref>]
\r
1156 --[no-]standard-notes
\r
1160 These options are deprecated. Use the above --notes/--no-notes
\r
1171 <emphasis>git diff-tree</emphasis> outputs a line with the commit ID when
\r
1172 applicable. This flag suppressed the commit ID output.
\r
1182 This flag changes the way a merge commit is displayed
\r
1183 (which means it is useful only when the command is given
\r
1184 one <tree-ish>, or <emphasis>--stdin</emphasis>). It shows the differences
\r
1185 from each of the parents to the merge result simultaneously
\r
1186 instead of showing pairwise diff between a parent and the
\r
1187 result one at a time (which is what the <emphasis>-m</emphasis> option does).
\r
1188 Furthermore, it lists only files which were modified
\r
1199 This flag changes the way a merge commit patch is displayed,
\r
1200 in a similar way to the <emphasis>-c</emphasis> option. It implies the <emphasis>-c</emphasis>
\r
1201 and <emphasis>-p</emphasis> options and further compresses the patch output
\r
1202 by omitting uninteresting hunks whose the contents in the parents
\r
1203 have only two variants and the merge result picks one of them
\r
1204 without modification. When all hunks are uninteresting, the commit
\r
1205 itself and the commit log message is not shown, just like in any other
\r
1206 "empty diff" case.
\r
1216 Show the commit itself and the commit log message even
\r
1217 if the diff itself is empty.
\r
1223 <simplesect id="_pretty_formats">
\r
1224 <title>PRETTY FORMATS</title>
\r
1225 <simpara>If the commit is a merge, and if the pretty-format
\r
1226 is not <emphasis>oneline</emphasis>, <emphasis>email</emphasis> or <emphasis>raw</emphasis>, an additional line is
\r
1227 inserted before the <emphasis>Author:</emphasis> line. This line begins with
\r
1228 "Merge: " and the sha1s of ancestral commits are printed,
\r
1229 separated by spaces. Note that the listed commits may not
\r
1230 necessarily be the list of the <emphasis role="strong">direct</emphasis> parent commits if you
\r
1231 have limited your view of history: for example, if you are
\r
1232 only interested in changes related to a certain directory or
\r
1234 <simpara>There are several built-in formats, and you can define
\r
1235 additional formats by setting a pretty.<name>
\r
1236 config option to either another format name, or a
\r
1237 <emphasis>format:</emphasis> string, as described below (see
\r
1238 <xref linkend="git-config(1)" />). Here are the details of the
\r
1239 built-in formats:</simpara>
\r
1243 <emphasis>oneline</emphasis>
\r
1245 <literallayout class="monospaced"><sha1> <title line></literallayout>
\r
1246 <simpara>This is designed to be as compact as possible.</simpara>
\r
1250 <emphasis>short</emphasis>
\r
1252 <literallayout class="monospaced">commit <sha1>
\r
1253 Author: <author></literallayout>
\r
1254 <literallayout class="monospaced"><title line></literallayout>
\r
1258 <emphasis>medium</emphasis>
\r
1260 <literallayout class="monospaced">commit <sha1>
\r
1261 Author: <author>
\r
1262 Date: <author date></literallayout>
\r
1263 <literallayout class="monospaced"><title line></literallayout>
\r
1264 <literallayout class="monospaced"><full commit message></literallayout>
\r
1268 <emphasis>full</emphasis>
\r
1270 <literallayout class="monospaced">commit <sha1>
\r
1271 Author: <author>
\r
1272 Commit: <committer></literallayout>
\r
1273 <literallayout class="monospaced"><title line></literallayout>
\r
1274 <literallayout class="monospaced"><full commit message></literallayout>
\r
1278 <emphasis>fuller</emphasis>
\r
1280 <literallayout class="monospaced">commit <sha1>
\r
1281 Author: <author>
\r
1282 AuthorDate: <author date>
\r
1283 Commit: <committer>
\r
1284 CommitDate: <committer date></literallayout>
\r
1285 <literallayout class="monospaced"><title line></literallayout>
\r
1286 <literallayout class="monospaced"><full commit message></literallayout>
\r
1290 <emphasis>email</emphasis>
\r
1292 <literallayout class="monospaced">From <sha1> <date>
\r
1293 From: <author>
\r
1294 Date: <author date>
\r
1295 Subject: [PATCH] <title line></literallayout>
\r
1296 <literallayout class="monospaced"><full commit message></literallayout>
\r
1300 <emphasis>raw</emphasis>
\r
1302 <simpara>The <emphasis>raw</emphasis> format shows the entire commit exactly as
\r
1303 stored in the commit object. Notably, the SHA1s are
\r
1304 displayed in full, regardless of whether --abbrev or
\r
1305 --no-abbrev are used, and <emphasis>parents</emphasis> information show the
\r
1306 true parent commits, without taking grafts nor history
\r
1307 simplification into account.</simpara>
\r
1311 <emphasis>format:<string></emphasis>
\r
1313 <simpara>The <emphasis>format:<string></emphasis> format allows you to specify which information
\r
1314 you want to show. It works a little bit like printf format,
\r
1315 with the notable exception that you get a newline with <emphasis>%n</emphasis>
\r
1316 instead of <emphasis>\n</emphasis>.</simpara>
\r
1317 <simpara>E.g, <emphasis>format:"The author of %h was %an, %ar%nThe title was >>%s<<%n"</emphasis>
\r
1318 would show something like this:</simpara>
\r
1319 <screen>The author of fe6e0ee was Junio C Hamano, 23 hours ago
\r
1320 The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<</screen>
\r
1321 <simpara>The placeholders are:</simpara>
\r
1325 <emphasis>%H</emphasis>: commit hash
\r
1330 <emphasis>%h</emphasis>: abbreviated commit hash
\r
1335 <emphasis>%T</emphasis>: tree hash
\r
1340 <emphasis>%t</emphasis>: abbreviated tree hash
\r
1345 <emphasis>%P</emphasis>: parent hashes
\r
1350 <emphasis>%p</emphasis>: abbreviated parent hashes
\r
1355 <emphasis>%an</emphasis>: author name
\r
1360 <emphasis>%aN</emphasis>: author name (respecting .mailmap, see <xref linkend="git-shortlog(1)" /> or <xref linkend="git-blame(1)" />)
\r
1365 <emphasis>%ae</emphasis>: author email
\r
1370 <emphasis>%aE</emphasis>: author email (respecting .mailmap, see <xref linkend="git-shortlog(1)" /> or <xref linkend="git-blame(1)" />)
\r
1375 <emphasis>%ad</emphasis>: author date (format respects --date= option)
\r
1380 <emphasis>%aD</emphasis>: author date, RFC2822 style
\r
1385 <emphasis>%ar</emphasis>: author date, relative
\r
1390 <emphasis>%at</emphasis>: author date, UNIX timestamp
\r
1395 <emphasis>%ai</emphasis>: author date, ISO 8601 format
\r
1400 <emphasis>%cn</emphasis>: committer name
\r
1405 <emphasis>%cN</emphasis>: committer name (respecting .mailmap, see <xref linkend="git-shortlog(1)" /> or <xref linkend="git-blame(1)" />)
\r
1410 <emphasis>%ce</emphasis>: committer email
\r
1415 <emphasis>%cE</emphasis>: committer email (respecting .mailmap, see <xref linkend="git-shortlog(1)" /> or <xref linkend="git-blame(1)" />)
\r
1420 <emphasis>%cd</emphasis>: committer date
\r
1425 <emphasis>%cD</emphasis>: committer date, RFC2822 style
\r
1430 <emphasis>%cr</emphasis>: committer date, relative
\r
1435 <emphasis>%ct</emphasis>: committer date, UNIX timestamp
\r
1440 <emphasis>%ci</emphasis>: committer date, ISO 8601 format
\r
1445 <emphasis>%d</emphasis>: ref names, like the --decorate option of <xref linkend="git-log(1)" />
\r
1450 <emphasis>%e</emphasis>: encoding
\r
1455 <emphasis>%s</emphasis>: subject
\r
1460 <emphasis>%f</emphasis>: sanitized subject line, suitable for a filename
\r
1465 <emphasis>%b</emphasis>: body
\r
1470 <emphasis>%B</emphasis>: raw body (unwrapped subject and body)
\r
1475 <emphasis>%N</emphasis>: commit notes
\r
1480 <emphasis>%gD</emphasis>: reflog selector, e.g., <emphasis>refs/stash@{1}</emphasis>
\r
1485 <emphasis>%gd</emphasis>: shortened reflog selector, e.g., <emphasis>stash@{1}</emphasis>
\r
1490 <emphasis>%gn</emphasis>: reflog identity name
\r
1495 <emphasis>%gN</emphasis>: reflog identity name (respecting .mailmap, see <xref linkend="git-shortlog(1)" /> or <xref linkend="git-blame(1)" />)
\r
1500 <emphasis>%ge</emphasis>: reflog identity email
\r
1505 <emphasis>%gE</emphasis>: reflog identity email (respecting .mailmap, see <xref linkend="git-shortlog(1)" /> or <xref linkend="git-blame(1)" />)
\r
1510 <emphasis>%gs</emphasis>: reflog subject
\r
1515 <emphasis>%Cred</emphasis>: switch color to red
\r
1520 <emphasis>%Cgreen</emphasis>: switch color to green
\r
1525 <emphasis>%Cblue</emphasis>: switch color to blue
\r
1530 <emphasis>%Creset</emphasis>: reset color
\r
1535 <emphasis>%C(…)</emphasis>: color specification, as described in color.branch.* config option
\r
1540 <emphasis>%m</emphasis>: left, right or boundary mark
\r
1545 <emphasis>%n</emphasis>: newline
\r
1550 <emphasis>%%</emphasis>: a raw <emphasis>%</emphasis>
\r
1555 <emphasis>%x00</emphasis>: print a byte from a hex code
\r
1560 <emphasis>%w([<w>[,<i1>[,<i2>]]])</emphasis>: switch line wrapping, like the -w option of
\r
1561 <xref linkend="git-shortlog(1)" />.
\r
1567 <note><simpara>Some placeholders may depend on other options given to the
\r
1568 revision traversal engine. For example, the <emphasis>%g*</emphasis> reflog options will
\r
1569 insert an empty string unless we are traversing reflog entries (e.g., by
\r
1570 <emphasis>git log -g</emphasis>). The <emphasis>%d</emphasis> placeholder will use the "short" decoration
\r
1571 format if <emphasis>--decorate</emphasis> was not already provided on the command line.</simpara></note>
\r
1572 <simpara>If you add a <emphasis>+</emphasis> (plus sign) after <emphasis>%</emphasis> of a placeholder, a line-feed
\r
1573 is inserted immediately before the expansion if and only if the
\r
1574 placeholder expands to a non-empty string.</simpara>
\r
1575 <simpara>If you add a <emphasis>-</emphasis> (minus sign) after <emphasis>%</emphasis> of a placeholder, line-feeds that
\r
1576 immediately precede the expansion are deleted if and only if the
\r
1577 placeholder expands to an empty string.</simpara>
\r
1578 <simpara>If you add a ` ` (space) after <emphasis>%</emphasis> of a placeholder, a space
\r
1579 is inserted immediately before the expansion if and only if the
\r
1580 placeholder expands to a non-empty string.</simpara>
\r
1584 <emphasis>tformat:</emphasis>
\r
1586 <simpara>The <emphasis>tformat:</emphasis> format works exactly like <emphasis>format:</emphasis>, except that it
\r
1587 provides "terminator" semantics instead of "separator" semantics. In
\r
1588 other words, each commit has the message terminator character (usually a
\r
1589 newline) appended, rather than a separator placed between entries.
\r
1590 This means that the final entry of a single-line format will be properly
\r
1591 terminated with a new line, just as the "oneline" format does.
\r
1592 For example:</simpara>
\r
1593 <screen>$ git log -2 --pretty=format:%h 4da45bef \
\r
1594 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
\r
1596 7134973 -- NO NEWLINE
\r
1598 $ git log -2 --pretty=tformat:%h 4da45bef \
\r
1599 | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
\r
1602 <simpara>In addition, any unrecognized string that has a <emphasis>%</emphasis> in it is interpreted
\r
1603 as if it has <emphasis>tformat:</emphasis> in front of it. For example, these two are
\r
1604 equivalent:</simpara>
\r
1605 <screen>$ git log -2 --pretty=tformat:%h 4da45bef
\r
1606 $ git log -2 --pretty=%h 4da45bef</screen>
\r
1610 <simplesect id="_limiting_output">
\r
1611 <title>Limiting Output</title>
\r
1612 <simpara>If you're only interested in differences in a subset of files, for
\r
1613 example some architecture-specific files, you might do:</simpara>
\r
1614 <literallayout class="monospaced">git diff-tree -r <tree-ish> <tree-ish> arch/ia64 include/asm-ia64</literallayout>
\r
1615 <simpara>and it will only show you what changed in those two directories.</simpara>
\r
1616 <simpara>Or if you are searching for what changed in just <emphasis>kernel/sched.c</emphasis>, just do</simpara>
\r
1617 <literallayout class="monospaced">git diff-tree -r <tree-ish> <tree-ish> kernel/sched.c</literallayout>
\r
1618 <simpara>and it will ignore all differences to other files.</simpara>
\r
1619 <simpara>The pattern is always the prefix, and is matched exactly. There are no
\r
1620 wildcards. Even stricter, it has to match a complete path component.
\r
1621 I.e. "foo" does not pick up <emphasis>foobar.h</emphasis>. "foo" does match <emphasis>foo/bar.h</emphasis>
\r
1622 so it can be used to name subdirectories.</simpara>
\r
1623 <simpara>An example of normal usage is:</simpara>
\r
1624 <literallayout class="monospaced">torvalds@ppc970:~/git> git diff-tree --abbrev 5319e4
\r
1625 :100664 100664 ac348b... a01513... git-fsck-objects.c</literallayout>
\r
1626 <simpara>which tells you that the last commit changed just one file (it's from
\r
1627 this one:</simpara>
\r
1628 <screen>commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
\r
1629 tree 5319e4d609cdd282069cc4dce33c1db559539b03
\r
1630 parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
\r
1631 author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
\r
1632 committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
\r
1634 Make "git-fsck-objects" print out all the root commits it finds.
\r
1636 Once I do the reference tracking, I'll also make it print out all the
\r
1637 HEAD commits it finds, which is even more interesting.</screen>
\r
1638 <simpara>in case you care).</simpara>
\r
1640 <simplesect id="_raw_output_format">
\r
1641 <title>Raw output format</title>
\r
1642 <simpara>The raw output format from "git-diff-index", "git-diff-tree",
\r
1643 "git-diff-files" and "git diff --raw" are very similar.</simpara>
\r
1644 <simpara>These commands all compare two sets of things; what is
\r
1645 compared differs:</simpara>
\r
1649 git-diff-index <tree-ish>
\r
1653 compares the <tree-ish> and the files on the filesystem.
\r
1659 git-diff-index --cached <tree-ish>
\r
1663 compares the <tree-ish> and the index.
\r
1669 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…]
\r
1673 compares the trees named by the two arguments.
\r
1679 git-diff-files [<pattern>…]
\r
1683 compares the index and the files on the filesystem.
\r
1688 <simpara>The "git-diff-tree" command begins its output by printing the hash of
\r
1689 what is being compared. After that, all the commands print one output
\r
1690 line per changed file.</simpara>
\r
1691 <simpara>An output line is formatted this way:</simpara>
\r
1692 <screen>in-place edit :100644 100644 bcd1234... 0123456... M file0
\r
1693 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
\r
1694 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
\r
1695 create :000000 100644 0000000... 1234567... A file4
\r
1696 delete :100644 000000 1234567... 0000000... D file5
\r
1697 unmerged :000000 000000 0000000... 0000000... U file6</screen>
\r
1698 <simpara>That is, from the left to the right:</simpara>
\r
1699 <orderedlist numeration="arabic">
\r
1707 mode for "src"; 000000 if creation or unmerged.
\r
1717 mode for "dst"; 000000 if deletion or unmerged.
\r
1727 sha1 for "src"; 0{40} if creation or unmerged.
\r
1737 sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
\r
1747 status, followed by optional "score" number.
\r
1752 a tab or a NUL when <emphasis>-z</emphasis> option is used.
\r
1762 a tab or a NUL when <emphasis>-z</emphasis> option is used; only exists for C or R.
\r
1767 path for "dst"; only exists for C or R.
\r
1772 an LF or a NUL when <emphasis>-z</emphasis> option is used, to terminate the record.
\r
1776 <simpara>Possible status letters are:</simpara>
\r
1780 A: addition of a file
\r
1785 C: copy of a file into a new one
\r
1790 D: deletion of a file
\r
1795 M: modification of the contents or mode of a file
\r
1800 R: renaming of a file
\r
1805 T: change in the type of the file
\r
1810 U: file is unmerged (you must complete the merge before it can
\r
1816 X: "unknown" change type (most probably a bug, please report it)
\r
1820 <simpara>Status letters C and R are always followed by a score (denoting the
\r
1821 percentage of similarity between the source and target of the move or
\r
1822 copy), and are the only ones to be so.</simpara>
\r
1823 <simpara><sha1> is shown as all 0's if a file is new on the filesystem
\r
1824 and it is out of sync with the index.</simpara>
\r
1825 <simpara>Example:</simpara>
\r
1826 <screen>:100644 100644 5be4a4...... 000000...... M file.c</screen>
\r
1827 <simpara>When <emphasis>-z</emphasis> option is not used, TAB, LF, and backslash characters
\r
1828 in pathnames are represented as <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, and <emphasis>\\</emphasis>,
\r
1829 respectively.</simpara>
\r
1831 <simplesect id="_diff_format_for_merges">
\r
1832 <title>diff format for merges</title>
\r
1833 <simpara>"git-diff-tree", "git-diff-files" and "git-diff --raw"
\r
1834 can take <emphasis>-c</emphasis> or <emphasis>--cc</emphasis> option
\r
1835 to generate diff output also for merge commits. The output differs
\r
1836 from the format described above in the following way:</simpara>
\r
1837 <orderedlist numeration="arabic">
\r
1840 there is a colon for each parent
\r
1845 there are more "src" modes and "src" sha1
\r
1850 status is concatenated status characters for each parent
\r
1855 no optional "score" number
\r
1860 single path, only for "dst"
\r
1864 <simpara>Example:</simpara>
\r
1865 <screen>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</screen>
\r
1866 <simpara>Note that <emphasis>combined diff</emphasis> lists only files which were modified from
\r
1867 all parents.</simpara>
\r
1869 <simplesect id="_generating_patches_with_p">
\r
1870 <title>Generating patches with -p</title>
\r
1871 <simpara>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run
\r
1872 with a <emphasis>-p</emphasis> option, "git diff" without the <emphasis>--raw</emphasis> option, or
\r
1873 "git log" with the "-p" option, they
\r
1874 do not produce the output described above; instead they produce a
\r
1875 patch file. You can customize the creation of such patches via the
\r
1876 GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</simpara>
\r
1877 <simpara>What the -p option produces is slightly different from the traditional
\r
1878 diff format:</simpara>
\r
1879 <orderedlist numeration="arabic">
\r
1882 It is preceded with a "git diff" header that looks like this:
\r
1884 <literallayout class="monospaced">diff --git a/file1 b/file2</literallayout>
\r
1885 <simpara>The <emphasis>a/</emphasis> and <emphasis>b/</emphasis> filenames are the same unless rename/copy is
\r
1886 involved. Especially, even for a creation or a deletion,
\r
1887 <emphasis>/dev/null</emphasis> is <emphasis>not</emphasis> used in place of the <emphasis>a/</emphasis> or <emphasis>b/</emphasis> filenames.</simpara>
\r
1888 <simpara>When rename/copy is involved, <emphasis>file1</emphasis> and <emphasis>file2</emphasis> show the
\r
1889 name of the source file of the rename/copy and the name of
\r
1890 the file that rename/copy produces, respectively.</simpara>
\r
1894 It is followed by one or more extended header lines:
\r
1896 <literallayout class="monospaced">old mode <mode>
\r
1897 new mode <mode>
\r
1898 deleted file mode <mode>
\r
1899 new file mode <mode>
\r
1900 copy from <path>
\r
1901 copy to <path>
\r
1902 rename from <path>
\r
1903 rename to <path>
\r
1904 similarity index <number>
\r
1905 dissimilarity index <number>
\r
1906 index <hash>..<hash> <mode></literallayout>
\r
1907 <simpara>File modes are printed as 6-digit octal numbers including the file type
\r
1908 and file permission bits.</simpara>
\r
1909 <simpara>Path names in extended headers do not include the <emphasis>a/</emphasis> and <emphasis>b/</emphasis> prefixes.</simpara>
\r
1910 <simpara>The similarity index is the percentage of unchanged lines, and
\r
1911 the dissimilarity index is the percentage of changed lines. It
\r
1912 is a rounded down integer, followed by a percent sign. The
\r
1913 similarity index value of 100% is thus reserved for two equal
\r
1914 files, while 100% dissimilarity means that no line from the old
\r
1915 file made it into the new one.</simpara>
\r
1916 <simpara>The index line includes the SHA-1 checksum before and after the change.
\r
1917 The <mode> is included if the file mode does not change; otherwise,
\r
1918 separate lines indicate the old and the new mode.</simpara>
\r
1922 TAB, LF, double quote and backslash characters in pathnames
\r
1923 are represented as <emphasis>\t</emphasis>, <emphasis>\n</emphasis>, <emphasis>\"</emphasis> and <emphasis>\\</emphasis>, respectively.
\r
1924 If there is need for such substitution then the whole
\r
1925 pathname is put in double quotes.
\r
1930 All the <emphasis>file1</emphasis> files in the output refer to files before the
\r
1931 commit, and all the <emphasis>file2</emphasis> files refer to files after the commit.
\r
1932 It is incorrect to apply each change to each file sequentially. For
\r
1933 example, this patch will swap a and b:
\r
1935 <literallayout class="monospaced">diff --git a/a b/b
\r
1938 diff --git a/b b/a
\r
1940 rename to a</literallayout>
\r
1944 <simplesect id="_combined_diff_format">
\r
1945 <title>combined diff format</title>
\r
1946 <simpara>Any diff-generating command can take the -c` or <emphasis>--cc</emphasis> option to
\r
1947 produce a <emphasis>combined diff</emphasis> when showing a merge. This is the default
\r
1948 format when showing merges with <xref linkend="git-diff(1)" /> or
\r
1949 <xref linkend="git-show(1)" />. Note also that you can give the `-m option to any
\r
1950 of these commands to force generation of diffs with individual parents
\r
1951 of a merge.</simpara>
\r
1952 <simpara>A <emphasis>combined diff</emphasis> format looks like this:</simpara>
\r
1953 <screen>diff --combined describe.c
\r
1954 index fabadb8,cc95eb0..4866510
\r
1957 @@@ -98,20 -98,12 +98,20 @@@
\r
1958 return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
\r
1961 - static void describe(char *arg)
\r
1962 -static void describe(struct commit *cmit, int last_one)
\r
1963 ++static void describe(char *arg, int last_one)
\r
1965 + unsigned char sha1[20];
\r
1966 + struct commit *cmit;
\r
1967 struct commit_list *list;
\r
1968 static int initialized = 0;
\r
1969 struct commit_name *n;
\r
1971 + if (get_sha1(arg, sha1) < 0)
\r
1972 + usage(describe_usage);
\r
1973 + cmit = lookup_commit_reference(sha1);
\r
1975 + usage(describe_usage);
\r
1977 if (!initialized) {
\r
1979 for_each_ref(get_name);</screen>
\r
1980 <orderedlist numeration="arabic">
\r
1983 It is preceded with a "git diff" header, that looks like
\r
1984 this (when <emphasis>-c</emphasis> option is used):
\r
1986 <literallayout class="monospaced">diff --combined file</literallayout>
\r
1987 <simpara>or like this (when <emphasis>--cc</emphasis> option is used):</simpara>
\r
1988 <literallayout class="monospaced">diff --cc file</literallayout>
\r
1992 It is followed by one or more extended header lines
\r
1993 (this example shows a merge with two parents):
\r
1995 <literallayout class="monospaced">index <hash>,<hash>..<hash>
\r
1996 mode <mode>,<mode>..<mode>
\r
1997 new file mode <mode>
\r
1998 deleted file mode <mode>,<mode></literallayout>
\r
1999 <simpara>The <emphasis>mode <mode>,<mode>..<mode></emphasis> line appears only if at least one of
\r
2000 the <mode> is different from the rest. Extended headers with
\r
2001 information about detected contents movement (renames and
\r
2002 copying detection) are designed to work with diff of two
\r
2003 <tree-ish> and are not used by combined diff format.</simpara>
\r
2007 It is followed by two-line from-file/to-file header
\r
2009 <literallayout class="monospaced">--- a/file
\r
2010 +++ b/file</literallayout>
\r
2011 <simpara>Similar to two-line header for traditional <emphasis>unified</emphasis> diff
\r
2012 format, <emphasis>/dev/null</emphasis> is used to signal created or deleted
\r
2017 Chunk header format is modified to prevent people from
\r
2018 accidentally feeding it to <emphasis>patch -p1</emphasis>. Combined diff format
\r
2019 was created for review of merge commit changes, and was not
\r
2020 meant for apply. The change is similar to the change in the
\r
2021 extended <emphasis>index</emphasis> header:
\r
2023 <literallayout class="monospaced">@@@ <from-file-range> <from-file-range> <to-file-range> @@@</literallayout>
\r
2024 <simpara>There are (number of parents + 1) <emphasis>@</emphasis> characters in the chunk
\r
2025 header for combined diff format.</simpara>
\r
2028 <simpara>Unlike the traditional <emphasis>unified</emphasis> diff format, which shows two
\r
2029 files A and B with a single column that has <emphasis>-</emphasis> (minus --
\r
2030 appears in A but removed in B), <emphasis>+</emphasis> (plus -- missing in A but
\r
2031 added to B), or <emphasis>" "</emphasis> (space -- unchanged) prefix, this format
\r
2032 compares two or more files file1, file2,… with one file X, and
\r
2033 shows how X differs from each of fileN. One column for each of
\r
2034 fileN is prepended to the output line to note how X's line is
\r
2035 different from it.</simpara>
\r
2036 <simpara>A <emphasis>-</emphasis> character in the column N means that the line appears in
\r
2037 fileN but it does not appear in the result. A <emphasis>+</emphasis> character
\r
2038 in the column N means that the line appears in the result,
\r
2039 and fileN does not have that line (in other words, the line was
\r
2040 added, from the point of view of that parent).</simpara>
\r
2041 <simpara>In the above example output, the function signature was changed
\r
2042 from both files (hence two <emphasis>-</emphasis> removals from both file1 and
\r
2043 file2, plus <emphasis>++</emphasis> to mean one line that was added does not appear
\r
2044 in either file1 nor file2). Also eight other lines are the same
\r
2045 from file1 but do not appear in file2 (hence prefixed with <emphasis>+</emphasis>).</simpara>
\r
2046 <simpara>When shown by <emphasis>git diff-tree -c</emphasis>, it compares the parents of a
\r
2047 merge commit with the merge result (i.e. file1..fileN are the
\r
2048 parents). When shown by <emphasis>git diff-files -c</emphasis>, it compares the
\r
2049 two unresolved merge parents with the working tree file
\r
2050 (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka
\r
2051 "their version").</simpara>
\r
2053 <simplesect id="_other_diff_formats">
\r
2054 <title>other diff formats</title>
\r
2055 <simpara>The <emphasis>--summary</emphasis> option describes newly added, deleted, renamed and
\r
2056 copied files. The <emphasis>--stat</emphasis> option adds diffstat(1) graph to the
\r
2057 output. These options can be combined with other options, such as
\r
2058 <emphasis>-p</emphasis>, and are meant for human consumption.</simpara>
\r
2059 <simpara>When showing a change that involves a rename or a copy, <emphasis>--stat</emphasis> output
\r
2060 formats the pathnames compactly by combining common prefix and suffix of
\r
2061 the pathnames. For example, a change that moves <emphasis>arch/i386/Makefile</emphasis> to
\r
2062 <emphasis>arch/x86/Makefile</emphasis> while modifying 4 lines will be shown like this:</simpara>
\r
2063 <screen>arch/{i386 => x86}/Makefile | 4 +--</screen>
\r
2064 <simpara>The <emphasis>--numstat</emphasis> option gives the diffstat(1) information but is designed
\r
2065 for easier machine consumption. An entry in <emphasis>--numstat</emphasis> output looks
\r
2066 like this:</simpara>
\r
2067 <screen>1 2 README
\r
2068 3 1 arch/{i386 => x86}/Makefile</screen>
\r
2069 <simpara>That is, from left to right:</simpara>
\r
2070 <orderedlist numeration="arabic">
\r
2073 the number of added lines;
\r
2083 the number of deleted lines;
\r
2093 pathname (possibly with rename/copy information);
\r
2102 <simpara>When <emphasis>-z</emphasis> output option is in effect, the output is formatted this way:</simpara>
\r
2103 <screen>1 2 README NUL
\r
2104 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</screen>
\r
2105 <simpara>That is:</simpara>
\r
2106 <orderedlist numeration="arabic">
\r
2109 the number of added lines;
\r
2119 the number of deleted lines;
\r
2129 a NUL (only exists if renamed/copied);
\r
2134 pathname in preimage;
\r
2139 a NUL (only exists if renamed/copied);
\r
2144 pathname in postimage (only exists if renamed/copied);
\r
2153 <simpara>The extra <emphasis>NUL</emphasis> before the preimage path in renamed case is to allow
\r
2154 scripts that read the output to tell if the current record being read is
\r
2155 a single-path record or a rename/copy record without reading ahead.
\r
2156 After reading added and deleted lines, reading up to <emphasis>NUL</emphasis> would yield
\r
2157 the pathname, but if that is <emphasis>NUL</emphasis>, the record will show two paths.</simpara>
\r
2159 <simplesect id="_git">
\r
2160 <title>GIT</title>
\r
2161 <simpara>Part of the <xref linkend="git(1)" /> suite</simpara>
\r