Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 2 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.2.5" /> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | <style type="text/css"> |
| 8 | /* Debug borders */ |
| 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { |
| 10 | /* |
| 11 | border: 1px solid red; |
| 12 | */ |
| 13 | } |
| 14 | |
| 15 | body { |
| 16 | margin: 1em 5% 1em 5%; |
| 17 | } |
| 18 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 19 | a { |
| 20 | color: blue; |
| 21 | text-decoration: underline; |
| 22 | } |
| 23 | a:visited { |
| 24 | color: fuchsia; |
| 25 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 26 | |
| 27 | em { |
| 28 | font-style: italic; |
| 29 | } |
| 30 | |
| 31 | strong { |
| 32 | font-weight: bold; |
| 33 | } |
| 34 | |
| 35 | tt { |
| 36 | color: navy; |
| 37 | } |
| 38 | |
| 39 | h1, h2, h3, h4, h5, h6 { |
| 40 | color: #527bbd; |
| 41 | font-family: sans-serif; |
| 42 | margin-top: 1.2em; |
| 43 | margin-bottom: 0.5em; |
| 44 | line-height: 1.3; |
| 45 | } |
| 46 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 47 | h1, h2, h3 { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 48 | border-bottom: 2px solid silver; |
| 49 | } |
| 50 | h2 { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 51 | padding-top: 0.5em; |
| 52 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 53 | h3 { |
| 54 | float: left; |
| 55 | } |
| 56 | h3 + * { |
| 57 | clear: left; |
| 58 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 59 | |
| 60 | div.sectionbody { |
| 61 | font-family: serif; |
| 62 | margin-left: 0; |
| 63 | } |
| 64 | |
| 65 | hr { |
| 66 | border: 1px solid silver; |
| 67 | } |
| 68 | |
| 69 | p { |
| 70 | margin-top: 0.5em; |
| 71 | margin-bottom: 0.5em; |
| 72 | } |
| 73 | |
| 74 | pre { |
| 75 | padding: 0; |
| 76 | margin: 0; |
| 77 | } |
| 78 | |
| 79 | span#author { |
| 80 | color: #527bbd; |
| 81 | font-family: sans-serif; |
| 82 | font-weight: bold; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 83 | font-size: 1.1em; |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 84 | } |
| 85 | span#email { |
| 86 | } |
| 87 | span#revision { |
| 88 | font-family: sans-serif; |
| 89 | } |
| 90 | |
| 91 | div#footer { |
| 92 | font-family: sans-serif; |
| 93 | font-size: small; |
| 94 | border-top: 2px solid silver; |
| 95 | padding-top: 0.5em; |
| 96 | margin-top: 4.0em; |
| 97 | } |
| 98 | div#footer-text { |
| 99 | float: left; |
| 100 | padding-bottom: 0.5em; |
| 101 | } |
| 102 | div#footer-badges { |
| 103 | float: right; |
| 104 | padding-bottom: 0.5em; |
| 105 | } |
| 106 | |
| 107 | div#preamble, |
| 108 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 109 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 110 | div.admonitionblock { |
| 111 | margin-right: 10%; |
| 112 | margin-top: 1.5em; |
| 113 | margin-bottom: 1.5em; |
| 114 | } |
| 115 | div.admonitionblock { |
| 116 | margin-top: 2.5em; |
| 117 | margin-bottom: 2.5em; |
| 118 | } |
| 119 | |
| 120 | div.content { /* Block element content. */ |
| 121 | padding: 0; |
| 122 | } |
| 123 | |
| 124 | /* Block element titles. */ |
| 125 | div.title, caption.title { |
| 126 | font-family: sans-serif; |
| 127 | font-weight: bold; |
| 128 | text-align: left; |
| 129 | margin-top: 1.0em; |
| 130 | margin-bottom: 0.5em; |
| 131 | } |
| 132 | div.title + * { |
| 133 | margin-top: 0; |
| 134 | } |
| 135 | |
| 136 | td div.title:first-child { |
| 137 | margin-top: 0.0em; |
| 138 | } |
| 139 | div.content div.title:first-child { |
| 140 | margin-top: 0.0em; |
| 141 | } |
| 142 | div.content + div.title { |
| 143 | margin-top: 0.0em; |
| 144 | } |
| 145 | |
| 146 | div.sidebarblock > div.content { |
| 147 | background: #ffffee; |
| 148 | border: 1px solid silver; |
| 149 | padding: 0.5em; |
| 150 | } |
| 151 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 152 | div.listingblock { |
| 153 | margin-right: 0%; |
| 154 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 155 | div.listingblock > div.content { |
| 156 | border: 1px solid silver; |
| 157 | background: #f4f4f4; |
| 158 | padding: 0.5em; |
| 159 | } |
| 160 | |
| 161 | div.quoteblock > div.content { |
| 162 | padding-left: 2.0em; |
| 163 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 164 | |
| 165 | div.attribution { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 166 | text-align: right; |
| 167 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 168 | div.verseblock + div.attribution { |
| 169 | text-align: left; |
| 170 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 171 | |
| 172 | div.admonitionblock .icon { |
| 173 | vertical-align: top; |
| 174 | font-size: 1.1em; |
| 175 | font-weight: bold; |
| 176 | text-decoration: underline; |
| 177 | color: #527bbd; |
| 178 | padding-right: 0.5em; |
| 179 | } |
| 180 | div.admonitionblock td.content { |
| 181 | padding-left: 0.5em; |
| 182 | border-left: 2px solid silver; |
| 183 | } |
| 184 | |
| 185 | div.exampleblock > div.content { |
| 186 | border-left: 2px solid silver; |
| 187 | padding: 0.5em; |
| 188 | } |
| 189 | |
| 190 | div.verseblock div.content { |
| 191 | white-space: pre; |
| 192 | } |
| 193 | |
| 194 | div.imageblock div.content { padding-left: 0; } |
| 195 | div.imageblock img { border: 1px solid silver; } |
| 196 | span.image img { border-style: none; } |
| 197 | |
| 198 | dl { |
| 199 | margin-top: 0.8em; |
| 200 | margin-bottom: 0.8em; |
| 201 | } |
| 202 | dt { |
| 203 | margin-top: 0.5em; |
| 204 | margin-bottom: 0; |
| 205 | font-style: italic; |
| 206 | } |
| 207 | dd > *:first-child { |
| 208 | margin-top: 0; |
| 209 | } |
| 210 | |
| 211 | ul, ol { |
| 212 | list-style-position: outside; |
| 213 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 214 | div.olist2 ol { |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 215 | list-style-type: lower-alpha; |
| 216 | } |
| 217 | |
| 218 | div.tableblock > table { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 219 | border: 3px solid #527bbd; |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 220 | } |
| 221 | thead { |
| 222 | font-family: sans-serif; |
| 223 | font-weight: bold; |
| 224 | } |
| 225 | tfoot { |
| 226 | font-weight: bold; |
| 227 | } |
| 228 | |
| 229 | div.hlist { |
| 230 | margin-top: 0.8em; |
| 231 | margin-bottom: 0.8em; |
| 232 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 233 | div.hlist td { |
| 234 | padding-bottom: 5px; |
| 235 | } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 236 | td.hlist1 { |
| 237 | vertical-align: top; |
| 238 | font-style: italic; |
| 239 | padding-right: 0.8em; |
| 240 | } |
| 241 | td.hlist2 { |
| 242 | vertical-align: top; |
| 243 | } |
| 244 | |
| 245 | @media print { |
| 246 | div#footer-badges { display: none; } |
| 247 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 248 | |
| 249 | div#toctitle { |
| 250 | color: #527bbd; |
| 251 | font-family: sans-serif; |
| 252 | font-size: 1.1em; |
| 253 | font-weight: bold; |
| 254 | margin-top: 1.0em; |
| 255 | margin-bottom: 0.1em; |
| 256 | } |
| 257 | |
| 258 | div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
| 259 | margin-top: 0; |
| 260 | margin-bottom: 0; |
| 261 | } |
| 262 | div.toclevel2 { |
| 263 | margin-left: 2em; |
| 264 | font-size: 0.9em; |
| 265 | } |
| 266 | div.toclevel3 { |
| 267 | margin-left: 4em; |
| 268 | font-size: 0.9em; |
| 269 | } |
| 270 | div.toclevel4 { |
| 271 | margin-left: 6em; |
| 272 | font-size: 0.9em; |
| 273 | } |
| 274 | include1::./stylesheets/xhtml11-manpage.css[] |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 275 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 276 | |
| 277 | div.sidebar-content { |
| 278 | background: #ffffee; |
| 279 | border: 1px solid silver; |
| 280 | padding: 0.5em; |
| 281 | } |
| 282 | div.sidebar-title, div.image-title { |
| 283 | font-family: sans-serif; |
| 284 | font-weight: bold; |
| 285 | margin-top: 0.0em; |
| 286 | margin-bottom: 0.5em; |
| 287 | } |
| 288 | |
| 289 | div.listingblock div.content { |
| 290 | border: 1px solid silver; |
| 291 | background: #f4f4f4; |
| 292 | padding: 0.5em; |
| 293 | } |
| 294 | |
| 295 | div.quoteblock-content { |
| 296 | padding-left: 2.0em; |
| 297 | } |
| 298 | |
| 299 | div.exampleblock-content { |
| 300 | border-left: 2px solid silver; |
| 301 | padding-left: 0.5em; |
| 302 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 303 | |
| 304 | /* IE6 sets dynamically generated links as visited. */ |
| 305 | div#toc a:visited { color: blue; } |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 306 | </style> |
| 307 | <title>git-diff-index(1)</title> |
| 308 | </head> |
| 309 | <body> |
| 310 | <div id="header"> |
| 311 | <h1> |
| 312 | git-diff-index(1) Manual Page |
| 313 | </h1> |
| 314 | <h2>NAME</h2> |
| 315 | <div class="sectionbody"> |
| 316 | <p>git-diff-index - |
| 317 | Compares content and mode of blobs between the index and repository |
| 318 | </p> |
| 319 | </div> |
| 320 | </div> |
| 321 | <h2>SYNOPSIS</h2> |
| 322 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 323 | <div class="para"><p><em>git diff-index</em> [-m] [--cached] [<common diff options>] <tree-ish> [<path>…]</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 324 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 325 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 326 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 327 | <div class="para"><p>Compares the content and mode of the blobs found via a tree |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 328 | object with the content of the current index and, optionally |
| 329 | ignoring the stat state of the file on disk. When paths are |
| 330 | specified, compares only those named paths. Otherwise all |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 331 | entries in the index are compared.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 332 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 333 | <h2 id="_options">OPTIONS</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 334 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 335 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 336 | <dt> |
| 337 | -p |
| 338 | </dt> |
Junio C Hamano | bbbb865 | 2008-12-29 10:34:22 | [diff] [blame] | 339 | <dt> |
| 340 | -u |
| 341 | </dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 342 | <dd> |
| 343 | <p> |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 344 | Generate patch (see section on generating patches). |
| 345 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 346 | </p> |
| 347 | </dd> |
| 348 | <dt> |
Junio C Hamano | 6936156 | 2007-07-26 02:14:34 | [diff] [blame] | 349 | -U<n> |
| 350 | </dt> |
Junio C Hamano | 6936156 | 2007-07-26 02:14:34 | [diff] [blame] | 351 | <dt> |
| 352 | --unified=<n> |
| 353 | </dt> |
| 354 | <dd> |
| 355 | <p> |
| 356 | Generate diffs with <n> lines of context instead of |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 357 | the usual three. |
| 358 | Implies <tt>-p</tt>. |
Junio C Hamano | 6936156 | 2007-07-26 02:14:34 | [diff] [blame] | 359 | </p> |
| 360 | </dd> |
| 361 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 362 | --raw |
| 363 | </dt> |
| 364 | <dd> |
| 365 | <p> |
| 366 | Generate the raw format. |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 367 | This is the default. |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 368 | </p> |
| 369 | </dd> |
| 370 | <dt> |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 371 | --patch-with-raw |
| 372 | </dt> |
| 373 | <dd> |
| 374 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 375 | Synonym for <tt>-p --raw</tt>. |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 376 | </p> |
| 377 | </dd> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 378 | <dt> |
| 379 | --patience |
| 380 | </dt> |
| 381 | <dd> |
| 382 | <p> |
| 383 | Generate a diff using the "patience diff" algorithm. |
| 384 | </p> |
| 385 | </dd> |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 386 | <dt> |
Junio C Hamano | 4a9a76a | 2006-10-01 05:40:29 | [diff] [blame] | 387 | --stat[=width[,name-width]] |
Junio C Hamano | ba7c8d8 | 2006-04-15 06:17:42 | [diff] [blame] | 388 | </dt> |
| 389 | <dd> |
| 390 | <p> |
Junio C Hamano | 4a9a76a | 2006-10-01 05:40:29 | [diff] [blame] | 391 | Generate a diffstat. You can override the default |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 392 | output width for 80-column terminal by <tt>--stat=width</tt>. |
Junio C Hamano | 4a9a76a | 2006-10-01 05:40:29 | [diff] [blame] | 393 | The width of the filename part can be controlled by |
| 394 | giving another width to it separated by a comma. |
Junio C Hamano | ba7c8d8 | 2006-04-15 06:17:42 | [diff] [blame] | 395 | </p> |
| 396 | </dd> |
| 397 | <dt> |
Junio C Hamano | fbe0052 | 2006-10-19 05:58:48 | [diff] [blame] | 398 | --numstat |
| 399 | </dt> |
| 400 | <dd> |
| 401 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 402 | Similar to <tt>--stat</tt>, but shows number of added and |
Junio C Hamano | fbe0052 | 2006-10-19 05:58:48 | [diff] [blame] | 403 | deleted lines in decimal notation and pathname without |
Junio C Hamano | d793de5 | 2006-12-26 09:11:43 | [diff] [blame] | 404 | abbreviation, to make it more machine friendly. For |
| 405 | binary files, outputs two <tt>-</tt> instead of saying |
| 406 | <tt>0 0</tt>. |
Junio C Hamano | fbe0052 | 2006-10-19 05:58:48 | [diff] [blame] | 407 | </p> |
| 408 | </dd> |
| 409 | <dt> |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 410 | --shortstat |
| 411 | </dt> |
| 412 | <dd> |
| 413 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 414 | Output only the last line of the <tt>--stat</tt> format containing total |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 415 | number of modified files, as well as number of added and deleted |
| 416 | lines. |
| 417 | </p> |
| 418 | </dd> |
| 419 | <dt> |
Junio C Hamano | 6a45be9 | 2008-04-22 08:19:03 | [diff] [blame] | 420 | --dirstat[=limit] |
| 421 | </dt> |
| 422 | <dd> |
| 423 | <p> |
Junio C Hamano | a2f4662 | 2008-09-03 05:20:31 | [diff] [blame] | 424 | Output the distribution of relative amount of changes (number of lines added or |
| 425 | removed) for each sub-directory. Directories with changes below |
| 426 | a cut-off percent (3% by default) are not shown. The cut-off percent |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 427 | can be set with <tt>--dirstat=limit</tt>. Changes in a child directory is not |
| 428 | counted for the parent directory, unless <tt>--cumulative</tt> is used. |
Junio C Hamano | 6a45be9 | 2008-04-22 08:19:03 | [diff] [blame] | 429 | </p> |
| 430 | </dd> |
| 431 | <dt> |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 432 | --dirstat-by-file[=limit] |
| 433 | </dt> |
| 434 | <dd> |
| 435 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 436 | Same as <tt>--dirstat</tt>, but counts changed files instead of lines. |
Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 437 | </p> |
| 438 | </dd> |
| 439 | <dt> |
Junio C Hamano | 6959c6c | 2006-05-17 10:34:11 | [diff] [blame] | 440 | --summary |
| 441 | </dt> |
| 442 | <dd> |
| 443 | <p> |
| 444 | Output a condensed summary of extended header information |
| 445 | such as creations, renames and mode changes. |
| 446 | </p> |
| 447 | </dd> |
| 448 | <dt> |
Junio C Hamano | d1308c9 | 2006-04-16 11:01:09 | [diff] [blame] | 449 | --patch-with-stat |
| 450 | </dt> |
| 451 | <dd> |
| 452 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 453 | Synonym for <tt>-p --stat</tt>. |
Junio C Hamano | d1308c9 | 2006-04-16 11:01:09 | [diff] [blame] | 454 | </p> |
| 455 | </dd> |
| 456 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 457 | -z |
| 458 | </dt> |
| 459 | <dd> |
| 460 | <p> |
Junio C Hamano | 5706e0b | 2009-11-24 10:54:16 | [diff] [blame] | 461 | When <tt>--raw</tt> or <tt>--numstat</tt> has been given, do not munge |
| 462 | pathnames and use NULs as output field terminators. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 463 | </p> |
Junio C Hamano | 5706e0b | 2009-11-24 10:54:16 | [diff] [blame] | 464 | <div class="para"><p>Without this option, each pathname output will have TAB, LF, double quotes, |
| 465 | and backslash characters replaced with <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt>, and <tt>\\</tt>, |
| 466 | respectively, and the pathname will be enclosed in double quotes if |
| 467 | any of those replacements occurred.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 468 | </dd> |
| 469 | <dt> |
| 470 | --name-only |
| 471 | </dt> |
| 472 | <dd> |
| 473 | <p> |
| 474 | Show only names of changed files. |
| 475 | </p> |
| 476 | </dd> |
| 477 | <dt> |
| 478 | --name-status |
| 479 | </dt> |
| 480 | <dd> |
| 481 | <p> |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 482 | Show only names and status of changed files. See the description |
| 483 | of the <tt>--diff-filter</tt> option on what the status letters mean. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 484 | </p> |
| 485 | </dd> |
| 486 | <dt> |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 487 | --submodule[=<format>] |
| 488 | </dt> |
| 489 | <dd> |
| 490 | <p> |
| 491 | Chose the output format for submodule differences. <format> can be one of |
| 492 | <em>short</em> and <em>log</em>. <em>short</em> just shows pairs of commit names, this format |
| 493 | is used when this option is not given. <em>log</em> is the default value for this |
| 494 | option and lists the commits in that commit range like the <em>summary</em> |
| 495 | option of <a href="git-submodule.html">git-submodule(1)</a> does. |
| 496 | </p> |
| 497 | </dd> |
| 498 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 499 | --color |
| 500 | </dt> |
| 501 | <dd> |
| 502 | <p> |
| 503 | Show colored diff. |
| 504 | </p> |
| 505 | </dd> |
| 506 | <dt> |
| 507 | --no-color |
| 508 | </dt> |
| 509 | <dd> |
| 510 | <p> |
| 511 | Turn off colored diff, even when the configuration file |
| 512 | gives the default to color output. |
| 513 | </p> |
| 514 | </dd> |
| 515 | <dt> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 516 | --color-words[=<regex>] |
Junio C Hamano | 85e45fa | 2006-08-13 07:47:41 | [diff] [blame] | 517 | </dt> |
| 518 | <dd> |
| 519 | <p> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 520 | Show colored word diff, i.e., color words which have changed. |
| 521 | By default, words are separated by whitespace. |
Junio C Hamano | 85e45fa | 2006-08-13 07:47:41 | [diff] [blame] | 522 | </p> |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 523 | <div class="para"><p>When a <regex> is specified, every non-overlapping match of the |
| 524 | <regex> is considered a word. Anything between these matches is |
| 525 | considered whitespace and ignored(!) for the purposes of finding |
| 526 | differences. You may want to append <tt>|[^[:space:]]</tt> to your regular |
| 527 | expression to make sure that it matches all non-whitespace characters. |
| 528 | A match that contains a newline is silently truncated(!) at the |
| 529 | newline.</p></div> |
| 530 | <div class="para"><p>The regex can also be set via a diff driver or configuration option, see |
| 531 | <a href="gitattributes.html">gitattributes(1)</a> or <a href="git-config.html">git-config(1)</a>. Giving it explicitly |
| 532 | overrides any diff driver or configuration setting. Diff drivers |
| 533 | override configuration settings.</p></div> |
Junio C Hamano | 85e45fa | 2006-08-13 07:47:41 | [diff] [blame] | 534 | </dd> |
| 535 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 536 | --no-renames |
| 537 | </dt> |
| 538 | <dd> |
| 539 | <p> |
| 540 | Turn off rename detection, even when the configuration |
| 541 | file gives the default to do so. |
| 542 | </p> |
| 543 | </dd> |
| 544 | <dt> |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 545 | --check |
| 546 | </dt> |
| 547 | <dd> |
| 548 | <p> |
| 549 | Warn if changes introduce trailing whitespace |
Junio C Hamano | 3dac504 | 2007-12-15 08:40:54 | [diff] [blame] | 550 | or an indent that uses a space before a tab. Exits with |
| 551 | non-zero status if problems are found. Not compatible with |
| 552 | --exit-code. |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 553 | </p> |
| 554 | </dd> |
| 555 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 556 | --full-index |
| 557 | </dt> |
| 558 | <dd> |
| 559 | <p> |
Junio C Hamano | 5cf43ca | 2008-08-20 09:14:14 | [diff] [blame] | 560 | Instead of the first handful of characters, show the full |
| 561 | pre- and post-image blob object names on the "index" |
| 562 | line when generating patch format output. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 563 | </p> |
| 564 | </dd> |
| 565 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 566 | --binary |
| 567 | </dt> |
| 568 | <dd> |
| 569 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 570 | In addition to <tt>--full-index</tt>, output a binary diff that |
| 571 | can be applied with <tt>git-apply</tt>. |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 572 | </p> |
| 573 | </dd> |
| 574 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 575 | --abbrev[=<n>] |
| 576 | </dt> |
| 577 | <dd> |
| 578 | <p> |
| 579 | Instead of showing the full 40-byte hexadecimal object |
| 580 | name in diff-raw format output and diff-tree header |
Junio C Hamano | 6efe302 | 2009-01-13 16:47:56 | [diff] [blame] | 581 | lines, show only a partial prefix. This is |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 582 | independent of the <tt>--full-index</tt> option above, which controls |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 583 | the diff-patch output format. Non default number of |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 584 | digits can be specified with <tt>--abbrev=<n></tt>. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 585 | </p> |
| 586 | </dd> |
| 587 | <dt> |
| 588 | -B |
| 589 | </dt> |
| 590 | <dd> |
| 591 | <p> |
| 592 | Break complete rewrite changes into pairs of delete and create. |
| 593 | </p> |
| 594 | </dd> |
| 595 | <dt> |
| 596 | -M |
| 597 | </dt> |
| 598 | <dd> |
| 599 | <p> |
| 600 | Detect renames. |
| 601 | </p> |
| 602 | </dd> |
| 603 | <dt> |
| 604 | -C |
| 605 | </dt> |
| 606 | <dd> |
| 607 | <p> |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 608 | Detect copies as well as renames. See also <tt>--find-copies-harder</tt>. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 609 | </p> |
| 610 | </dd> |
| 611 | <dt> |
Junio C Hamano | 6ec31b9 | 2006-02-10 05:52:01 | [diff] [blame] | 612 | --diff-filter=[ACDMRTUXB*] |
| 613 | </dt> |
| 614 | <dd> |
| 615 | <p> |
| 616 | Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>), |
| 617 | Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their |
Junio C Hamano | a2deec5 | 2008-10-18 18:58:09 | [diff] [blame] | 618 | type (i.e. regular file, symlink, submodule, …) changed (<tt>T</tt>), |
| 619 | are Unmerged (<tt>U</tt>), are |
Junio C Hamano | 6ec31b9 | 2006-02-10 05:52:01 | [diff] [blame] | 620 | Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>). |
| 621 | Any combination of the filter characters may be used. |
| 622 | When <tt>*</tt> (All-or-none) is added to the combination, all |
| 623 | paths are selected if there is any file that matches |
| 624 | other criteria in the comparison; if there is no file |
| 625 | that matches other criteria, nothing is selected. |
| 626 | </p> |
| 627 | </dd> |
| 628 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 629 | --find-copies-harder |
| 630 | </dt> |
| 631 | <dd> |
| 632 | <p> |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 633 | For performance reasons, by default, <tt>-C</tt> option finds copies only |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 634 | if the original file of the copy was modified in the same |
| 635 | changeset. This flag makes the command |
| 636 | inspect unmodified files as candidates for the source of |
| 637 | copy. This is a very expensive operation for large |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 638 | projects, so use it with caution. Giving more than one |
| 639 | <tt>-C</tt> option has the same effect. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 640 | </p> |
| 641 | </dd> |
| 642 | <dt> |
| 643 | -l<num> |
| 644 | </dt> |
| 645 | <dd> |
| 646 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 647 | The <tt>-M</tt> and <tt>-C</tt> options require O(n^2) processing time where n |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 648 | is the number of potential rename/copy targets. This |
| 649 | option prevents rename/copy detection from running if |
| 650 | the number of rename/copy targets exceeds the specified |
| 651 | number. |
| 652 | </p> |
| 653 | </dd> |
| 654 | <dt> |
| 655 | -S<string> |
| 656 | </dt> |
| 657 | <dd> |
| 658 | <p> |
Junio C Hamano | 5217a27 | 2009-03-21 00:39:33 | [diff] [blame] | 659 | Look for differences that introduce or remove an instance of |
| 660 | <string>. Note that this is different than the string simply |
| 661 | appearing in diff output; see the <em>pickaxe</em> entry in |
| 662 | <a href="gitdiffcore.html">gitdiffcore(7)</a> for more details. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 663 | </p> |
| 664 | </dd> |
| 665 | <dt> |
| 666 | --pickaxe-all |
| 667 | </dt> |
| 668 | <dd> |
| 669 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 670 | When <tt>-S</tt> finds a change, show all the changes in that |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 671 | changeset, not just the files that contain the change |
| 672 | in <string>. |
| 673 | </p> |
| 674 | </dd> |
| 675 | <dt> |
Junio C Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 676 | --pickaxe-regex |
| 677 | </dt> |
| 678 | <dd> |
| 679 | <p> |
| 680 | Make the <string> not a plain string but an extended POSIX |
| 681 | regex to match. |
| 682 | </p> |
| 683 | </dd> |
| 684 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 685 | -O<orderfile> |
| 686 | </dt> |
| 687 | <dd> |
| 688 | <p> |
| 689 | Output the patch in the order specified in the |
| 690 | <orderfile>, which has one shell glob pattern per line. |
| 691 | </p> |
| 692 | </dd> |
| 693 | <dt> |
| 694 | -R |
| 695 | </dt> |
| 696 | <dd> |
| 697 | <p> |
| 698 | Swap two inputs; that is, show differences from index or |
| 699 | on-disk file to tree contents. |
| 700 | </p> |
| 701 | </dd> |
Junio C Hamano | c26f548 | 2006-07-09 09:38:14 | [diff] [blame] | 702 | <dt> |
Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 703 | --relative[=<path>] |
| 704 | </dt> |
| 705 | <dd> |
| 706 | <p> |
| 707 | When run from a subdirectory of the project, it can be |
| 708 | told to exclude changes outside the directory and show |
| 709 | pathnames relative to it with this option. When you are |
| 710 | not in a subdirectory (e.g. in a bare repository), you |
| 711 | can name which subdirectory to make the output relative |
| 712 | to by giving a <path> as an argument. |
| 713 | </p> |
| 714 | </dd> |
| 715 | <dt> |
Junio C Hamano | bbbb865 | 2008-12-29 10:34:22 | [diff] [blame] | 716 | -a |
| 717 | </dt> |
| 718 | <dt> |
Junio C Hamano | c26f548 | 2006-07-09 09:38:14 | [diff] [blame] | 719 | --text |
| 720 | </dt> |
| 721 | <dd> |
| 722 | <p> |
| 723 | Treat all files as text. |
| 724 | </p> |
| 725 | </dd> |
| 726 | <dt> |
Junio C Hamano | fd46896 | 2007-02-14 23:45:04 | [diff] [blame] | 727 | --ignore-space-at-eol |
| 728 | </dt> |
| 729 | <dd> |
| 730 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 731 | Ignore changes in whitespace at EOL. |
Junio C Hamano | fd46896 | 2007-02-14 23:45:04 | [diff] [blame] | 732 | </p> |
| 733 | </dd> |
| 734 | <dt> |
Junio C Hamano | bbbb865 | 2008-12-29 10:34:22 | [diff] [blame] | 735 | -b |
| 736 | </dt> |
| 737 | <dt> |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 738 | --ignore-space-change |
| 739 | </dt> |
| 740 | <dd> |
| 741 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 742 | Ignore changes in amount of whitespace. This ignores whitespace |
| 743 | at line end, and considers all other sequences of one or |
| 744 | more whitespace characters to be equivalent. |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 745 | </p> |
| 746 | </dd> |
| 747 | <dt> |
Junio C Hamano | bbbb865 | 2008-12-29 10:34:22 | [diff] [blame] | 748 | -w |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 749 | </dt> |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 750 | <dt> |
| 751 | --ignore-all-space |
| 752 | </dt> |
| 753 | <dd> |
| 754 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 755 | Ignore whitespace when comparing lines. This ignores |
| 756 | differences even if one line has whitespace where the other |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 757 | line has none. |
| 758 | </p> |
| 759 | </dd> |
| 760 | <dt> |
Junio C Hamano | 1d40ee8 | 2009-01-07 10:14:16 | [diff] [blame] | 761 | --inter-hunk-context=<lines> |
| 762 | </dt> |
| 763 | <dd> |
| 764 | <p> |
| 765 | Show the context between diff hunks, up to the specified number |
| 766 | of lines, thereby fusing hunks that are close to each other. |
| 767 | </p> |
| 768 | </dd> |
| 769 | <dt> |
Junio C Hamano | 48fd2f6 | 2007-03-19 02:02:30 | [diff] [blame] | 770 | --exit-code |
| 771 | </dt> |
| 772 | <dd> |
| 773 | <p> |
| 774 | Make the program exit with codes similar to diff(1). |
| 775 | That is, it exits with 1 if there were differences and |
| 776 | 0 means no differences. |
| 777 | </p> |
| 778 | </dd> |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 779 | <dt> |
| 780 | --quiet |
| 781 | </dt> |
| 782 | <dd> |
| 783 | <p> |
Junio C Hamano | 3b70d3c | 2009-11-21 17:37:37 | [diff] [blame] | 784 | Disable all output of the program. Implies <tt>--exit-code</tt>. |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 785 | </p> |
| 786 | </dd> |
Junio C Hamano | bb0f404 | 2007-07-04 06:41:40 | [diff] [blame] | 787 | <dt> |
| 788 | --ext-diff |
| 789 | </dt> |
| 790 | <dd> |
| 791 | <p> |
| 792 | Allow an external diff helper to be executed. If you set an |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 793 | external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need |
| 794 | to use this option with <a href="git-log.html">git-log(1)</a> and friends. |
Junio C Hamano | bb0f404 | 2007-07-04 06:41:40 | [diff] [blame] | 795 | </p> |
| 796 | </dd> |
| 797 | <dt> |
| 798 | --no-ext-diff |
| 799 | </dt> |
| 800 | <dd> |
| 801 | <p> |
| 802 | Disallow external diff drivers. |
| 803 | </p> |
| 804 | </dd> |
Junio C Hamano | e27cbd2 | 2007-12-21 17:57:33 | [diff] [blame] | 805 | <dt> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 806 | --ignore-submodules |
| 807 | </dt> |
| 808 | <dd> |
| 809 | <p> |
| 810 | Ignore changes to submodules in the diff generation. |
| 811 | </p> |
| 812 | </dd> |
| 813 | <dt> |
Junio C Hamano | e27cbd2 | 2007-12-21 17:57:33 | [diff] [blame] | 814 | --src-prefix=<prefix> |
| 815 | </dt> |
| 816 | <dd> |
| 817 | <p> |
| 818 | Show the given source prefix instead of "a/". |
| 819 | </p> |
| 820 | </dd> |
| 821 | <dt> |
| 822 | --dst-prefix=<prefix> |
| 823 | </dt> |
| 824 | <dd> |
| 825 | <p> |
| 826 | Show the given destination prefix instead of "b/". |
| 827 | </p> |
| 828 | </dd> |
| 829 | <dt> |
| 830 | --no-prefix |
| 831 | </dt> |
| 832 | <dd> |
| 833 | <p> |
| 834 | Do not show any source or destination prefix. |
| 835 | </p> |
| 836 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 837 | </dl></div> |
| 838 | <div class="para"><p>For more detailed explanation on these common options, see also |
| 839 | <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div> |
| 840 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 841 | <dt> |
| 842 | <tree-ish> |
| 843 | </dt> |
| 844 | <dd> |
| 845 | <p> |
| 846 | The id of a tree object to diff against. |
| 847 | </p> |
| 848 | </dd> |
| 849 | <dt> |
| 850 | --cached |
| 851 | </dt> |
| 852 | <dd> |
| 853 | <p> |
| 854 | do not consider the on-disk file at all |
| 855 | </p> |
| 856 | </dd> |
| 857 | <dt> |
| 858 | -m |
| 859 | </dt> |
| 860 | <dd> |
| 861 | <p> |
| 862 | By default, files recorded in the index but not checked |
| 863 | out are reported as deleted. This flag makes |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 864 | <em>git diff-index</em> say that all non-checked-out files are up |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 865 | to date. |
| 866 | </p> |
| 867 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 868 | </dl></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 869 | </div> |
Junio C Hamano | 543f8d6 | 2009-07-29 08:35:21 | [diff] [blame] | 870 | <h2 id="_raw_output_format">Raw output format</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 871 | <div class="sectionbody"> |
Junio C Hamano | 543f8d6 | 2009-07-29 08:35:21 | [diff] [blame] | 872 | <div class="para"><p>The raw output format from "git-diff-index", "git-diff-tree", |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 873 | "git-diff-files" and "git diff --raw" are very similar.</p></div> |
| 874 | <div class="para"><p>These commands all compare two sets of things; what is |
| 875 | compared differs:</p></div> |
| 876 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 877 | <dt> |
| 878 | git-diff-index <tree-ish> |
| 879 | </dt> |
| 880 | <dd> |
| 881 | <p> |
| 882 | compares the <tree-ish> and the files on the filesystem. |
| 883 | </p> |
| 884 | </dd> |
| 885 | <dt> |
| 886 | git-diff-index --cached <tree-ish> |
| 887 | </dt> |
| 888 | <dd> |
| 889 | <p> |
| 890 | compares the <tree-ish> and the index. |
| 891 | </p> |
| 892 | </dd> |
| 893 | <dt> |
| 894 | git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] |
| 895 | </dt> |
| 896 | <dd> |
| 897 | <p> |
| 898 | compares the trees named by the two arguments. |
| 899 | </p> |
| 900 | </dd> |
| 901 | <dt> |
| 902 | git-diff-files [<pattern>…] |
| 903 | </dt> |
| 904 | <dd> |
| 905 | <p> |
| 906 | compares the index and the files on the filesystem. |
| 907 | </p> |
| 908 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 909 | </dl></div> |
Junio C Hamano | 543f8d6 | 2009-07-29 08:35:21 | [diff] [blame] | 910 | <div class="para"><p>The "git-diff-tree" command begins its ouput by printing the hash of |
| 911 | what is being compared. After that, all the commands print one output |
| 912 | line per changed file.</p></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 913 | <div class="para"><p>An output line is formatted this way:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 914 | <div class="listingblock"> |
| 915 | <div class="content"> |
| 916 | <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0 |
| 917 | copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2 |
| 918 | rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3 |
| 919 | create :000000 100644 0000000... 1234567... A file4 |
| 920 | delete :100644 000000 1234567... 0000000... D file5 |
| 921 | unmerged :000000 000000 0000000... 0000000... U file6</tt></pre> |
| 922 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 923 | <div class="para"><p>That is, from the left to the right:</p></div> |
| 924 | <div class="olist"><ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 925 | <li> |
| 926 | <p> |
| 927 | a colon. |
| 928 | </p> |
| 929 | </li> |
| 930 | <li> |
| 931 | <p> |
| 932 | mode for "src"; 000000 if creation or unmerged. |
| 933 | </p> |
| 934 | </li> |
| 935 | <li> |
| 936 | <p> |
| 937 | a space. |
| 938 | </p> |
| 939 | </li> |
| 940 | <li> |
| 941 | <p> |
| 942 | mode for "dst"; 000000 if deletion or unmerged. |
| 943 | </p> |
| 944 | </li> |
| 945 | <li> |
| 946 | <p> |
| 947 | a space. |
| 948 | </p> |
| 949 | </li> |
| 950 | <li> |
| 951 | <p> |
| 952 | sha1 for "src"; 0{40} if creation or unmerged. |
| 953 | </p> |
| 954 | </li> |
| 955 | <li> |
| 956 | <p> |
| 957 | a space. |
| 958 | </p> |
| 959 | </li> |
| 960 | <li> |
| 961 | <p> |
| 962 | sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree". |
| 963 | </p> |
| 964 | </li> |
| 965 | <li> |
| 966 | <p> |
| 967 | a space. |
| 968 | </p> |
| 969 | </li> |
| 970 | <li> |
| 971 | <p> |
| 972 | status, followed by optional "score" number. |
| 973 | </p> |
| 974 | </li> |
| 975 | <li> |
| 976 | <p> |
| 977 | a tab or a NUL when <em>-z</em> option is used. |
| 978 | </p> |
| 979 | </li> |
| 980 | <li> |
| 981 | <p> |
| 982 | path for "src" |
| 983 | </p> |
| 984 | </li> |
| 985 | <li> |
| 986 | <p> |
| 987 | a tab or a NUL when <em>-z</em> option is used; only exists for C or R. |
| 988 | </p> |
| 989 | </li> |
| 990 | <li> |
| 991 | <p> |
| 992 | path for "dst"; only exists for C or R. |
| 993 | </p> |
| 994 | </li> |
| 995 | <li> |
| 996 | <p> |
| 997 | an LF or a NUL when <em>-z</em> option is used, to terminate the record. |
| 998 | </p> |
| 999 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1000 | </ol></div> |
Junio C Hamano | aa17c7c | 2008-11-03 04:36:58 | [diff] [blame] | 1001 | <div class="para"><p>Possible status letters are:</p></div> |
| 1002 | <div class="ilist"><ul> |
| 1003 | <li> |
| 1004 | <p> |
| 1005 | A: addition of a file |
| 1006 | </p> |
| 1007 | </li> |
| 1008 | <li> |
| 1009 | <p> |
| 1010 | C: copy of a file into a new one |
| 1011 | </p> |
| 1012 | </li> |
| 1013 | <li> |
| 1014 | <p> |
| 1015 | D: deletion of a file |
| 1016 | </p> |
| 1017 | </li> |
| 1018 | <li> |
| 1019 | <p> |
| 1020 | M: modification of the contents or mode of a file |
| 1021 | </p> |
| 1022 | </li> |
| 1023 | <li> |
| 1024 | <p> |
| 1025 | R: renaming of a file |
| 1026 | </p> |
| 1027 | </li> |
| 1028 | <li> |
| 1029 | <p> |
| 1030 | T: change in the type of the file |
| 1031 | </p> |
| 1032 | </li> |
| 1033 | <li> |
| 1034 | <p> |
| 1035 | U: file is unmerged (you must complete the merge before it can |
| 1036 | be committed) |
| 1037 | </p> |
| 1038 | </li> |
| 1039 | <li> |
| 1040 | <p> |
| 1041 | X: "unknown" change type (most probably a bug, please report it) |
| 1042 | </p> |
| 1043 | </li> |
| 1044 | </ul></div> |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame] | 1045 | <div class="para"><p>Status letters C and R are always followed by a score (denoting the |
Junio C Hamano | aa17c7c | 2008-11-03 04:36:58 | [diff] [blame] | 1046 | percentage of similarity between the source and target of the move or |
| 1047 | copy), and are the only ones to be so.</p></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1048 | <div class="para"><p><sha1> is shown as all 0's if a file is new on the filesystem |
| 1049 | and it is out of sync with the index.</p></div> |
| 1050 | <div class="para"><p>Example:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1051 | <div class="listingblock"> |
| 1052 | <div class="content"> |
| 1053 | <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre> |
| 1054 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1055 | <div class="para"><p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1056 | in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>, |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1057 | respectively.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1058 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1059 | <h2 id="_diff_format_for_merges">diff format for merges</h2> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1060 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1061 | <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff --raw" |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1062 | can take <em>-c</em> or <em>--cc</em> option |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1063 | to generate diff output also for merge commits. The output differs |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1064 | from the format described above in the following way:</p></div> |
| 1065 | <div class="olist"><ol> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1066 | <li> |
| 1067 | <p> |
| 1068 | there is a colon for each parent |
| 1069 | </p> |
| 1070 | </li> |
| 1071 | <li> |
| 1072 | <p> |
| 1073 | there are more "src" modes and "src" sha1 |
| 1074 | </p> |
| 1075 | </li> |
| 1076 | <li> |
| 1077 | <p> |
| 1078 | status is concatenated status characters for each parent |
| 1079 | </p> |
| 1080 | </li> |
| 1081 | <li> |
| 1082 | <p> |
| 1083 | no optional "score" number |
| 1084 | </p> |
| 1085 | </li> |
| 1086 | <li> |
| 1087 | <p> |
| 1088 | single path, only for "dst" |
| 1089 | </p> |
| 1090 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1091 | </ol></div> |
| 1092 | <div class="para"><p>Example:</p></div> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1093 | <div class="listingblock"> |
| 1094 | <div class="content"> |
| 1095 | <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre> |
| 1096 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1097 | <div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from |
| 1098 | all parents.</p></div> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1099 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1100 | <h2 id="_generating_patches_with_p">Generating patches with -p</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1101 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1102 | <div class="para"><p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run |
Junio C Hamano | 00b8b63 | 2007-12-07 09:50:49 | [diff] [blame] | 1103 | with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or |
| 1104 | "git log" with the "-p" option, they |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1105 | do not produce the output described above; instead they produce a |
| 1106 | patch file. You can customize the creation of such patches via the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1107 | GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div> |
| 1108 | <div class="para"><p>What the -p option produces is slightly different from the traditional |
| 1109 | diff format.</p></div> |
| 1110 | <div class="olist"><ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1111 | <li> |
| 1112 | <p> |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 1113 | It is preceded with a "git diff" header, that looks like |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1114 | this: |
| 1115 | </p> |
| 1116 | <div class="literalblock"> |
| 1117 | <div class="content"> |
| 1118 | <pre><tt>diff --git a/file1 b/file2</tt></pre> |
| 1119 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1120 | <div class="para"><p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1121 | involved. Especially, even for a creation or a deletion, |
Junio C Hamano | e1b2683 | 2009-11-15 10:02:56 | [diff] [blame] | 1122 | <tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1123 | <div class="para"><p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1124 | name of the source file of the rename/copy and the name of |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1125 | the file that rename/copy produces, respectively.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1126 | </li> |
| 1127 | <li> |
| 1128 | <p> |
| 1129 | It is followed by one or more extended header lines: |
| 1130 | </p> |
| 1131 | <div class="literalblock"> |
| 1132 | <div class="content"> |
| 1133 | <pre><tt>old mode <mode> |
| 1134 | new mode <mode> |
| 1135 | deleted file mode <mode> |
| 1136 | new file mode <mode> |
| 1137 | copy from <path> |
| 1138 | copy to <path> |
| 1139 | rename from <path> |
| 1140 | rename to <path> |
| 1141 | similarity index <number> |
| 1142 | dissimilarity index <number> |
| 1143 | index <hash>..<hash> <mode></tt></pre> |
| 1144 | </div></div> |
| 1145 | </li> |
| 1146 | <li> |
| 1147 | <p> |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 1148 | TAB, LF, double quote and backslash characters in pathnames |
| 1149 | are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively. |
| 1150 | If there is need for such substitution then the whole |
| 1151 | pathname is put in double quotes. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1152 | </p> |
| 1153 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1154 | </ol></div> |
| 1155 | <div class="para"><p>The similarity index is the percentage of unchanged lines, and |
Junio C Hamano | d526ba9 | 2007-07-02 00:17:42 | [diff] [blame] | 1156 | the dissimilarity index is the percentage of changed lines. It |
| 1157 | is a rounded down integer, followed by a percent sign. The |
| 1158 | similarity index value of 100% is thus reserved for two equal |
| 1159 | files, while 100% dissimilarity means that no line from the old |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1160 | file made it into the new one.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1161 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1162 | <h2 id="_combined_diff_format">combined diff format</h2> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1163 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1164 | <div class="para"><p>"git-diff-tree", "git-diff-files" and "git-diff" can take <em>-c</em> or |
Junio C Hamano | 00b8b63 | 2007-12-07 09:50:49 | [diff] [blame] | 1165 | <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit |
| 1166 | with "git log -p", this is the default format. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1167 | A <em>combined diff</em> format looks like this:</p></div> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1168 | <div class="listingblock"> |
| 1169 | <div class="content"> |
| 1170 | <pre><tt>diff --combined describe.c |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1171 | index fabadb8,cc95eb0..4866510 |
| 1172 | --- a/describe.c |
| 1173 | +++ b/describe.c |
| 1174 | @@@ -98,20 -98,12 +98,20 @@@ |
| 1175 | return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | - static void describe(char *arg) |
| 1179 | -static void describe(struct commit *cmit, int last_one) |
| 1180 | ++static void describe(char *arg, int last_one) |
| 1181 | { |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1182 | + unsigned char sha1[20]; |
| 1183 | + struct commit *cmit; |
| 1184 | struct commit_list *list; |
| 1185 | static int initialized = 0; |
| 1186 | struct commit_name *n; |
| 1187 | |
| 1188 | + if (get_sha1(arg, sha1) < 0) |
| 1189 | + usage(describe_usage); |
| 1190 | + cmit = lookup_commit_reference(sha1); |
| 1191 | + if (!cmit) |
| 1192 | + usage(describe_usage); |
| 1193 | + |
| 1194 | if (!initialized) { |
| 1195 | initialized = 1; |
| 1196 | for_each_ref(get_name);</tt></pre> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1197 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1198 | <div class="olist"><ol> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1199 | <li> |
| 1200 | <p> |
| 1201 | It is preceded with a "git diff" header, that looks like |
| 1202 | this (when <em>-c</em> option is used): |
| 1203 | </p> |
| 1204 | <div class="literalblock"> |
| 1205 | <div class="content"> |
| 1206 | <pre><tt>diff --combined file</tt></pre> |
| 1207 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1208 | <div class="para"><p>or like this (when <em>--cc</em> option is used):</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1209 | <div class="literalblock"> |
| 1210 | <div class="content"> |
Junio C Hamano | 0868a30 | 2008-07-22 09:20:44 | [diff] [blame] | 1211 | <pre><tt>diff --cc file</tt></pre> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1212 | </div></div> |
| 1213 | </li> |
| 1214 | <li> |
| 1215 | <p> |
| 1216 | It is followed by one or more extended header lines |
| 1217 | (this example shows a merge with two parents): |
| 1218 | </p> |
| 1219 | <div class="literalblock"> |
| 1220 | <div class="content"> |
| 1221 | <pre><tt>index <hash>,<hash>..<hash> |
| 1222 | mode <mode>,<mode>..<mode> |
| 1223 | new file mode <mode> |
| 1224 | deleted file mode <mode>,<mode></tt></pre> |
| 1225 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1226 | <div class="para"><p>The <tt>mode <mode>,<mode>..<mode></tt> line appears only if at least one of |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 1227 | the <mode> is different from the rest. Extended headers with |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1228 | information about detected contents movement (renames and |
| 1229 | copying detection) are designed to work with diff of two |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1230 | <tree-ish> and are not used by combined diff format.</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1231 | </li> |
| 1232 | <li> |
| 1233 | <p> |
| 1234 | It is followed by two-line from-file/to-file header |
| 1235 | </p> |
| 1236 | <div class="literalblock"> |
| 1237 | <div class="content"> |
| 1238 | <pre><tt>--- a/file |
| 1239 | +++ b/file</tt></pre> |
| 1240 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1241 | <div class="para"><p>Similar to two-line header for traditional <em>unified</em> diff |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1242 | format, <tt>/dev/null</tt> is used to signal created or deleted |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1243 | files.</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1244 | </li> |
| 1245 | <li> |
| 1246 | <p> |
| 1247 | Chunk header format is modified to prevent people from |
| 1248 | accidentally feeding it to <tt>patch -p1</tt>. Combined diff format |
| 1249 | was created for review of merge commit changes, and was not |
| 1250 | meant for apply. The change is similar to the change in the |
| 1251 | extended <em>index</em> header: |
| 1252 | </p> |
| 1253 | <div class="literalblock"> |
| 1254 | <div class="content"> |
| 1255 | <pre><tt>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</tt></pre> |
| 1256 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1257 | <div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk |
| 1258 | header for combined diff format.</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1259 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1260 | </ol></div> |
| 1261 | <div class="para"><p>Unlike the traditional <em>unified</em> diff format, which shows two |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1262 | files A and B with a single column that has <tt>-</tt> (minus — |
| 1263 | appears in A but removed in B), <tt>+</tt> (plus — missing in A but |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1264 | added to B), or <tt>" "</tt> (space — unchanged) prefix, this format |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1265 | compares two or more files file1, file2,… with one file X, and |
| 1266 | shows how X differs from each of fileN. One column for each of |
| 1267 | fileN is prepended to the output line to note how X's line is |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1268 | different from it.</p></div> |
| 1269 | <div class="para"><p>A <tt>-</tt> character in the column N means that the line appears in |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1270 | fileN but it does not appear in the result. A <tt>+</tt> character |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame] | 1271 | in the column N means that the line appears in the result, |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1272 | and fileN does not have that line (in other words, the line was |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1273 | added, from the point of view of that parent).</p></div> |
| 1274 | <div class="para"><p>In the above example output, the function signature was changed |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1275 | from both files (hence two <tt>-</tt> removals from both file1 and |
Junio C Hamano | 4604fe5 | 2008-09-19 06:37:10 | [diff] [blame] | 1276 | file2, plus <tt>++</tt> to mean one line that was added does not appear |
Junio C Hamano | 54bf1e2 | 2008-12-20 06:30:11 | [diff] [blame] | 1277 | in either file1 nor file2). Also eight other lines are the same |
| 1278 | from file1 but do not appear in file2 (hence prefixed with <tt>+</tt>).</p></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1279 | <div class="para"><p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1280 | merge commit with the merge result (i.e. file1..fileN are the |
| 1281 | parents). When shown by <tt>git diff-files -c</tt>, it compares the |
| 1282 | two unresolved merge parents with the working tree file |
| 1283 | (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1284 | "their version").</p></div> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1285 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1286 | <h2 id="_other_diff_formats">other diff formats</h2> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1287 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1288 | <div class="para"><p>The <tt>--summary</tt> option describes newly added, deleted, renamed and |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1289 | copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the |
| 1290 | output. These options can be combined with other options, such as |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1291 | <tt>-p</tt>, and are meant for human consumption.</p></div> |
| 1292 | <div class="para"><p>When showing a change that involves a rename or a copy, <tt>--stat</tt> output |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1293 | formats the pathnames compactly by combining common prefix and suffix of |
| 1294 | the pathnames. For example, a change that moves <tt>arch/i386/Makefile</tt> to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1295 | <tt>arch/x86/Makefile</tt> while modifying 4 lines will be shown like this:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1296 | <div class="listingblock"> |
| 1297 | <div class="content"> |
| 1298 | <pre><tt>arch/{i386 => x86}/Makefile | 4 +--</tt></pre> |
| 1299 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1300 | <div class="para"><p>The <tt>--numstat</tt> option gives the diffstat(1) information but is designed |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1301 | for easier machine consumption. An entry in <tt>--numstat</tt> output looks |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1302 | like this:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1303 | <div class="listingblock"> |
| 1304 | <div class="content"> |
| 1305 | <pre><tt>1 2 README |
| 1306 | 3 1 arch/{i386 => x86}/Makefile</tt></pre> |
| 1307 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1308 | <div class="para"><p>That is, from left to right:</p></div> |
| 1309 | <div class="olist"><ol> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1310 | <li> |
| 1311 | <p> |
| 1312 | the number of added lines; |
| 1313 | </p> |
| 1314 | </li> |
| 1315 | <li> |
| 1316 | <p> |
| 1317 | a tab; |
| 1318 | </p> |
| 1319 | </li> |
| 1320 | <li> |
| 1321 | <p> |
| 1322 | the number of deleted lines; |
| 1323 | </p> |
| 1324 | </li> |
| 1325 | <li> |
| 1326 | <p> |
| 1327 | a tab; |
| 1328 | </p> |
| 1329 | </li> |
| 1330 | <li> |
| 1331 | <p> |
| 1332 | pathname (possibly with rename/copy information); |
| 1333 | </p> |
| 1334 | </li> |
| 1335 | <li> |
| 1336 | <p> |
| 1337 | a newline. |
| 1338 | </p> |
| 1339 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1340 | </ol></div> |
| 1341 | <div class="para"><p>When <tt>-z</tt> output option is in effect, the output is formatted this way:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1342 | <div class="listingblock"> |
| 1343 | <div class="content"> |
| 1344 | <pre><tt>1 2 README NUL |
| 1345 | 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre> |
| 1346 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1347 | <div class="para"><p>That is:</p></div> |
| 1348 | <div class="olist"><ol> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1349 | <li> |
| 1350 | <p> |
| 1351 | the number of added lines; |
| 1352 | </p> |
| 1353 | </li> |
| 1354 | <li> |
| 1355 | <p> |
| 1356 | a tab; |
| 1357 | </p> |
| 1358 | </li> |
| 1359 | <li> |
| 1360 | <p> |
| 1361 | the number of deleted lines; |
| 1362 | </p> |
| 1363 | </li> |
| 1364 | <li> |
| 1365 | <p> |
| 1366 | a tab; |
| 1367 | </p> |
| 1368 | </li> |
| 1369 | <li> |
| 1370 | <p> |
| 1371 | a NUL (only exists if renamed/copied); |
| 1372 | </p> |
| 1373 | </li> |
| 1374 | <li> |
| 1375 | <p> |
| 1376 | pathname in preimage; |
| 1377 | </p> |
| 1378 | </li> |
| 1379 | <li> |
| 1380 | <p> |
| 1381 | a NUL (only exists if renamed/copied); |
| 1382 | </p> |
| 1383 | </li> |
| 1384 | <li> |
| 1385 | <p> |
| 1386 | pathname in postimage (only exists if renamed/copied); |
| 1387 | </p> |
| 1388 | </li> |
| 1389 | <li> |
| 1390 | <p> |
| 1391 | a NUL. |
| 1392 | </p> |
| 1393 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1394 | </ol></div> |
| 1395 | <div class="para"><p>The extra <tt>NUL</tt> before the preimage path in renamed case is to allow |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1396 | scripts that read the output to tell if the current record being read is |
| 1397 | a single-path record or a rename/copy record without reading ahead. |
| 1398 | After reading added and deleted lines, reading up to <tt>NUL</tt> would yield |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1399 | the pathname, but if that is <tt>NUL</tt>, the record will show two paths.</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1400 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1401 | <h2 id="_operating_modes">Operating Modes</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1402 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1403 | <div class="para"><p>You can choose whether you want to trust the index file entirely |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1404 | (using the <em>--cached</em> flag) or ask the diff logic to show any files |
| 1405 | that don't match the stat state as being "tentatively changed". Both |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1406 | of these operations are very useful indeed.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1407 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1408 | <h2 id="_cached_mode">Cached Mode</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1409 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1410 | <div class="para"><p>If <em>--cached</em> is specified, it allows you to ask:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1411 | <div class="literalblock"> |
| 1412 | <div class="content"> |
| 1413 | <pre><tt>show me the differences between HEAD and the current index |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1414 | contents (the ones I'd write using 'git write-tree')</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1415 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1416 | <div class="para"><p>For example, let's say that you have worked on your working directory, updated |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 1417 | some files in the index and are ready to commit. You want to see exactly |
Junio C Hamano | dcc22ee | 2006-11-03 02:40:13 | [diff] [blame] | 1418 | <strong>what</strong> you are going to commit, without having to write a new tree |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1419 | object and compare it that way, and to do that, you just do</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1420 | <div class="literalblock"> |
| 1421 | <div class="content"> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1422 | <pre><tt>git diff-index --cached HEAD</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1423 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1424 | <div class="para"><p>Example: let's say I had renamed <tt>commit.c</tt> to <tt>git-commit.c</tt>, and I had |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1425 | done an <tt>update-index</tt> to make that effective in the index file. |
| 1426 | <tt>git diff-files</tt> wouldn't show anything at all, since the index file |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1427 | matches my working directory. But doing a <em>git diff-index</em> does:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1428 | <div class="literalblock"> |
| 1429 | <div class="content"> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1430 | <pre><tt>torvalds@ppc970:~/git> git diff-index --cached HEAD |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1431 | -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c |
| 1432 | +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre> |
| 1433 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1434 | <div class="para"><p>You can see easily that the above is a rename.</p></div> |
| 1435 | <div class="para"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1436 | actually doing a <em>git write-tree</em> and comparing that. Except this one is much |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1437 | nicer for the case where you just want to check where you are.</p></div> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1438 | <div class="para"><p>So doing a <tt>git diff-index --cached</tt> is basically very useful when you are |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1439 | asking yourself "what have I already marked for being committed, and |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1440 | what's the difference to a previous tree".</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1441 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1442 | <h2 id="_non_cached_mode">Non-cached Mode</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1443 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1444 | <div class="para"><p>The "non-cached" mode takes a different approach, and is potentially |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1445 | the more useful of the two in that what it does can't be emulated with |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1446 | a <em>git write-tree</em> + <em>git diff-tree</em>. Thus that's the default mode. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1447 | The non-cached version asks the question:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1448 | <div class="literalblock"> |
| 1449 | <div class="content"> |
| 1450 | <pre><tt>show me the differences between HEAD and the currently checked out |
| 1451 | tree - index contents _and_ files that aren't up-to-date</tt></pre> |
| 1452 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1453 | <div class="para"><p>which is obviously a very useful question too, since that tells you what |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1454 | you <strong>could</strong> commit. Again, the output matches the <em>git diff-tree -r</em> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1455 | output to a tee, but with a twist.</p></div> |
| 1456 | <div class="para"><p>The twist is that if some file doesn't match the index, we don't have |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1457 | a backing store thing for it, and we use the magic "all-zero" sha1 to |
| 1458 | show that. So let's say that you have edited <tt>kernel/sched.c</tt>, but |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1459 | have not actually done a <em>git update-index</em> on it yet - there is no |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1460 | "object" associated with the new state, and you get:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1461 | <div class="literalblock"> |
| 1462 | <div class="content"> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1463 | <pre><tt>torvalds@ppc970:~/v2.6/linux> git diff-index HEAD |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1464 | *100644->100664 blob 7476bb......->000000...... kernel/sched.c</tt></pre> |
| 1465 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1466 | <div class="para"><p>i.e., it shows that the tree has changed, and that <tt>kernel/sched.c</tt> has is |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1467 | not up-to-date and may contain new stuff. The all-zero sha1 means that to |
| 1468 | get the real diff, you need to look at the object in the working directory |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1469 | directly rather than do an object-to-object diff.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1470 | <div class="admonitionblock"> |
| 1471 | <table><tr> |
| 1472 | <td class="icon"> |
| 1473 | <div class="title">Note</div> |
| 1474 | </td> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1475 | <td class="content">As with other commands of this type, <em>git diff-index</em> does not |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1476 | actually look at the contents of the file at all. So maybe |
| 1477 | <tt>kernel/sched.c</tt> hasn't actually changed, and it's just that you |
| 1478 | touched it. In either case, it's a note that you need to |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1479 | <em>git update-index</em> it to make the index be in sync.</td> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1480 | </tr></table> |
| 1481 | </div> |
| 1482 | <div class="admonitionblock"> |
| 1483 | <table><tr> |
| 1484 | <td class="icon"> |
| 1485 | <div class="title">Note</div> |
| 1486 | </td> |
| 1487 | <td class="content">You can have a mixture of files show up as "has been updated" |
| 1488 | and "is still dirty in the working directory" together. You can always |
| 1489 | tell which file is in which state, since the "has been updated" ones |
| 1490 | show a valid sha1, and the "not in sync with the index" ones will |
| 1491 | always have the special all-zero sha1.</td> |
| 1492 | </tr></table> |
| 1493 | </div> |
| 1494 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1495 | <h2 id="_author">Author</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1496 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1497 | <div class="para"><p>Written by Linus Torvalds <torvalds@osdl.org></p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1498 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1499 | <h2 id="_documentation">Documentation</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1500 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1501 | <div class="para"><p>Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1502 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1503 | <h2 id="_git">GIT</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1504 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1505 | <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1506 | </div> |
| 1507 | <div id="footer"> |
| 1508 | <div id="footer-text"> |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame^] | 1509 | Last updated 2010-01-21 17:44:26 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1510 | </div> |
| 1511 | </div> |
| 1512 | </body> |
| 1513 | </html> |