1The output format from "git-diff-cache", "git-diff-tree" and 2"git-diff-files" is very similar. 3 4These commands all compare two sets of things; what are 5compared are different: 6 7git-diff-cache <tree-ish>:: 8 compares the <tree-ish> and the files on the filesystem. 9 10git-diff-cache --cached <tree-ish>:: 11 compares the <tree-ish> and the cache. 12 13git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]:: 14 compares the trees named by the two arguments. 15 16git-diff-files [<pattern>...]:: 17 compares the cache and the files on the filesystem. 18 19 20An output line is formatted this way: 21 22 ':' <mode> ' ' <mode> ' ' <sha1> ' ' <sha1> I <path> I <path> L 23 24By default, I and L are '\t' and '\n' respectively. When '-z' 25flag is in effect, both I and L are '\0'. 26 27In each <mode>, <sha1> and <path> pair, left hand side describes 28the left hand side of what is being compared (<tree-ish> in 29git-diff-cache, <tree-ish-1> in git-diff-tree, cache contents in 30git-diff-files). Non-existence is shown by having 000000 in the 31<mode> column. That is, 000000 appears as the first <mode> for 32newly created files, and as the second <mode> for deleted files. 33 34Usually two <path> are the same. When rename/copy detection is 35used, however, an "create" and another "delete" records can be 36merged into a single record that has two <path>, old name and 37new name. 38 39<sha1> is shown as all 0's if new is a file on the filesystem 40and it is out of sync with the cache. Example: 41 42 :100644 100644 5be4a4...... 000000...... file.c file.c 43 44 45Generating patches with -p 46-------------------------- 47 48When "git-diff-cache", "git-diff-tree", or "git-diff-files" are run 49with a '-p' option, they do not produce the output described above 50instead they produce a patch file. 51 52The patch generation can be customized at two levels. This 53customization also applies to "git-diff-helper". 54 551. When the environment variable 'GIT_EXTERNAL_DIFF' is not set, 56 these commands internally invoke "diff" like this: 57 58 diff -L a/<path> -L a/<path> -pu <old> <new> 59+ 60For added files, `/dev/null` is used for <old>. For removed 61files, `/dev/null` is used for <new> 62+ 63The "diff" formatting options can be customized via the 64environment variable 'GIT_DIFF_OPTS'. For example, if you 65prefer context diff: 66 67 GIT_DIFF_OPTS=-c git-diff-cache -p $(cat .git/HEAD) 68 69 702. When the environment variable 'GIT_EXTERNAL_DIFF' is set, the 71 program named by it is called, instead of the diff invocation 72 described above. 73+ 74For a path that is added, removed, or modified, 75'GIT_EXTERNAL_DIFF' is called with 7 parameters: 76 77 path old-file old-hex old-mode new-file new-hex new-mode 78+ 79where: 80 81 <old|new>-file:: are files GIT_EXTERNAL_DIFF can use to read the 82 contents of <old|ne>, 83 <old|new>-hex:: are the 40-hexdigit SHA1 hashes, 84 <old|new>-mode:: are the octal representation of the file modes. 85 86+ 87The file parameters can point at the user's working file 88(e.g. `new-file` in "git-diff-files"), `/dev/null` (e.g. `old-file` 89when a new file is added), or a temporary file (e.g. `old-file` in the 90cache). 'GIT_EXTERNAL_DIFF' should not worry about unlinking the 91temporary file --- it is removed when 'GIT_EXTERNAL_DIFF' exits. 92 93For a path that is unmerged, 'GIT_EXTERNAL_DIFF' is called with 1 94parameter, <path>.