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> |
| 339 | <dd> |
| 340 | <p> |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 341 | Generate patch (see section on generating patches). |
| 342 | |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 343 | </p> |
| 344 | </dd> |
| 345 | <dt> |
| 346 | -u |
| 347 | </dt> |
| 348 | <dd> |
| 349 | <p> |
| 350 | Synonym for "-p". |
| 351 | </p> |
| 352 | </dd> |
| 353 | <dt> |
Junio C Hamano | 6936156 | 2007-07-26 02:14:34 | [diff] [blame] | 354 | -U<n> |
| 355 | </dt> |
| 356 | <dd> |
| 357 | <p> |
| 358 | Shorthand for "--unified=<n>". |
| 359 | </p> |
| 360 | </dd> |
| 361 | <dt> |
| 362 | --unified=<n> |
| 363 | </dt> |
| 364 | <dd> |
| 365 | <p> |
| 366 | Generate diffs with <n> lines of context instead of |
| 367 | the usual three. Implies "-p". |
| 368 | </p> |
| 369 | </dd> |
| 370 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 371 | --raw |
| 372 | </dt> |
| 373 | <dd> |
| 374 | <p> |
| 375 | Generate the raw format. |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 376 | This is the default. |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 377 | </p> |
| 378 | </dd> |
| 379 | <dt> |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 380 | --patch-with-raw |
| 381 | </dt> |
| 382 | <dd> |
| 383 | <p> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 384 | Synonym for "-p --raw". |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 385 | </p> |
| 386 | </dd> |
| 387 | <dt> |
Junio C Hamano | 4a9a76a | 2006-10-01 05:40:29 | [diff] [blame] | 388 | --stat[=width[,name-width]] |
Junio C Hamano | ba7c8d8 | 2006-04-15 06:17:42 | [diff] [blame] | 389 | </dt> |
| 390 | <dd> |
| 391 | <p> |
Junio C Hamano | 4a9a76a | 2006-10-01 05:40:29 | [diff] [blame] | 392 | Generate a diffstat. You can override the default |
| 393 | output width for 80-column terminal by "--stat=width". |
| 394 | The width of the filename part can be controlled by |
| 395 | giving another width to it separated by a comma. |
Junio C Hamano | ba7c8d8 | 2006-04-15 06:17:42 | [diff] [blame] | 396 | </p> |
| 397 | </dd> |
| 398 | <dt> |
Junio C Hamano | fbe0052 | 2006-10-19 05:58:48 | [diff] [blame] | 399 | --numstat |
| 400 | </dt> |
| 401 | <dd> |
| 402 | <p> |
| 403 | Similar to --stat, but shows number of added and |
| 404 | deleted lines in decimal notation and pathname without |
Junio C Hamano | d793de5 | 2006-12-26 09:11:43 | [diff] [blame] | 405 | abbreviation, to make it more machine friendly. For |
| 406 | binary files, outputs two <tt>-</tt> instead of saying |
| 407 | <tt>0 0</tt>. |
Junio C Hamano | fbe0052 | 2006-10-19 05:58:48 | [diff] [blame] | 408 | </p> |
| 409 | </dd> |
| 410 | <dt> |
Junio C Hamano | 7d23f5e | 2006-12-16 07:44:04 | [diff] [blame] | 411 | --shortstat |
| 412 | </dt> |
| 413 | <dd> |
| 414 | <p> |
| 415 | Output only the last line of the --stat format containing total |
| 416 | number of modified files, as well as number of added and deleted |
| 417 | lines. |
| 418 | </p> |
| 419 | </dd> |
| 420 | <dt> |
Junio C Hamano | 6a45be9 | 2008-04-22 08:19:03 | [diff] [blame] | 421 | --dirstat[=limit] |
| 422 | </dt> |
| 423 | <dd> |
| 424 | <p> |
| 425 | Output only the sub-directories that are impacted by a diff, |
| 426 | and to what degree they are impacted. You can override the |
| 427 | default cut-off in percent (3) by "--dirstat=limit". If you |
| 428 | want to enable "cumulative" directory statistics, you can use |
| 429 | the "--cumulative" flag, which adds up percentages recursively |
| 430 | even when they have been already reported for a sub-directory. |
| 431 | </p> |
| 432 | </dd> |
| 433 | <dt> |
Junio C Hamano | 6959c6c | 2006-05-17 10:34:11 | [diff] [blame] | 434 | --summary |
| 435 | </dt> |
| 436 | <dd> |
| 437 | <p> |
| 438 | Output a condensed summary of extended header information |
| 439 | such as creations, renames and mode changes. |
| 440 | </p> |
| 441 | </dd> |
| 442 | <dt> |
Junio C Hamano | d1308c9 | 2006-04-16 11:01:09 | [diff] [blame] | 443 | --patch-with-stat |
| 444 | </dt> |
| 445 | <dd> |
| 446 | <p> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 447 | Synonym for "-p --stat". |
Junio C Hamano | ff97979 | 2007-11-16 10:11:30 | [diff] [blame] | 448 | |
Junio C Hamano | d1308c9 | 2006-04-16 11:01:09 | [diff] [blame] | 449 | </p> |
| 450 | </dd> |
| 451 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 452 | -z |
| 453 | </dt> |
| 454 | <dd> |
| 455 | <p> |
Junio C Hamano | b968dbb | 2007-07-27 07:26:40 | [diff] [blame] | 456 | NUL-line termination on output. This affects the --raw |
| 457 | output field terminator. Also output from commands such |
| 458 | as "git-log" will be delimited with NUL between commits. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 459 | </p> |
| 460 | </dd> |
| 461 | <dt> |
| 462 | --name-only |
| 463 | </dt> |
| 464 | <dd> |
| 465 | <p> |
| 466 | Show only names of changed files. |
| 467 | </p> |
| 468 | </dd> |
| 469 | <dt> |
| 470 | --name-status |
| 471 | </dt> |
| 472 | <dd> |
| 473 | <p> |
Junio C Hamano | a9aee78 | 2008-04-23 16:09:20 | [diff] [blame] | 474 | Show only names and status of changed files. See the description |
| 475 | 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] | 476 | </p> |
| 477 | </dd> |
| 478 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 479 | --color |
| 480 | </dt> |
| 481 | <dd> |
| 482 | <p> |
| 483 | Show colored diff. |
| 484 | </p> |
| 485 | </dd> |
| 486 | <dt> |
| 487 | --no-color |
| 488 | </dt> |
| 489 | <dd> |
| 490 | <p> |
| 491 | Turn off colored diff, even when the configuration file |
| 492 | gives the default to color output. |
| 493 | </p> |
| 494 | </dd> |
| 495 | <dt> |
Junio C Hamano | 85e45fa | 2006-08-13 07:47:41 | [diff] [blame] | 496 | --color-words |
| 497 | </dt> |
| 498 | <dd> |
| 499 | <p> |
| 500 | Show colored word diff, i.e. color words which have changed. |
| 501 | </p> |
| 502 | </dd> |
| 503 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 504 | --no-renames |
| 505 | </dt> |
| 506 | <dd> |
| 507 | <p> |
| 508 | Turn off rename detection, even when the configuration |
| 509 | file gives the default to do so. |
| 510 | </p> |
| 511 | </dd> |
| 512 | <dt> |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 513 | --check |
| 514 | </dt> |
| 515 | <dd> |
| 516 | <p> |
| 517 | Warn if changes introduce trailing whitespace |
Junio C Hamano | 3dac504 | 2007-12-15 08:40:54 | [diff] [blame] | 518 | or an indent that uses a space before a tab. Exits with |
| 519 | non-zero status if problems are found. Not compatible with |
| 520 | --exit-code. |
Junio C Hamano | a890c4f | 2007-01-28 10:29:21 | [diff] [blame] | 521 | </p> |
| 522 | </dd> |
| 523 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 524 | --full-index |
| 525 | </dt> |
| 526 | <dd> |
| 527 | <p> |
| 528 | Instead of the first handful characters, show full |
| 529 | object name of pre- and post-image blob on the "index" |
| 530 | line when generating a patch format output. |
| 531 | </p> |
| 532 | </dd> |
| 533 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 534 | --binary |
| 535 | </dt> |
| 536 | <dd> |
| 537 | <p> |
| 538 | In addition to --full-index, output "binary diff" that |
| 539 | can be applied with "git apply". |
| 540 | </p> |
| 541 | </dd> |
| 542 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 543 | --abbrev[=<n>] |
| 544 | </dt> |
| 545 | <dd> |
| 546 | <p> |
| 547 | Instead of showing the full 40-byte hexadecimal object |
| 548 | name in diff-raw format output and diff-tree header |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 549 | lines, show only handful hexdigits prefix. This is |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 550 | independent of --full-index option above, which controls |
| 551 | the diff-patch output format. Non default number of |
| 552 | digits can be specified with --abbrev=<n>. |
| 553 | </p> |
| 554 | </dd> |
| 555 | <dt> |
| 556 | -B |
| 557 | </dt> |
| 558 | <dd> |
| 559 | <p> |
| 560 | Break complete rewrite changes into pairs of delete and create. |
| 561 | </p> |
| 562 | </dd> |
| 563 | <dt> |
| 564 | -M |
| 565 | </dt> |
| 566 | <dd> |
| 567 | <p> |
| 568 | Detect renames. |
| 569 | </p> |
| 570 | </dd> |
| 571 | <dt> |
| 572 | -C |
| 573 | </dt> |
| 574 | <dd> |
| 575 | <p> |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 576 | 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] | 577 | </p> |
| 578 | </dd> |
| 579 | <dt> |
Junio C Hamano | 6ec31b9 | 2006-02-10 05:52:01 | [diff] [blame] | 580 | --diff-filter=[ACDMRTUXB*] |
| 581 | </dt> |
| 582 | <dd> |
| 583 | <p> |
| 584 | Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>), |
| 585 | Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their |
| 586 | type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are |
| 587 | Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>). |
| 588 | Any combination of the filter characters may be used. |
| 589 | When <tt>*</tt> (All-or-none) is added to the combination, all |
| 590 | paths are selected if there is any file that matches |
| 591 | other criteria in the comparison; if there is no file |
| 592 | that matches other criteria, nothing is selected. |
| 593 | </p> |
| 594 | </dd> |
| 595 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 596 | --find-copies-harder |
| 597 | </dt> |
| 598 | <dd> |
| 599 | <p> |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 600 | For performance reasons, by default, <tt>-C</tt> option finds copies only |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 601 | if the original file of the copy was modified in the same |
| 602 | changeset. This flag makes the command |
| 603 | inspect unmodified files as candidates for the source of |
| 604 | copy. This is a very expensive operation for large |
Junio C Hamano | 16f9887 | 2007-06-12 16:09:14 | [diff] [blame] | 605 | projects, so use it with caution. Giving more than one |
| 606 | <tt>-C</tt> option has the same effect. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 607 | </p> |
| 608 | </dd> |
| 609 | <dt> |
| 610 | -l<num> |
| 611 | </dt> |
| 612 | <dd> |
| 613 | <p> |
| 614 | -M and -C options require O(n^2) processing time where n |
| 615 | is the number of potential rename/copy targets. This |
| 616 | option prevents rename/copy detection from running if |
| 617 | the number of rename/copy targets exceeds the specified |
| 618 | number. |
| 619 | </p> |
| 620 | </dd> |
| 621 | <dt> |
| 622 | -S<string> |
| 623 | </dt> |
| 624 | <dd> |
| 625 | <p> |
| 626 | Look for differences that contain the change in <string>. |
| 627 | </p> |
| 628 | </dd> |
| 629 | <dt> |
| 630 | --pickaxe-all |
| 631 | </dt> |
| 632 | <dd> |
| 633 | <p> |
| 634 | When -S finds a change, show all the changes in that |
| 635 | changeset, not just the files that contain the change |
| 636 | in <string>. |
| 637 | </p> |
| 638 | </dd> |
| 639 | <dt> |
Junio C Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 640 | --pickaxe-regex |
| 641 | </dt> |
| 642 | <dd> |
| 643 | <p> |
| 644 | Make the <string> not a plain string but an extended POSIX |
| 645 | regex to match. |
| 646 | </p> |
| 647 | </dd> |
| 648 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 649 | -O<orderfile> |
| 650 | </dt> |
| 651 | <dd> |
| 652 | <p> |
| 653 | Output the patch in the order specified in the |
| 654 | <orderfile>, which has one shell glob pattern per line. |
| 655 | </p> |
| 656 | </dd> |
| 657 | <dt> |
| 658 | -R |
| 659 | </dt> |
| 660 | <dd> |
| 661 | <p> |
| 662 | Swap two inputs; that is, show differences from index or |
| 663 | on-disk file to tree contents. |
| 664 | </p> |
| 665 | </dd> |
Junio C Hamano | c26f548 | 2006-07-09 09:38:14 | [diff] [blame] | 666 | <dt> |
Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 667 | --relative[=<path>] |
| 668 | </dt> |
| 669 | <dd> |
| 670 | <p> |
| 671 | When run from a subdirectory of the project, it can be |
| 672 | told to exclude changes outside the directory and show |
| 673 | pathnames relative to it with this option. When you are |
| 674 | not in a subdirectory (e.g. in a bare repository), you |
| 675 | can name which subdirectory to make the output relative |
| 676 | to by giving a <path> as an argument. |
| 677 | </p> |
| 678 | </dd> |
| 679 | <dt> |
Junio C Hamano | c26f548 | 2006-07-09 09:38:14 | [diff] [blame] | 680 | --text |
| 681 | </dt> |
| 682 | <dd> |
| 683 | <p> |
| 684 | Treat all files as text. |
| 685 | </p> |
| 686 | </dd> |
| 687 | <dt> |
| 688 | -a |
| 689 | </dt> |
| 690 | <dd> |
| 691 | <p> |
| 692 | Shorthand for "--text". |
| 693 | </p> |
| 694 | </dd> |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 695 | <dt> |
Junio C Hamano | fd46896 | 2007-02-14 23:45:04 | [diff] [blame] | 696 | --ignore-space-at-eol |
| 697 | </dt> |
| 698 | <dd> |
| 699 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 700 | Ignore changes in whitespace at EOL. |
Junio C Hamano | fd46896 | 2007-02-14 23:45:04 | [diff] [blame] | 701 | </p> |
| 702 | </dd> |
| 703 | <dt> |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 704 | --ignore-space-change |
| 705 | </dt> |
| 706 | <dd> |
| 707 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 708 | Ignore changes in amount of whitespace. This ignores whitespace |
| 709 | at line end, and considers all other sequences of one or |
| 710 | more whitespace characters to be equivalent. |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 711 | </p> |
| 712 | </dd> |
| 713 | <dt> |
| 714 | -b |
| 715 | </dt> |
| 716 | <dd> |
| 717 | <p> |
| 718 | Shorthand for "--ignore-space-change". |
| 719 | </p> |
| 720 | </dd> |
| 721 | <dt> |
| 722 | --ignore-all-space |
| 723 | </dt> |
| 724 | <dd> |
| 725 | <p> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 726 | Ignore whitespace when comparing lines. This ignores |
| 727 | differences even if one line has whitespace where the other |
Junio C Hamano | d9c2d2f | 2006-12-06 08:59:07 | [diff] [blame] | 728 | line has none. |
| 729 | </p> |
| 730 | </dd> |
| 731 | <dt> |
| 732 | -w |
| 733 | </dt> |
| 734 | <dd> |
| 735 | <p> |
| 736 | Shorthand for "--ignore-all-space". |
| 737 | </p> |
| 738 | </dd> |
Junio C Hamano | 48fd2f6 | 2007-03-19 02:02:30 | [diff] [blame] | 739 | <dt> |
| 740 | --exit-code |
| 741 | </dt> |
| 742 | <dd> |
| 743 | <p> |
| 744 | Make the program exit with codes similar to diff(1). |
| 745 | That is, it exits with 1 if there were differences and |
| 746 | 0 means no differences. |
| 747 | </p> |
| 748 | </dd> |
Junio C Hamano | 35e5755 | 2007-03-25 07:54:35 | [diff] [blame] | 749 | <dt> |
| 750 | --quiet |
| 751 | </dt> |
| 752 | <dd> |
| 753 | <p> |
| 754 | Disable all output of the program. Implies --exit-code. |
| 755 | </p> |
| 756 | </dd> |
Junio C Hamano | bb0f404 | 2007-07-04 06:41:40 | [diff] [blame] | 757 | <dt> |
| 758 | --ext-diff |
| 759 | </dt> |
| 760 | <dd> |
| 761 | <p> |
| 762 | Allow an external diff helper to be executed. If you set an |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 763 | external diff driver with <a href="gitattributes.html">gitattributes(5)</a>, you need |
| 764 | 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] | 765 | </p> |
| 766 | </dd> |
| 767 | <dt> |
| 768 | --no-ext-diff |
| 769 | </dt> |
| 770 | <dd> |
| 771 | <p> |
| 772 | Disallow external diff drivers. |
| 773 | </p> |
| 774 | </dd> |
Junio C Hamano | e27cbd2 | 2007-12-21 17:57:33 | [diff] [blame] | 775 | <dt> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 776 | --ignore-submodules |
| 777 | </dt> |
| 778 | <dd> |
| 779 | <p> |
| 780 | Ignore changes to submodules in the diff generation. |
| 781 | </p> |
| 782 | </dd> |
| 783 | <dt> |
Junio C Hamano | e27cbd2 | 2007-12-21 17:57:33 | [diff] [blame] | 784 | --src-prefix=<prefix> |
| 785 | </dt> |
| 786 | <dd> |
| 787 | <p> |
| 788 | Show the given source prefix instead of "a/". |
| 789 | </p> |
| 790 | </dd> |
| 791 | <dt> |
| 792 | --dst-prefix=<prefix> |
| 793 | </dt> |
| 794 | <dd> |
| 795 | <p> |
| 796 | Show the given destination prefix instead of "b/". |
| 797 | </p> |
| 798 | </dd> |
| 799 | <dt> |
| 800 | --no-prefix |
| 801 | </dt> |
| 802 | <dd> |
| 803 | <p> |
| 804 | Do not show any source or destination prefix. |
| 805 | </p> |
| 806 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 807 | </dl></div> |
| 808 | <div class="para"><p>For more detailed explanation on these common options, see also |
| 809 | <a href="gitdiffcore.html">gitdiffcore(7)</a>.</p></div> |
| 810 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 811 | <dt> |
| 812 | <tree-ish> |
| 813 | </dt> |
| 814 | <dd> |
| 815 | <p> |
| 816 | The id of a tree object to diff against. |
| 817 | </p> |
| 818 | </dd> |
| 819 | <dt> |
| 820 | --cached |
| 821 | </dt> |
| 822 | <dd> |
| 823 | <p> |
| 824 | do not consider the on-disk file at all |
| 825 | </p> |
| 826 | </dd> |
| 827 | <dt> |
| 828 | -m |
| 829 | </dt> |
| 830 | <dd> |
| 831 | <p> |
| 832 | By default, files recorded in the index but not checked |
| 833 | out are reported as deleted. This flag makes |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 834 | <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] | 835 | to date. |
| 836 | </p> |
| 837 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 838 | </dl></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 839 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 840 | <h2 id="_output_format">Output format</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 841 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 842 | <div class="para"><p>The output format from "git-diff-index", "git-diff-tree", |
| 843 | "git-diff-files" and "git diff --raw" are very similar.</p></div> |
| 844 | <div class="para"><p>These commands all compare two sets of things; what is |
| 845 | compared differs:</p></div> |
| 846 | <div class="vlist"><dl> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 847 | <dt> |
| 848 | git-diff-index <tree-ish> |
| 849 | </dt> |
| 850 | <dd> |
| 851 | <p> |
| 852 | compares the <tree-ish> and the files on the filesystem. |
| 853 | </p> |
| 854 | </dd> |
| 855 | <dt> |
| 856 | git-diff-index --cached <tree-ish> |
| 857 | </dt> |
| 858 | <dd> |
| 859 | <p> |
| 860 | compares the <tree-ish> and the index. |
| 861 | </p> |
| 862 | </dd> |
| 863 | <dt> |
| 864 | git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] |
| 865 | </dt> |
| 866 | <dd> |
| 867 | <p> |
| 868 | compares the trees named by the two arguments. |
| 869 | </p> |
| 870 | </dd> |
| 871 | <dt> |
| 872 | git-diff-files [<pattern>…] |
| 873 | </dt> |
| 874 | <dd> |
| 875 | <p> |
| 876 | compares the index and the files on the filesystem. |
| 877 | </p> |
| 878 | </dd> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 879 | </dl></div> |
| 880 | <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] | 881 | <div class="listingblock"> |
| 882 | <div class="content"> |
| 883 | <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0 |
| 884 | copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2 |
| 885 | rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3 |
| 886 | create :000000 100644 0000000... 1234567... A file4 |
| 887 | delete :100644 000000 1234567... 0000000... D file5 |
| 888 | unmerged :000000 000000 0000000... 0000000... U file6</tt></pre> |
| 889 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 890 | <div class="para"><p>That is, from the left to the right:</p></div> |
| 891 | <div class="olist"><ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 892 | <li> |
| 893 | <p> |
| 894 | a colon. |
| 895 | </p> |
| 896 | </li> |
| 897 | <li> |
| 898 | <p> |
| 899 | mode for "src"; 000000 if creation or unmerged. |
| 900 | </p> |
| 901 | </li> |
| 902 | <li> |
| 903 | <p> |
| 904 | a space. |
| 905 | </p> |
| 906 | </li> |
| 907 | <li> |
| 908 | <p> |
| 909 | mode for "dst"; 000000 if deletion or unmerged. |
| 910 | </p> |
| 911 | </li> |
| 912 | <li> |
| 913 | <p> |
| 914 | a space. |
| 915 | </p> |
| 916 | </li> |
| 917 | <li> |
| 918 | <p> |
| 919 | sha1 for "src"; 0{40} if creation or unmerged. |
| 920 | </p> |
| 921 | </li> |
| 922 | <li> |
| 923 | <p> |
| 924 | a space. |
| 925 | </p> |
| 926 | </li> |
| 927 | <li> |
| 928 | <p> |
| 929 | sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree". |
| 930 | </p> |
| 931 | </li> |
| 932 | <li> |
| 933 | <p> |
| 934 | a space. |
| 935 | </p> |
| 936 | </li> |
| 937 | <li> |
| 938 | <p> |
| 939 | status, followed by optional "score" number. |
| 940 | </p> |
| 941 | </li> |
| 942 | <li> |
| 943 | <p> |
| 944 | a tab or a NUL when <em>-z</em> option is used. |
| 945 | </p> |
| 946 | </li> |
| 947 | <li> |
| 948 | <p> |
| 949 | path for "src" |
| 950 | </p> |
| 951 | </li> |
| 952 | <li> |
| 953 | <p> |
| 954 | a tab or a NUL when <em>-z</em> option is used; only exists for C or R. |
| 955 | </p> |
| 956 | </li> |
| 957 | <li> |
| 958 | <p> |
| 959 | path for "dst"; only exists for C or R. |
| 960 | </p> |
| 961 | </li> |
| 962 | <li> |
| 963 | <p> |
| 964 | an LF or a NUL when <em>-z</em> option is used, to terminate the record. |
| 965 | </p> |
| 966 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 967 | </ol></div> |
| 968 | <div class="para"><p><sha1> is shown as all 0's if a file is new on the filesystem |
| 969 | and it is out of sync with the index.</p></div> |
| 970 | <div class="para"><p>Example:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 971 | <div class="listingblock"> |
| 972 | <div class="content"> |
| 973 | <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre> |
| 974 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 975 | <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] | 976 | 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] | 977 | respectively.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 978 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 979 | <h2 id="_diff_format_for_merges">diff format for merges</h2> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 980 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 981 | <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] | 982 | can take <em>-c</em> or <em>--cc</em> option |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 983 | to generate diff output also for merge commits. The output differs |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 984 | from the format described above in the following way:</p></div> |
| 985 | <div class="olist"><ol> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 986 | <li> |
| 987 | <p> |
| 988 | there is a colon for each parent |
| 989 | </p> |
| 990 | </li> |
| 991 | <li> |
| 992 | <p> |
| 993 | there are more "src" modes and "src" sha1 |
| 994 | </p> |
| 995 | </li> |
| 996 | <li> |
| 997 | <p> |
| 998 | status is concatenated status characters for each parent |
| 999 | </p> |
| 1000 | </li> |
| 1001 | <li> |
| 1002 | <p> |
| 1003 | no optional "score" number |
| 1004 | </p> |
| 1005 | </li> |
| 1006 | <li> |
| 1007 | <p> |
| 1008 | single path, only for "dst" |
| 1009 | </p> |
| 1010 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1011 | </ol></div> |
| 1012 | <div class="para"><p>Example:</p></div> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1013 | <div class="listingblock"> |
| 1014 | <div class="content"> |
| 1015 | <pre><tt>::100644 100644 100644 fabadb8... cc95eb0... 4866510... MM describe.c</tt></pre> |
| 1016 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1017 | <div class="para"><p>Note that <em>combined diff</em> lists only files which were modified from |
| 1018 | all parents.</p></div> |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 1019 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1020 | <h2 id="_generating_patches_with_p">Generating patches with -p</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1021 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1022 | <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] | 1023 | with a <em>-p</em> option, "git diff" without the <em>--raw</em> option, or |
| 1024 | "git log" with the "-p" option, they |
Junio C Hamano | 7ae0ab2 | 2007-11-03 02:46:46 | [diff] [blame] | 1025 | do not produce the output described above; instead they produce a |
| 1026 | patch file. You can customize the creation of such patches via the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1027 | GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables.</p></div> |
| 1028 | <div class="para"><p>What the -p option produces is slightly different from the traditional |
| 1029 | diff format.</p></div> |
| 1030 | <div class="olist"><ol> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1031 | <li> |
| 1032 | <p> |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 1033 | It is preceded with a "git diff" header, that looks like |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1034 | this: |
| 1035 | </p> |
| 1036 | <div class="literalblock"> |
| 1037 | <div class="content"> |
| 1038 | <pre><tt>diff --git a/file1 b/file2</tt></pre> |
| 1039 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1040 | <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] | 1041 | involved. Especially, even for a creation or a deletion, |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1042 | <tt>/dev/null</tt> is <em>not</em> used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p></div> |
| 1043 | <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] | 1044 | 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] | 1045 | the file that rename/copy produces, respectively.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1046 | </li> |
| 1047 | <li> |
| 1048 | <p> |
| 1049 | It is followed by one or more extended header lines: |
| 1050 | </p> |
| 1051 | <div class="literalblock"> |
| 1052 | <div class="content"> |
| 1053 | <pre><tt>old mode <mode> |
| 1054 | new mode <mode> |
| 1055 | deleted file mode <mode> |
| 1056 | new file mode <mode> |
| 1057 | copy from <path> |
| 1058 | copy to <path> |
| 1059 | rename from <path> |
| 1060 | rename to <path> |
| 1061 | similarity index <number> |
| 1062 | dissimilarity index <number> |
| 1063 | index <hash>..<hash> <mode></tt></pre> |
| 1064 | </div></div> |
| 1065 | </li> |
| 1066 | <li> |
| 1067 | <p> |
Junio C Hamano | a053d54 | 2006-10-27 09:29:13 | [diff] [blame] | 1068 | TAB, LF, double quote and backslash characters in pathnames |
| 1069 | are represented as <tt>\t</tt>, <tt>\n</tt>, <tt>\"</tt> and <tt>\\</tt>, respectively. |
| 1070 | If there is need for such substitution then the whole |
| 1071 | pathname is put in double quotes. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1072 | </p> |
| 1073 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1074 | </ol></div> |
| 1075 | <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] | 1076 | the dissimilarity index is the percentage of changed lines. It |
| 1077 | is a rounded down integer, followed by a percent sign. The |
| 1078 | similarity index value of 100% is thus reserved for two equal |
| 1079 | files, while 100% dissimilarity means that no line from the old |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1080 | file made it into the new one.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1081 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1082 | <h2 id="_combined_diff_format">combined diff format</h2> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1083 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1084 | <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] | 1085 | <em>--cc</em> option to produce <em>combined diff</em>. For showing a merge commit |
| 1086 | with "git log -p", this is the default format. |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1087 | A <em>combined diff</em> format looks like this:</p></div> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1088 | <div class="listingblock"> |
| 1089 | <div class="content"> |
| 1090 | <pre><tt>diff --combined describe.c |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1091 | index fabadb8,cc95eb0..4866510 |
| 1092 | --- a/describe.c |
| 1093 | +++ b/describe.c |
| 1094 | @@@ -98,20 -98,12 +98,20 @@@ |
| 1095 | return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1096 | } |
| 1097 | |
| 1098 | - static void describe(char *arg) |
| 1099 | -static void describe(struct commit *cmit, int last_one) |
| 1100 | ++static void describe(char *arg, int last_one) |
| 1101 | { |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1102 | + unsigned char sha1[20]; |
| 1103 | + struct commit *cmit; |
| 1104 | struct commit_list *list; |
| 1105 | static int initialized = 0; |
| 1106 | struct commit_name *n; |
| 1107 | |
| 1108 | + if (get_sha1(arg, sha1) < 0) |
| 1109 | + usage(describe_usage); |
| 1110 | + cmit = lookup_commit_reference(sha1); |
| 1111 | + if (!cmit) |
| 1112 | + usage(describe_usage); |
| 1113 | + |
| 1114 | if (!initialized) { |
| 1115 | initialized = 1; |
| 1116 | for_each_ref(get_name);</tt></pre> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1117 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1118 | <div class="olist"><ol> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1119 | <li> |
| 1120 | <p> |
| 1121 | It is preceded with a "git diff" header, that looks like |
| 1122 | this (when <em>-c</em> option is used): |
| 1123 | </p> |
| 1124 | <div class="literalblock"> |
| 1125 | <div class="content"> |
| 1126 | <pre><tt>diff --combined file</tt></pre> |
| 1127 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1128 | <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] | 1129 | <div class="literalblock"> |
| 1130 | <div class="content"> |
| 1131 | <pre><tt>diff --c file</tt></pre> |
| 1132 | </div></div> |
| 1133 | </li> |
| 1134 | <li> |
| 1135 | <p> |
| 1136 | It is followed by one or more extended header lines |
| 1137 | (this example shows a merge with two parents): |
| 1138 | </p> |
| 1139 | <div class="literalblock"> |
| 1140 | <div class="content"> |
| 1141 | <pre><tt>index <hash>,<hash>..<hash> |
| 1142 | mode <mode>,<mode>..<mode> |
| 1143 | new file mode <mode> |
| 1144 | deleted file mode <mode>,<mode></tt></pre> |
| 1145 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1146 | <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] | 1147 | the <mode> is different from the rest. Extended headers with |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1148 | information about detected contents movement (renames and |
| 1149 | copying detection) are designed to work with diff of two |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1150 | <tree-ish> and are not used by combined diff format.</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1151 | </li> |
| 1152 | <li> |
| 1153 | <p> |
| 1154 | It is followed by two-line from-file/to-file header |
| 1155 | </p> |
| 1156 | <div class="literalblock"> |
| 1157 | <div class="content"> |
| 1158 | <pre><tt>--- a/file |
| 1159 | +++ b/file</tt></pre> |
| 1160 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1161 | <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] | 1162 | format, <tt>/dev/null</tt> is used to signal created or deleted |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1163 | files.</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1164 | </li> |
| 1165 | <li> |
| 1166 | <p> |
| 1167 | Chunk header format is modified to prevent people from |
| 1168 | accidentally feeding it to <tt>patch -p1</tt>. Combined diff format |
| 1169 | was created for review of merge commit changes, and was not |
| 1170 | meant for apply. The change is similar to the change in the |
| 1171 | extended <em>index</em> header: |
| 1172 | </p> |
| 1173 | <div class="literalblock"> |
| 1174 | <div class="content"> |
| 1175 | <pre><tt>@@@ <from-file-range> <from-file-range> <to-file-range> @@@</tt></pre> |
| 1176 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1177 | <div class="para"><p>There are (number of parents + 1) <tt>@</tt> characters in the chunk |
| 1178 | header for combined diff format.</p></div> |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1179 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1180 | </ol></div> |
| 1181 | <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] | 1182 | files A and B with a single column that has <tt>-</tt> (minus — |
| 1183 | 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] | 1184 | added to B), or <tt>" "</tt> (space — unchanged) prefix, this format |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1185 | compares two or more files file1, file2,… with one file X, and |
| 1186 | shows how X differs from each of fileN. One column for each of |
| 1187 | 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] | 1188 | different from it.</p></div> |
| 1189 | <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] | 1190 | fileN but it does not appear in the result. A <tt>+</tt> character |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1191 | in the column N means that the line appears in the last file, |
Junio C Hamano | 29f1431 | 2006-10-26 08:47:29 | [diff] [blame] | 1192 | 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] | 1193 | added, from the point of view of that parent).</p></div> |
| 1194 | <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] | 1195 | from both files (hence two <tt>-</tt> removals from both file1 and |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1196 | file2, plus <tt><tt>+</tt> to mean one line that was added does not appear |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1197 | in either file1 nor file2). Also two other lines are the same |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1198 | from file1 but do not appear in file2 (hence prefixed with <tt> </tt></tt>).</p></div> |
| 1199 | <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] | 1200 | merge commit with the merge result (i.e. file1..fileN are the |
| 1201 | parents). When shown by <tt>git diff-files -c</tt>, it compares the |
| 1202 | two unresolved merge parents with the working tree file |
| 1203 | (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] | 1204 | "their version").</p></div> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 1205 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1206 | <h2 id="_other_diff_formats">other diff formats</h2> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1207 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1208 | <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] | 1209 | copied files. The <tt>--stat</tt> option adds diffstat(1) graph to the |
| 1210 | output. These options can be combined with other options, such as |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1211 | <tt>-p</tt>, and are meant for human consumption.</p></div> |
| 1212 | <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] | 1213 | formats the pathnames compactly by combining common prefix and suffix of |
| 1214 | 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] | 1215 | <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] | 1216 | <div class="listingblock"> |
| 1217 | <div class="content"> |
| 1218 | <pre><tt>arch/{i386 => x86}/Makefile | 4 +--</tt></pre> |
| 1219 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1220 | <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] | 1221 | for easier machine consumption. An entry in <tt>--numstat</tt> output looks |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1222 | like this:</p></div> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1223 | <div class="listingblock"> |
| 1224 | <div class="content"> |
| 1225 | <pre><tt>1 2 README |
| 1226 | 3 1 arch/{i386 => x86}/Makefile</tt></pre> |
| 1227 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1228 | <div class="para"><p>That is, from left to right:</p></div> |
| 1229 | <div class="olist"><ol> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1230 | <li> |
| 1231 | <p> |
| 1232 | the number of added lines; |
| 1233 | </p> |
| 1234 | </li> |
| 1235 | <li> |
| 1236 | <p> |
| 1237 | a tab; |
| 1238 | </p> |
| 1239 | </li> |
| 1240 | <li> |
| 1241 | <p> |
| 1242 | the number of deleted lines; |
| 1243 | </p> |
| 1244 | </li> |
| 1245 | <li> |
| 1246 | <p> |
| 1247 | a tab; |
| 1248 | </p> |
| 1249 | </li> |
| 1250 | <li> |
| 1251 | <p> |
| 1252 | pathname (possibly with rename/copy information); |
| 1253 | </p> |
| 1254 | </li> |
| 1255 | <li> |
| 1256 | <p> |
| 1257 | a newline. |
| 1258 | </p> |
| 1259 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1260 | </ol></div> |
| 1261 | <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] | 1262 | <div class="listingblock"> |
| 1263 | <div class="content"> |
| 1264 | <pre><tt>1 2 README NUL |
| 1265 | 3 1 NUL arch/i386/Makefile NUL arch/x86/Makefile NUL</tt></pre> |
| 1266 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1267 | <div class="para"><p>That is:</p></div> |
| 1268 | <div class="olist"><ol> |
Junio C Hamano | 3a70234 | 2007-12-12 21:34:02 | [diff] [blame] | 1269 | <li> |
| 1270 | <p> |
| 1271 | the number of added lines; |
| 1272 | </p> |
| 1273 | </li> |
| 1274 | <li> |
| 1275 | <p> |
| 1276 | a tab; |
| 1277 | </p> |
| 1278 | </li> |
| 1279 | <li> |
| 1280 | <p> |
| 1281 | the number of deleted lines; |
| 1282 | </p> |
| 1283 | </li> |
| 1284 | <li> |
| 1285 | <p> |
| 1286 | a tab; |
| 1287 | </p> |
| 1288 | </li> |
| 1289 | <li> |
| 1290 | <p> |
| 1291 | a NUL (only exists if renamed/copied); |
| 1292 | </p> |
| 1293 | </li> |
| 1294 | <li> |
| 1295 | <p> |
| 1296 | pathname in preimage; |
| 1297 | </p> |
| 1298 | </li> |
| 1299 | <li> |
| 1300 | <p> |
| 1301 | a NUL (only exists if renamed/copied); |
| 1302 | </p> |
| 1303 | </li> |
| 1304 | <li> |
| 1305 | <p> |
| 1306 | pathname in postimage (only exists if renamed/copied); |
| 1307 | </p> |
| 1308 | </li> |
| 1309 | <li> |
| 1310 | <p> |
| 1311 | a NUL. |
| 1312 | </p> |
| 1313 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1314 | </ol></div> |
| 1315 | <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] | 1316 | scripts that read the output to tell if the current record being read is |
| 1317 | a single-path record or a rename/copy record without reading ahead. |
| 1318 | 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] | 1319 | 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] | 1320 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1321 | <h2 id="_operating_modes">Operating Modes</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1322 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1323 | <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] | 1324 | (using the <em>--cached</em> flag) or ask the diff logic to show any files |
| 1325 | that don't match the stat state as being "tentatively changed". Both |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1326 | of these operations are very useful indeed.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1327 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1328 | <h2 id="_cached_mode">Cached Mode</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1329 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1330 | <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] | 1331 | <div class="literalblock"> |
| 1332 | <div class="content"> |
| 1333 | <pre><tt>show me the differences between HEAD and the current index |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1334 | contents (the ones I'd write using 'git-write-tree')</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1335 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1336 | <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] | 1337 | 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] | 1338 | <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] | 1339 | 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] | 1340 | <div class="literalblock"> |
| 1341 | <div class="content"> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1342 | <pre><tt>git diff-index --cached HEAD</tt></pre> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1343 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1344 | <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] | 1345 | done an <tt>update-index</tt> to make that effective in the index file. |
| 1346 | <tt>git diff-files</tt> wouldn't show anything at all, since the index file |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1347 | 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] | 1348 | <div class="literalblock"> |
| 1349 | <div class="content"> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1350 | <pre><tt>torvalds@ppc970:~/git> git diff-index --cached HEAD |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1351 | -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c |
| 1352 | +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre> |
| 1353 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1354 | <div class="para"><p>You can see easily that the above is a rename.</p></div> |
| 1355 | <div class="para"><p>In fact, <tt>git diff-index --cached</tt> <strong>should</strong> always be entirely equivalent to |
| 1356 | actually doing a <em>git-write-tree</em> and comparing that. Except this one is much |
| 1357 | nicer for the case where you just want to check where you are.</p></div> |
| 1358 | <div class="para"><p>So doing a <em>git-diff-index --cached</em> is basically very useful when you are |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1359 | asking yourself "what have I already marked for being committed, and |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1360 | what's the difference to a previous tree".</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1361 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1362 | <h2 id="_non_cached_mode">Non-cached Mode</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1363 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1364 | <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] | 1365 | the more useful of the two in that what it does can't be emulated with |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1366 | a <em>git-write-tree</em> + <em>git-diff-tree</em>. Thus that's the default mode. |
| 1367 | The non-cached version asks the question:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1368 | <div class="literalblock"> |
| 1369 | <div class="content"> |
| 1370 | <pre><tt>show me the differences between HEAD and the currently checked out |
| 1371 | tree - index contents _and_ files that aren't up-to-date</tt></pre> |
| 1372 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1373 | <div class="para"><p>which is obviously a very useful question too, since that tells you what |
| 1374 | you <strong>could</strong> commit. Again, the output matches the <em>git-diff-tree -r</em> |
| 1375 | output to a tee, but with a twist.</p></div> |
| 1376 | <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] | 1377 | a backing store thing for it, and we use the magic "all-zero" sha1 to |
| 1378 | show that. So let's say that you have edited <tt>kernel/sched.c</tt>, but |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1379 | have not actually done a <em>git-update-index</em> on it yet - there is no |
| 1380 | "object" associated with the new state, and you get:</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1381 | <div class="literalblock"> |
| 1382 | <div class="content"> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 1383 | <pre><tt>torvalds@ppc970:~/v2.6/linux> git diff-index HEAD |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1384 | *100644->100664 blob 7476bb......->000000...... kernel/sched.c</tt></pre> |
| 1385 | </div></div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1386 | <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] | 1387 | not up-to-date and may contain new stuff. The all-zero sha1 means that to |
| 1388 | 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] | 1389 | directly rather than do an object-to-object diff.</p></div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1390 | <div class="admonitionblock"> |
| 1391 | <table><tr> |
| 1392 | <td class="icon"> |
| 1393 | <div class="title">Note</div> |
| 1394 | </td> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1395 | <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] | 1396 | actually look at the contents of the file at all. So maybe |
| 1397 | <tt>kernel/sched.c</tt> hasn't actually changed, and it's just that you |
| 1398 | touched it. In either case, it's a note that you need to |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1399 | <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] | 1400 | </tr></table> |
| 1401 | </div> |
| 1402 | <div class="admonitionblock"> |
| 1403 | <table><tr> |
| 1404 | <td class="icon"> |
| 1405 | <div class="title">Note</div> |
| 1406 | </td> |
| 1407 | <td class="content">You can have a mixture of files show up as "has been updated" |
| 1408 | and "is still dirty in the working directory" together. You can always |
| 1409 | tell which file is in which state, since the "has been updated" ones |
| 1410 | show a valid sha1, and the "not in sync with the index" ones will |
| 1411 | always have the special all-zero sha1.</td> |
| 1412 | </tr></table> |
| 1413 | </div> |
| 1414 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1415 | <h2 id="_author">Author</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1416 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1417 | <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] | 1418 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1419 | <h2 id="_documentation">Documentation</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1420 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1421 | <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] | 1422 | </div> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1423 | <h2 id="_git">GIT</h2> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1424 | <div class="sectionbody"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1425 | <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] | 1426 | </div> |
| 1427 | <div id="footer"> |
| 1428 | <div id="footer-text"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1429 | Last updated 2008-07-06 05:16:43 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1430 | </div> |
| 1431 | </div> |
| 1432 | </body> |
| 1433 | </html> |