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