Home Explore Blog CI



git

3rd chunk of `Documentation/diff-format.adoc`
c563258dccee7f5f363f2f935501d3ff6709fa0e2c01dfc20000000100000c20
 tab-separated pathname(s) of the file

For `-c` and `--cc`, only the destination or final path is shown even
if the file was renamed on any side of history.  With
`--combined-all-paths`, the name of the path in each parent is shown
followed by the name of the path in the merge commit.

Examples for `-c` and `--cc` without `--combined-all-paths`:
------------------------------------------------
::100644 100644 100644 fabadb8 cc95eb0 4866510 MM	desc.c
::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM	bar.sh
::100644 100644 100644 e07d6c5 9042e82 ee91881 RR	phooey.c
------------------------------------------------

Examples when `--combined-all-paths` added to either `-c` or `--cc`:

------------------------------------------------
::100644 100644 100644 fabadb8 cc95eb0 4866510 MM	desc.c	desc.c	desc.c
::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM	foo.sh	bar.sh	bar.sh
::100644 100644 100644 e07d6c5 9042e82 ee91881 RR	fooey.c	fuey.c	phooey.c
------------------------------------------------

Note that 'combined diff' lists only files which were modified from
all parents.


include::diff-generate-patch.adoc[]


other diff formats
------------------

The `--summary` option describes newly added, deleted, renamed and
copied files.  The `--stat` option adds `diffstat`(1) graph to the
output.  These options can be combined with other options, such as
`-p`, and are meant for human consumption.

When showing a change that involves a rename or a copy, `--stat` output
formats the pathnames compactly by combining common prefix and suffix of
the pathnames.  For example, a change that moves `arch/i386/Makefile` to
`arch/x86/Makefile` while modifying 4 lines will be shown like this:

------------------------------------
arch/{i386 => x86}/Makefile    |   4 +--
------------------------------------

The `--numstat` option gives the diffstat(1) information but is designed
for easier machine consumption.  An entry in `--numstat` output looks
like this:

----------------------------------------
1	2	README
3	1	arch/{i386 => x86}/Makefile
----------------------------------------

That is, from left to right:

. the number of added lines;
. a tab;
. the number of deleted lines;
. a tab;
. pathname (possibly with rename/copy information);
. a newline.

When `-z` output option is in effect, the output is formatted this way:

----------------------------------------
1	2	README NUL
3	1	NUL arch/i386/Makefile NUL arch/x86/Makefile NUL
----------------------------------------

That is:

. the number of added lines;
. a tab;
. the number of deleted lines;
. a tab;
. a NUL (only exists if renamed/copied);
. pathname in preimage;
. a NUL (only exists if renamed/copied);
. pathname in postimage (only exists if renamed/copied);
. a NUL.

The extra `NUL` before the preimage path in renamed case is to allow
scripts that read the output to tell if the current record being read is
a single-path record or a rename/copy record without reading ahead.
After reading added and deleted lines, reading up to `NUL` would yield
the pathname, but if that is `NUL`, the record will show two paths.

Title: Git Diff Output Formats
Summary
The Git diff command offers various output formats, including `--summary`, `--stat`, and `--numstat`, which provide information on added, deleted, renamed, and copied files in different formats, suitable for both human and machine consumption, with options to customize the output.