Linux "git-diff" Command Line Options and Examples
Show changes between commits, commit and working tree, etc

Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes between two blob objects, or changes between two files on disk. git diff [--options] [--] [<path>..


Usage:

git diff [options] [] [--] [...]
git diff [options] --cached [] [--] [...]
git diff [options] [--] [...]
git diff [options]
git diff [options] [--no-index] [--]






Command Line Options:

-p
Generate patch (see section on generating patches). This is the default.
git-diff -p ...
-s
Suppress diff output. Useful for commands like git show that show the patch by default, or to cancel the effect of --patch.
git-diff -s ...
-U<n>
Generate diffs with <n> lines of context instead of the usual three. Implies -p.
git-diff -U<n> ...
--raw
Generate the diff in raw format.
git-diff --raw ...
--patch-with-raw
Synonym for -p --raw.
git-diff --patch-with-raw ...
--indent-heuristic
Enable the heuristic that shift diff hunk boundaries to make patches easier to read. This is the default.
git-diff --indent-heuristic ...
--no-indent-heuristic
Disable the indent heuristic.
git-diff --no-indent-heuristic ...
--minimal
Spend extra time to make sure the smallest possible diff is produced.
git-diff --minimal ...
--patience
Generate a diff using the "patience diff" algorithm.
git-diff --patience ...
--histogram
Generate a diff using the "histogram diff" algorithm.
git-diff --histogram ...
--anchored
Generate a diff using the "anchored diff" algorithm.This option may be specified more than once.If a line exists in both the source and destination, exists only once, and starts with this text, this algorithm attempts toprevent it from appearing as a deletion or addition in the output. It uses the "patience diff" algorithm internally.
git-diff --anchored ...
--diff-algorithm
Choose a diff algorithm. The variants are as follows:default, myersThe basic greedy diff algorithm. Currently, this is the default.minimalSpend extra time to make sure the smallest possible diff is produced.patienceUse "patience diff" algorithm when generating patches.histogramThis algorithm extends the patience algorithm to "support low-occurrence common elements".For instance, if you configured diff.algorithm variable to a non-default value and want to use the default one, then you have touse --diff-algorithm=default option.
git-diff --diff-algorithm ...
--stat[
Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part.Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <width>. Thewidth of the filename part can be limited by giving another width <name-width> after a comma. The width of the graph part can belimited by using --stat-graph-width=<width> (affects all commands generating a stat graph) or by settingdiff.statGraphWidth=<width> (does not affect git format-patch). By giving a third parameter <count>, you can limit the output tothe first <count> lines, followed by ... if there are more.These parameters can also be set individually with --stat-width=<width>, --stat-name-width=<name-width> and --stat-count=<count>.
git-diff --stat[ ...
--compact-summary
Output a condensed summary of extended header information such as file creations or deletions ("new" or "gone", optionally "+l"if it’s a symlink) and mode changes ("+x" or "-x" for adding or removing executable bit respectively) in diffstat. Theinformation is put betwen the filename part and the graph part. Implies --stat.
git-diff --compact-summary ...
--numstat
Similar to --stat, but shows number of added and deleted lines in decimal notation and pathname without abbreviation, to make itmore machine friendly. For binary files, outputs two - instead of saying 0 0.
git-diff --numstat ...
--shortstat
Output only the last line of the --stat format containing total number of modified files, as well as number of added and deletedlines.
git-diff --shortstat ...
--dirstat[
Output the distribution of relative amount of changes for each sub-directory. The behavior of --dirstat can be customized bypassing it a comma separated list of parameters. The defaults are controlled by the diff.dirstat configuration variable (see git-config(1)). The following parameters are available:changesCompute the dirstat numbers by counting the lines that have been removed from the source, or added to the destination. Thisignores the amount of pure code movements within a file. In other words, rearranging lines in a file is not counted as muchas other changes. This is the default behavior when no parameter is given.linesCompute the dirstat numbers by doing the regular line-based diff analysis, and summing the removed/added line counts. (Forbinary files, count 64-byte chunks instead, since binary files have no natural concept of lines). This is a more expensive
git-diff --dirstat[ ...
--summary
Output a condensed summary of extended header information such as creations, renames and mode changes.
git-diff --summary ...
--patch-with-stat
Synonym for -p --stat.
git-diff --patch-with-stat ...
-z
When --raw, --numstat, --name-only or --name-status has been given, do not munge pathnames and use NULs as output fieldterminators.Without this option, pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath(see git-config(1)).
git-diff -z ...
--name-only
Show only names of changed files.
git-diff --name-only ...
--name-status
Show only names and status of changed files. See the description of the --diff-filter option on what the status letters mean.
git-diff --name-status ...
--submodule[
Specify how differences in submodules are shown. When specifying --submodule=short the short format is used. This format justshows the names of the commits at the beginning and end of the range. When --submodule or --submodule=log is specified, the logformat is used. This format lists the commits in the range like git-submodule(1) summary does. When --submodule=diff isspecified, the diff format is used. This format shows an inline diff of the changes in the submodule contents between the commitrange. Defaults to diff.submodule or the short format if the config option is unset.
git-diff --submodule[ ...
--color[
Show colored diff. --color (i.e. without =<when>) is the same as --color=always. <when> can be one of always, never, or auto.It can be changed by the color.ui and color.diff configuration settings.
git-diff --color[ ...
--no-color
Turn off colored diff. This can be used to override configuration settings. It is the same as --color=never.
git-diff --no-color ...
--color-moved[
Moved lines of code are colored differently. It can be changed by the diff.colorMoved configuration setting. The <mode> defaultsto no if the option is not given and to zebra if the option with no mode is given. The mode must be one of:noMoved lines are not highlighted.defaultIs a synonym for zebra. This may change to a more sensible mode in the future.plainAny line that is added in one location and was removed in another location will be colored with color.diff.newMoved.Similarly color.diff.oldMoved will be used for removed lines that are added somewhere else in the diff. This mode picks upany moved line, but it is not very useful in a review to determine if a block of code was moved without permutation.zebraBlocks of moved text of at least 20 alphanumeric characters are detected greedily. The detected blocks are painted usingeither the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative. The change between the two colorsindicates that a new block was detected.dimmed_zebraSimilar to zebra, but additional dimming of uninteresting parts of moved code is performed. The bordering lines of twoadjacent blocks are considered interesting, the rest is uninteresting.
git-diff --color-moved[ ...
--word-diff[
Show a word diff, using the <mode> to delimit changed words. By default, words are delimited by whitespace; see --word-diff-regexbelow. The <mode> defaults to plain, and must be one of:colorHighlight changed words using only colors. Implies --color.plainShow words as [-removed-] and {+added+}. Makes no attempts to escape the delimiters if they appear in the input, so theoutput may be ambiguous.porcelainUse a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usualunified diff format, starting with a +/-/` ` character at the beginning of the line and extending to the end of the line.Newlines in the input are represented by a tilde ~ on a line of its own.noneDisable word diff again.Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled.
git-diff --word-diff[ ...
--word-diff-regex
Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies --word-diff unlessit was already enabled.Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace andignored(!) for the purposes of finding differences. You may want to append |[^[:space:]] to your regular expression to make surethat it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.For example, --word-diff-regex=. will treat each character as a word and, correspondingly, show differences character bycharacter.The regex can also be set via a diff driver or configuration option, see gitattributes(5) or git-config(1). Giving it explicitlyoverrides any diff driver or configuration setting. Diff drivers override configuration settings.
git-diff --word-diff-regex ...
--color-words[
Equivalent to --word-diff=color plus (if a regex was specified) --word-diff-regex=<regex>.
git-diff --color-words[ ...
--no-renames
Turn off rename detection, even when the configuration file gives the default to do so.
git-diff --no-renames ...
--check
Warn if changes introduce conflict markers or whitespace errors. What are considered whitespace errors is controlled bycore.whitespace configuration. By default, trailing whitespaces (including lines that solely consist of whitespaces) and a spacecharacter that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors.Exits with non-zero status if problems are found. Not compatible with --exit-code.
git-diff --check ...
--ws-error-highlight
Highlight whitespace errors in the context, old or new lines of the diff. Multiple values are separated by comma, none resetsprevious values, default reset the list to new and all is a shorthand for old,new,context. When this option is not given, and theconfiguration variable diff.wsErrorHighlight is not set, only whitespace errors in new lines are highlighted. The whitespaceerrors are colored whith color.diff.whitespace.
git-diff --ws-error-highlight ...
--full-index
Instead of the first handful of characters, show the full pre- and post-image blob object names on the "index" line whengenerating patch format output.
git-diff --full-index ...
--binary
In addition to --full-index, output a binary diff that can be applied with git-apply.
git-diff --binary ...
--abbrev[
Instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show only apartial prefix. This is independent of the --full-index option above, which controls the diff-patch output format. Non defaultnumber of digits can be specified with --abbrev=<n>.
git-diff --abbrev[ ...
-B[<n>][/<m>]
Break complete rewrite changes into pairs of delete and create. This serves two purposes:It affects the way a change that amounts to a total rewrite of a file not as a series of deletion and insertion mixed togetherwith a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by asingle insertion of everything new, and the number m controls this aspect of the -B option (defaults to 60%). -B/70% specifiesthat less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise theresulting patch will be a series of deletion and insertion mixed together with context lines).When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file thatdisappeared as the source of a rename), and the number n controls this aspect of the -B option (defaults to 50%). -B20%specifies that a change with addition and deletion compared to 20% or more of the file’s size are eligible for being picked up asa possible source of a rename to another file.
git-diff -B[<n>][/<m>] ...
-M[<n>]
Detect renames. If n is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to thefile’s size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’tchanged. Without a % sign, the number is to be read as a fraction, with a decimal point before it. I.e., -M5 becomes 0.5, and isthus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to exact renames, use -M100%. The defaultsimilarity index is 50%.
git-diff -M[<n>] ...
-C[<n>]
Detect copies as well as renames. See also --find-copies-harder. If n is specified, it has the same meaning as for -M<n>.
git-diff -C[<n>] ...
--find-copies-harder
For performance reasons, by default, -C option finds copies only if the original file of the copy was modified in the samechangeset. This flag makes the command inspect unmodified files as candidates for the source of copy. This is a very expensiveoperation for large projects, so use it with caution. Giving more than one -C option has the same effect.
git-diff --find-copies-harder ...
-D
Omit the preimage for deletes, i.e. print only the header but not the diff between the preimage and /dev/null. The resultingpatch is not meant to be applied with patch or git apply; this is solely for people who want to just concentrate on reviewing thetext after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, evenmanually, hence the name of the option.When used together with -B, omit also the preimage in the deletion part of a delete/create pair.
git-diff -D ...
-l<num>
The -M and -C options require O(n^2) processing time where n is the number of potential rename/copy targets. This option preventsrename/copy detection from running if the number of rename/copy targets exceeds the specified number.
git-diff -l<num> ...
--diff-filter
Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file,symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination ofthe filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected ifthere is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing isselected.Also, these upper-case letters can be downcased to exclude. E.g. --diff-filter=ad excludes added and deleted paths.Note that not all diffs can feature all types. For instance, diffs from the index to the working tree can never have Addedentries (because the set of paths included in the diff is limited by what is in the index). Similarly, copied and renamed entriescannot appear if detection for those types is disabled.
git-diff --diff-filter ...
-S<string>
Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intendedfor the scripter’s use.It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since itfirst came into being: use the feature iteratively to feed the interesting block in the preimage back into -S, and keep goinguntil you get the very first version of the block.
git-diff -S<string> ...
-G<regex>
Look for differences whose patch text contains added/removed lines that match <regex>.To illustrate the difference between -S<regex> --pickaxe-regex and -G<regex>, consider a commit with the following diff in thesame file:+ return !regexec(regexp, two->ptr, 1, &regmatch, 0);...
git-diff -G<regex> ...
-
While git log -G"regexec\(regexp" will show this commit, git log -S"regexec\(regexp" --pickaxe-regex will not (because the numberof occurrences of that string did not change).See the pickaxe entry in gitdiffcore(7) for more information.
git-diff - ...
--find-object
Look for differences that change the number of occurrences of the specified object. Similar to -S, just the argument is differentin that it doesn’t search for a specific string but for a specific object id.The object can be a blob or a submodule commit. It implies the -t option in git-log to also find trees.
git-diff --find-object ...
--pickaxe-all
When -S or -G finds a change, show all the changes in that changeset, not just the files that contain the change in <string>.
git-diff --pickaxe-all ...
--pickaxe-regex
Treat the <string> given to -S as an extended POSIX regular expression to match.
git-diff --pickaxe-regex ...
-O<orderfile>
Control the order in which files appear in the output. This overrides the diff.orderFile configuration variable (see git-config(1)). To cancel diff.orderFile, use -O/dev/null.The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the firstpattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on.All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the endof the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output orderrelative to each other is the normal order.<orderfile> is parsed as follows:· Blank lines are ignored, so they can be used as separators for readability.· Lines starting with a hash ("#") are ignored, so they can be used for comments. Add a backslash ("\") to the beginning of thepattern if it starts with a hash.· Each other line contains a single pattern.Patterns have the same syntax and semantics as patterns used for fnmantch(3) without the FNM_PATHNAME flag, except a pathnamealso matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern"foo*bar" matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx".
git-diff -O<orderfile> ...
-R
Swap two inputs; that is, show differences from index or on-disk file to tree contents.
git-diff -R ...
--relative[
When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relativeto it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to makethe output relative to by giving a <path> as an argument.
git-diff --relative[ ...
-a
Treat all files as text.
git-diff -a ...
--ignore-cr-at-eol
Ignore carrige-return at the end of line when doing a comparison.
git-diff --ignore-cr-at-eol ...
--ignore-space-at-eol
Ignore changes in whitespace at EOL.
git-diff --ignore-space-at-eol ...
-b
Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or morewhitespace characters to be equivalent.
git-diff -b ...
-w
Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
git-diff -w ...
--ignore-blank-lines
Ignore changes whose lines are all blank.
git-diff --ignore-blank-lines ...
--inter-hunk-context
Show the context between diff hunks, up to the specified number of lines, thereby fusing hunks that are close to each other.Defaults to diff.interHunkContext or 0 if the config option is unset.
git-diff --inter-hunk-context ...
-W
Show whole surrounding functions of changes.
git-diff -W ...
--exit-code
Make the program exit with codes similar to diff(1). That is, it exits with 1 if there were differences and 0 means nodifferences.
git-diff --exit-code ...
--quiet
Disable all output of the program. Implies --exit-code.
git-diff --quiet ...
--ext-diff
Allow an external diff helper to be executed. If you set an external diff driver with gitattributes(5), you need to use thisoption with git-log(1) and friends.
git-diff --ext-diff ...
--no-ext-diff
Disallow external diff drivers.
git-diff --no-ext-diff ...
--textconv
Allow (or disallow) external text conversion filters to be run when comparing binary files. See gitattributes(5) for details.Because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption, but cannot beapplied. For this reason, textconv filters are enabled by default only for git-diff(1) and git-log(1), but not for git-format-patch(1) or diff plumbing commands.
git-diff --textconv ...
--ignore-submodules[
Ignore changes to submodules in the diff generation. <when> can be either "none", "untracked", "dirty" or "all", which is thedefault. Using "none" will consider the submodule modified when it either contains untracked or modified files or its HEADdiffers from the commit recorded in the superproject and can be used to override any settings of the ignore option in git-config(1) or gitmodules(5). When "untracked" is used submodules are not considered dirty when they only contain untracked content(but they are still scanned for modified content). Using "dirty" ignores all changes to the work tree of submodules, only changesto the commits stored in the superproject are shown (this was the behavior until 1.7.0). Using "all" hides all changes tosubmodules.
git-diff --ignore-submodules[ ...
--src-prefix
Show the given source prefix instead of "a/".
git-diff --src-prefix ...
--dst-prefix
Show the given destination prefix instead of "b/".
git-diff --dst-prefix ...
--no-prefix
Do not show any source or destination prefix.
git-diff --no-prefix ...
--line-prefix
Prepend an additional prefix to every line of output.
git-diff --line-prefix ...
--ita-invisible-in-index
By default entries added by "git add -N" appear as an existing empty file in "git diff" and a new file in "git diff --cached".This option makes the entry appear as a new file in "git diff" and non-existent in "git diff --cached". This option could bereverted with --ita-visible-in-index. Both options are experimental and could be removed in future.For more detailed explanation on these common options, see also gitdiffcore(7).
git-diff --ita-invisible-in-index ...
-1
Compare the working tree with the "base" version (stage #1), "our branch" (stage #2) or "their branch" (stage #3). The indexcontains these stages only for unmerged entries i.e. while resolving conflicts. See git-read-tree(1) section "3-Way Merge" fordetailed information.
git-diff -1 ...
-0
Omit diff output for unmerged entries and just show "Unmerged". Can be used only when comparing the working tree with the index.<path>...The <paths> parameters, when given, are used to limit the diff to the named paths (you can give directory names and get diff forall files under them).RAW OUTPUT FORMATThe raw output format from "git-diff-index", "git-diff-tree", "git-diff-files" and "git diff --raw" are very similar.These commands all compare two sets of things; what is compared differs:git-diff-index <tree-ish>compares the <tree-ish> and the files on the filesystem.git-diff-index --cached <tree-ish>compares the <tree-ish> and the index.git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]compares the trees named by the two arguments.git-diff-files [<pattern>...]compares the index and the files on the filesystem.The "git-diff-tree" command begins its output by printing the hash of what is being compared. After that, all the commands print oneoutput line per changed file.An output line is formatted this way:in-place edit :100644 100644 bcd1234... 0123456... M file0copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3create :000000 100644 0000000... 1234567... A file4delete :100644 000000 1234567... 0000000... D file5unmerged :000000 000000 0000000... 0000000... U file6That is, from the left to the right:1. a colon.2. mode for "src"; 000000 if creation or unmerged.3. a space.4. mode for "dst"; 000000 if deletion or unmerged.5. a space.6. sha1 for "src"; 0{40} if creation or unmerged.7. a space.8. sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".9. a space.10. status, followed by optional "score" number.11. a tab or a NUL when -z option is used.12. path for "src"13. a tab or a NUL when -z option is used; only exists for C or R.14. path for "dst"; only exists for C or R.15. an LF or a NUL when -z option is used, to terminate the record.Possible status letters are:· A: addition of a file· C: copy of a file into a new one· D: deletion of a file· M: modification of the contents or mode of a file· R: renaming of a file· T: change in the type of the file· U: file is unmerged (you must complete the merge before it can be committed)· X: "unknown" change type (most probably a bug, please report it)Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of themove or copy). Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites.<sha1> is shown as all 0’s if a file is new on the filesystem and it is out of sync with the index.Example::100644 100644 5be4a4...... 000000...... M file.cWithout the -z option, pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (seegit-config(1)). Using -z the filename is output verbatim and the line is terminated by a NUL byte.DIFF FORMAT FOR MERGES"git-diff-tree", "git-diff-files" and "git-diff --raw" can take -c or --cc option to generate diff output also for merge commits. Theoutput differs from the format described above in the following way:1. there is a colon for each parent2. there are more "src" modes and "src" sha13. status is concatenated status characters for each parent4. no optional "score" number5. single path, only for "dst"Example:::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.cNote that combined diff lists only files which were modified from all parents.GENERATING PATCHES WITH -PWhen "git-diff-index", "git-diff-tree", or "git-diff-files" are run with a -p option, "git diff" without the --raw option, or "gitlog" with the "-p" option, they do not produce the output described above; instead they produce a patch file. You can customize thecreation of such patches via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.What the -p option produces is slightly different from the traditional diff format:1. It is preceded with a "git diff" header that looks like this:diff --git a/file1 b/file2The a/ and b/ filenames are the same unless rename/copy is involved. Especially, even for a creation or a deletion, /dev/null isnot used in place of the a/ or b/ filenames.When rename/copy is involved, file1 and file2 show the name of the source file of the rename/copy and the name of the file thatrename/copy produces, respectively.2. It is followed by one or more extended header lines:old mode <mode>new mode <mode>deleted file mode <mode>new file mode <mode>copy from <path>copy to <path>rename from <path>rename to <path>similarity index <number>dissimilarity index <number>index <hash>..<hash> <mode>File modes are printed as 6-digit octal numbers including the file type and file permission bits.Path names in extended headers do not include the a/ and b/ prefixes.The similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. It isa rounded down integer, followed by a percent sign. The similarity index value of 100% is thus reserved for two equal files,while 100% dissimilarity means that no line from the old file made it into the new one.The index line includes the SHA-1 checksum before and after the change. The <mode> is included if the file mode does not change;otherwise, separate lines indicate the old and the new mode.3. Pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see git-config(1)).4. All the file1 files in the output refer to files before the commit, and all the file2 files refer to files after the commit. Itis incorrect to apply each change to each file sequentially. For example, this patch will swap a and b:diff --git a/a b/brename from arename to bdiff --git a/b b/arename from brename to aCOMBINED DIFF FORMATAny diff-generating command can take the -c or --cc option to produce a combined diff when showing a merge. This is the defaultformat when showing merges with git-diff(1) or git-show(1). Note also that you can give the -m option to any of these commands toforce generation of diffs with individual parents of a merge.A combined diff format looks like this:diff --combined describe.cindex fabadb8,cc95eb0..4866510
git-diff -0 ...
-static
++static void describe(char *arg, int last_one){+ unsigned char sha1[20];+ struct commit *cmit;struct commit_list *list;static int initialized = 0;struct commit_name *n;+ if (get_sha1(arg, sha1) < 0)+ usage(describe_usage);+ cmit = lookup_commit_reference(sha1);+ if (!cmit)+ usage(describe_usage);+if (!initialized) {initialized = 1;for_each_ref(get_name);1. It is preceded with a "git diff" header, that looks like this (when -c option is used):diff --combined fileor like this (when --cc option is used):diff --cc file2. It is followed by one or more extended header lines (this example shows a merge with two parents):index <hash>,<hash>..<hash>mode <mode>,<mode>..<mode>new file mode <mode>deleted file mode <mode>,<mode>The mode <mode>,<mode>..<mode> line appears only if at least one of the <mode> is different from the rest. Extended headers withinformation about detected contents movement (renames and copying detection) are designed to work with diff of two <tree-ish> andare not used by combined diff format.3. It is followed by two-line from-file/to-file header
git-diff -static ...