David Kågedal | f552e51 | 2009-07-28 10:32:18 +0200 | [diff] [blame] | 1 | Raw output format |
| 2 | ----------------- |
| 3 | |
| 4 | The raw output format from "git-diff-index", "git-diff-tree", |
Gerrit Pape | 9e6c723 | 2007-10-31 13:59:16 +0000 | [diff] [blame] | 5 | "git-diff-files" and "git diff --raw" are very similar. |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 6 | |
Junio C Hamano | a6080a0 | 2007-06-07 00:04:01 -0700 | [diff] [blame] | 7 | These commands all compare two sets of things; what is |
Christian Meder | f73ae1f | 2005-10-05 15:08:26 -0700 | [diff] [blame] | 8 | compared differs: |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 9 | |
Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 10 | git-diff-index <tree-ish>:: |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 11 | compares the <tree-ish> and the files on the filesystem. |
| 12 | |
Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 13 | git-diff-index --cached <tree-ish>:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 14 | compares the <tree-ish> and the index. |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 15 | |
| 16 | git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>...]:: |
| 17 | compares the trees named by the two arguments. |
| 18 | |
| 19 | git-diff-files [<pattern>...]:: |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 20 | compares the index and the files on the filesystem. |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 21 | |
Ralf Wildenhues | 6a5d0b0 | 2010-01-31 14:24:39 +0100 | [diff] [blame] | 22 | The "git-diff-tree" command begins its output by printing the hash of |
David Kågedal | f552e51 | 2009-07-28 10:32:18 +0200 | [diff] [blame] | 23 | what is being compared. After that, all the commands print one output |
| 24 | line per changed file. |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 25 | |
Junio C Hamano | 81e50ea | 2005-05-21 19:42:18 -0700 | [diff] [blame] | 26 | An output line is formatted this way: |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 27 | |
Junio C Hamano | 8db9307 | 2005-08-30 13:51:01 -0700 | [diff] [blame] | 28 | ------------------------------------------------ |
Junio C Hamano | b6d8f30 | 2005-05-23 14:55:33 -0700 | [diff] [blame] | 29 | in-place edit :100644 100644 bcd1234... 0123456... M file0 |
| 30 | copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2 |
| 31 | rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3 |
Junio C Hamano | 8db9307 | 2005-08-30 13:51:01 -0700 | [diff] [blame] | 32 | create :000000 100644 0000000... 1234567... A file4 |
Junio C Hamano | b6d8f30 | 2005-05-23 14:55:33 -0700 | [diff] [blame] | 33 | delete :100644 000000 1234567... 0000000... D file5 |
| 34 | unmerged :000000 000000 0000000... 0000000... U file6 |
Junio C Hamano | 8db9307 | 2005-08-30 13:51:01 -0700 | [diff] [blame] | 35 | ------------------------------------------------ |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 36 | |
Junio C Hamano | b6d8f30 | 2005-05-23 14:55:33 -0700 | [diff] [blame] | 37 | That is, from the left to the right: |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 38 | |
Junio C Hamano | 8db9307 | 2005-08-30 13:51:01 -0700 | [diff] [blame] | 39 | . a colon. |
| 40 | . mode for "src"; 000000 if creation or unmerged. |
| 41 | . a space. |
| 42 | . mode for "dst"; 000000 if deletion or unmerged. |
| 43 | . a space. |
| 44 | . sha1 for "src"; 0\{40\} if creation or unmerged. |
| 45 | . a space. |
| 46 | . sha1 for "dst"; 0\{40\} if creation, unmerged or "look at work tree". |
| 47 | . a space. |
| 48 | . status, followed by optional "score" number. |
| 49 | . a tab or a NUL when '-z' option is used. |
| 50 | . path for "src" |
| 51 | . a tab or a NUL when '-z' option is used; only exists for C or R. |
| 52 | . path for "dst"; only exists for C or R. |
| 53 | . an LF or a NUL when '-z' option is used, to terminate the record. |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 54 | |
Yann Dirson | a5a323f | 2008-11-02 14:37:28 +0100 | [diff] [blame] | 55 | Possible status letters are: |
| 56 | |
| 57 | - A: addition of a file |
| 58 | - C: copy of a file into a new one |
| 59 | - D: deletion of a file |
| 60 | - M: modification of the contents or mode of a file |
| 61 | - R: renaming of a file |
| 62 | - T: change in the type of the file |
| 63 | - U: file is unmerged (you must complete the merge before it can |
| 64 | be committed) |
| 65 | - X: "unknown" change type (most probably a bug, please report it) |
| 66 | |
Markus Heidelberg | 04c8ce9 | 2008-12-19 13:14:18 +0100 | [diff] [blame] | 67 | Status letters C and R are always followed by a score (denoting the |
Yann Dirson | a5a323f | 2008-11-02 14:37:28 +0100 | [diff] [blame] | 68 | percentage of similarity between the source and target of the move or |
Junio C Hamano | ac1c2d9 | 2015-01-28 13:17:19 -0800 | [diff] [blame] | 69 | copy). Status letter M may be followed by a score (denoting the |
| 70 | percentage of dissimilarity) for file rewrites. |
Yann Dirson | a5a323f | 2008-11-02 14:37:28 +0100 | [diff] [blame] | 71 | |
Christian Meder | f73ae1f | 2005-10-05 15:08:26 -0700 | [diff] [blame] | 72 | <sha1> is shown as all 0's if a file is new on the filesystem |
Lukas_Sandström | 5f3aa19 | 2005-11-11 02:12:27 +0100 | [diff] [blame] | 73 | and it is out of sync with the index. |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 74 | |
Junio C Hamano | 8db9307 | 2005-08-30 13:51:01 -0700 | [diff] [blame] | 75 | Example: |
| 76 | |
| 77 | ------------------------------------------------ |
| 78 | :100644 100644 5be4a4...... 000000...... M file.c |
| 79 | ------------------------------------------------ |
David Greaves | 03ea280 | 2005-05-08 18:22:48 +0100 | [diff] [blame] | 80 | |
Junio C Hamano | d88156e | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 81 | When `-z` option is not used, TAB, LF, and backslash characters |
| 82 | in pathnames are represented as `\t`, `\n`, and `\\`, |
| 83 | respectively. |
| 84 | |
Jakub Narebski | 3b559ea | 2007-05-05 00:48:35 +0200 | [diff] [blame] | 85 | diff format for merges |
| 86 | ---------------------- |
| 87 | |
Gerrit Pape | 9e6c723 | 2007-10-31 13:59:16 +0000 | [diff] [blame] | 88 | "git-diff-tree", "git-diff-files" and "git-diff --raw" |
| 89 | can take '-c' or '--cc' option |
Jakub Narebski | 3b559ea | 2007-05-05 00:48:35 +0200 | [diff] [blame] | 90 | to generate diff output also for merge commits. The output differs |
| 91 | from the format described above in the following way: |
| 92 | |
| 93 | . there is a colon for each parent |
| 94 | . there are more "src" modes and "src" sha1 |
| 95 | . status is concatenated status characters for each parent |
| 96 | . no optional "score" number |
| 97 | . single path, only for "dst" |
| 98 | |
| 99 | Example: |
| 100 | |
| 101 | ------------------------------------------------ |
| 102 | ::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c |
| 103 | ------------------------------------------------ |
| 104 | |
| 105 | Note that 'combined diff' lists only files which were modified from |
| 106 | all parents. |
| 107 | |
Junio C Hamano | d88156e | 2005-10-14 21:56:46 -0700 | [diff] [blame] | 108 | |
Miklos Vajna | 272bd3c | 2007-11-01 15:57:40 +0100 | [diff] [blame] | 109 | include::diff-generate-patch.txt[] |
Junio C Hamano | f604652 | 2007-12-11 23:46:30 -0800 | [diff] [blame] | 110 | |
| 111 | |
| 112 | other diff formats |
| 113 | ------------------ |
| 114 | |
| 115 | The `--summary` option describes newly added, deleted, renamed and |
| 116 | copied files. The `--stat` option adds diffstat(1) graph to the |
| 117 | output. These options can be combined with other options, such as |
| 118 | `-p`, and are meant for human consumption. |
| 119 | |
| 120 | When showing a change that involves a rename or a copy, `--stat` output |
| 121 | formats the pathnames compactly by combining common prefix and suffix of |
| 122 | the pathnames. For example, a change that moves `arch/i386/Makefile` to |
| 123 | `arch/x86/Makefile` while modifying 4 lines will be shown like this: |
| 124 | |
| 125 | ------------------------------------ |
| 126 | arch/{i386 => x86}/Makefile | 4 +-- |
| 127 | ------------------------------------ |
| 128 | |
| 129 | The `--numstat` option gives the diffstat(1) information but is designed |
| 130 | for easier machine consumption. An entry in `--numstat` output looks |
| 131 | like this: |
| 132 | |
| 133 | ---------------------------------------- |
| 134 | 1 2 README |
| 135 | 3 1 arch/{i386 => x86}/Makefile |
| 136 | ---------------------------------------- |
| 137 | |
| 138 | That is, from left to right: |
| 139 | |
| 140 | . the number of added lines; |
| 141 | . a tab; |
| 142 | . the number of deleted lines; |
| 143 | . a tab; |
| 144 | . pathname (possibly with rename/copy information); |
| 145 | . a newline. |
| 146 | |
| 147 | When `-z` output option is in effect, the output is formatted this way: |
| 148 | |
| 149 | ---------------------------------------- |
| 150 | 1 2 README NUL |
| 151 | 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL |
| 152 | ---------------------------------------- |
| 153 | |
| 154 | That is: |
| 155 | |
| 156 | . the number of added lines; |
| 157 | . a tab; |
| 158 | . the number of deleted lines; |
| 159 | . a tab; |
| 160 | . a NUL (only exists if renamed/copied); |
| 161 | . pathname in preimage; |
| 162 | . a NUL (only exists if renamed/copied); |
| 163 | . pathname in postimage (only exists if renamed/copied); |
| 164 | . a NUL. |
| 165 | |
| 166 | The extra `NUL` before the preimage path in renamed case is to allow |
| 167 | scripts that read the output to tell if the current record being read is |
| 168 | a single-path record or a rename/copy record without reading ahead. |
| 169 | After reading added and deleted lines, reading up to `NUL` would yield |
| 170 | the pathname, but if that is `NUL`, the record will show two paths. |