1 The output format from "git-diff-cache", "git-diff-tree" and
2 "git-diff-files" is very similar.
4 These commands all compare two sets of things; what are
5 compared are different:
7 git-diff-cache <tree-ish>::
8 compares the <tree-ish> and the files on the filesystem.
10 git-diff-cache --cached <tree-ish>::
11 compares the <tree-ish> and the cache.
13 git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]::
14 compares the trees named by the two arguments.
16 git-diff-files [<pattern>...]::
17 compares the cache and the files on the filesystem.
20 An output line is formatted this way:
22 in-place edit :100644 100644 bcd1234... 0123456... M file0
23 copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2
24 rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3
25 create :000000 100644 0000000... 1234567... N file4
26 delete :100644 000000 1234567... 0000000... D file5
27 unmerged :000000 000000 0000000... 0000000... U file6
29 That is, from the left to the right:
32 (2) mode for "src"; 000000 if creation or unmerged.
34 (4) mode for "dst"; 000000 if deletion or unmerged.
36 (6) sha1 for "src"; 0{40} if creation or unmerged.
38 (8) sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree".
39 (9) status, followed by optional "score" number.
40 (10) a tab or a NUL when '-z' option is used.
42 (12) a tab or a NUL when '-z' option is used; only exists for C or R.
43 (13) path for "dst"; only exists for C or R.
44 (14) an LF or a NUL when '-z' option is used, to terminate the record.
46 <sha1> is shown as all 0's if new is a file on the filesystem
47 and it is out of sync with the cache. Example:
49 :100644 100644 5be4a4...... 000000...... M file.c
51 Generating patches with -p
52 --------------------------
54 When "git-diff-cache", "git-diff-tree", or "git-diff-files" are run
55 with a '-p' option, they do not produce the output described above
56 instead they produce a patch file.
58 The patch generation can be customized at two levels. This
59 customization also applies to "git-diff-helper".
61 1. When the environment variable 'GIT_EXTERNAL_DIFF' is not set,
62 these commands internally invoke "diff" like this:
64 diff -L a/<path> -L a/<path> -pu <old> <new>
66 For added files, `/dev/null` is used for <old>. For removed
67 files, `/dev/null` is used for <new>
69 The "diff" formatting options can be customized via the
70 environment variable 'GIT_DIFF_OPTS'. For example, if you
73 GIT_DIFF_OPTS=-c git-diff-cache -p $(cat .git/HEAD)
76 2. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the
77 program named by it is called, instead of the diff invocation
80 For a path that is added, removed, or modified,
81 'GIT_EXTERNAL_DIFF' is called with 7 parameters:
83 path old-file old-hex old-mode new-file new-hex new-mode
87 <old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the
89 <old|new>-hex:: are the 40-hexdigit SHA1 hashes,
90 <old|new>-mode:: are the octal representation of the file modes.
93 The file parameters can point at the user's working file
94 (e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file`
95 when a new file is added), or a temporary file (e.g. `old-file` in the
96 cache). 'GIT_EXTERNAL_DIFF' should not worry about unlinking the
97 temporary file --- it is removed when 'GIT_EXTERNAL_DIFF' exits.
99 For a path that is unmerged, 'GIT_EXTERNAL_DIFF' is called with 1