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 | 6ec31b9 | 2006-02-10 05:52:01 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 7.0.2" /> |
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 | |
| 19 | a { color: blue; } |
| 20 | a:visited { color: fuchsia; } |
| 21 | |
| 22 | em { |
| 23 | font-style: italic; |
| 24 | } |
| 25 | |
| 26 | strong { |
| 27 | font-weight: bold; |
| 28 | } |
| 29 | |
| 30 | tt { |
| 31 | color: navy; |
| 32 | } |
| 33 | |
| 34 | h1, h2, h3, h4, h5, h6 { |
| 35 | color: #527bbd; |
| 36 | font-family: sans-serif; |
| 37 | margin-top: 1.2em; |
| 38 | margin-bottom: 0.5em; |
| 39 | line-height: 1.3; |
| 40 | } |
| 41 | |
| 42 | h1 { |
| 43 | border-bottom: 2px solid silver; |
| 44 | } |
| 45 | h2 { |
| 46 | border-bottom: 2px solid silver; |
| 47 | padding-top: 0.5em; |
| 48 | } |
| 49 | |
| 50 | div.sectionbody { |
| 51 | font-family: serif; |
| 52 | margin-left: 0; |
| 53 | } |
| 54 | |
| 55 | hr { |
| 56 | border: 1px solid silver; |
| 57 | } |
| 58 | |
| 59 | p { |
| 60 | margin-top: 0.5em; |
| 61 | margin-bottom: 0.5em; |
| 62 | } |
| 63 | |
| 64 | pre { |
| 65 | padding: 0; |
| 66 | margin: 0; |
| 67 | } |
| 68 | |
| 69 | span#author { |
| 70 | color: #527bbd; |
| 71 | font-family: sans-serif; |
| 72 | font-weight: bold; |
| 73 | font-size: 1.2em; |
| 74 | } |
| 75 | span#email { |
| 76 | } |
| 77 | span#revision { |
| 78 | font-family: sans-serif; |
| 79 | } |
| 80 | |
| 81 | div#footer { |
| 82 | font-family: sans-serif; |
| 83 | font-size: small; |
| 84 | border-top: 2px solid silver; |
| 85 | padding-top: 0.5em; |
| 86 | margin-top: 4.0em; |
| 87 | } |
| 88 | div#footer-text { |
| 89 | float: left; |
| 90 | padding-bottom: 0.5em; |
| 91 | } |
| 92 | div#footer-badges { |
| 93 | float: right; |
| 94 | padding-bottom: 0.5em; |
| 95 | } |
| 96 | |
| 97 | div#preamble, |
| 98 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, |
| 99 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 100 | div.admonitionblock { |
| 101 | margin-right: 10%; |
| 102 | margin-top: 1.5em; |
| 103 | margin-bottom: 1.5em; |
| 104 | } |
| 105 | div.admonitionblock { |
| 106 | margin-top: 2.5em; |
| 107 | margin-bottom: 2.5em; |
| 108 | } |
| 109 | |
| 110 | div.content { /* Block element content. */ |
| 111 | padding: 0; |
| 112 | } |
| 113 | |
| 114 | /* Block element titles. */ |
| 115 | div.title, caption.title { |
| 116 | font-family: sans-serif; |
| 117 | font-weight: bold; |
| 118 | text-align: left; |
| 119 | margin-top: 1.0em; |
| 120 | margin-bottom: 0.5em; |
| 121 | } |
| 122 | div.title + * { |
| 123 | margin-top: 0; |
| 124 | } |
| 125 | |
| 126 | td div.title:first-child { |
| 127 | margin-top: 0.0em; |
| 128 | } |
| 129 | div.content div.title:first-child { |
| 130 | margin-top: 0.0em; |
| 131 | } |
| 132 | div.content + div.title { |
| 133 | margin-top: 0.0em; |
| 134 | } |
| 135 | |
| 136 | div.sidebarblock > div.content { |
| 137 | background: #ffffee; |
| 138 | border: 1px solid silver; |
| 139 | padding: 0.5em; |
| 140 | } |
| 141 | |
| 142 | div.listingblock > div.content { |
| 143 | border: 1px solid silver; |
| 144 | background: #f4f4f4; |
| 145 | padding: 0.5em; |
| 146 | } |
| 147 | |
| 148 | div.quoteblock > div.content { |
| 149 | padding-left: 2.0em; |
| 150 | } |
| 151 | div.quoteblock .attribution { |
| 152 | text-align: right; |
| 153 | } |
| 154 | |
| 155 | div.admonitionblock .icon { |
| 156 | vertical-align: top; |
| 157 | font-size: 1.1em; |
| 158 | font-weight: bold; |
| 159 | text-decoration: underline; |
| 160 | color: #527bbd; |
| 161 | padding-right: 0.5em; |
| 162 | } |
| 163 | div.admonitionblock td.content { |
| 164 | padding-left: 0.5em; |
| 165 | border-left: 2px solid silver; |
| 166 | } |
| 167 | |
| 168 | div.exampleblock > div.content { |
| 169 | border-left: 2px solid silver; |
| 170 | padding: 0.5em; |
| 171 | } |
| 172 | |
| 173 | div.verseblock div.content { |
| 174 | white-space: pre; |
| 175 | } |
| 176 | |
| 177 | div.imageblock div.content { padding-left: 0; } |
| 178 | div.imageblock img { border: 1px solid silver; } |
| 179 | span.image img { border-style: none; } |
| 180 | |
| 181 | dl { |
| 182 | margin-top: 0.8em; |
| 183 | margin-bottom: 0.8em; |
| 184 | } |
| 185 | dt { |
| 186 | margin-top: 0.5em; |
| 187 | margin-bottom: 0; |
| 188 | font-style: italic; |
| 189 | } |
| 190 | dd > *:first-child { |
| 191 | margin-top: 0; |
| 192 | } |
| 193 | |
| 194 | ul, ol { |
| 195 | list-style-position: outside; |
| 196 | } |
| 197 | ol.olist2 { |
| 198 | list-style-type: lower-alpha; |
| 199 | } |
| 200 | |
| 201 | div.tableblock > table { |
| 202 | border-color: #527bbd; |
| 203 | border-width: 3px; |
| 204 | } |
| 205 | thead { |
| 206 | font-family: sans-serif; |
| 207 | font-weight: bold; |
| 208 | } |
| 209 | tfoot { |
| 210 | font-weight: bold; |
| 211 | } |
| 212 | |
| 213 | div.hlist { |
| 214 | margin-top: 0.8em; |
| 215 | margin-bottom: 0.8em; |
| 216 | } |
| 217 | td.hlist1 { |
| 218 | vertical-align: top; |
| 219 | font-style: italic; |
| 220 | padding-right: 0.8em; |
| 221 | } |
| 222 | td.hlist2 { |
| 223 | vertical-align: top; |
| 224 | } |
| 225 | |
| 226 | @media print { |
| 227 | div#footer-badges { display: none; } |
| 228 | } |
| 229 | include::./stylesheets/xhtml11-manpage.css[] |
| 230 | /* Workarounds for IE6's broken and incomplete CSS2. */ |
| 231 | |
| 232 | div.sidebar-content { |
| 233 | background: #ffffee; |
| 234 | border: 1px solid silver; |
| 235 | padding: 0.5em; |
| 236 | } |
| 237 | div.sidebar-title, div.image-title { |
| 238 | font-family: sans-serif; |
| 239 | font-weight: bold; |
| 240 | margin-top: 0.0em; |
| 241 | margin-bottom: 0.5em; |
| 242 | } |
| 243 | |
| 244 | div.listingblock div.content { |
| 245 | border: 1px solid silver; |
| 246 | background: #f4f4f4; |
| 247 | padding: 0.5em; |
| 248 | } |
| 249 | |
| 250 | div.quoteblock-content { |
| 251 | padding-left: 2.0em; |
| 252 | } |
| 253 | |
| 254 | div.exampleblock-content { |
| 255 | border-left: 2px solid silver; |
| 256 | padding-left: 0.5em; |
| 257 | } |
| 258 | </style> |
| 259 | <title>git-diff-index(1)</title> |
| 260 | </head> |
| 261 | <body> |
| 262 | <div id="header"> |
| 263 | <h1> |
| 264 | git-diff-index(1) Manual Page |
| 265 | </h1> |
| 266 | <h2>NAME</h2> |
| 267 | <div class="sectionbody"> |
| 268 | <p>git-diff-index - |
| 269 | Compares content and mode of blobs between the index and repository |
| 270 | </p> |
| 271 | </div> |
| 272 | </div> |
| 273 | <h2>SYNOPSIS</h2> |
| 274 | <div class="sectionbody"> |
| 275 | <p><em>git-diff-index</em> [-m] [--cached] [<common diff options>] <tree-ish> [<path>…]</p> |
| 276 | </div> |
| 277 | <h2>DESCRIPTION</h2> |
| 278 | <div class="sectionbody"> |
| 279 | <p>Compares the content and mode of the blobs found via a tree |
| 280 | object with the content of the current index and, optionally |
| 281 | ignoring the stat state of the file on disk. When paths are |
| 282 | specified, compares only those named paths. Otherwise all |
| 283 | entries in the index are compared.</p> |
| 284 | </div> |
| 285 | <h2>OPTIONS</h2> |
| 286 | <div class="sectionbody"> |
| 287 | <dl> |
| 288 | <dt> |
| 289 | -p |
| 290 | </dt> |
| 291 | <dd> |
| 292 | <p> |
| 293 | Generate patch (see section on generating patches) |
| 294 | </p> |
| 295 | </dd> |
| 296 | <dt> |
| 297 | -u |
| 298 | </dt> |
| 299 | <dd> |
| 300 | <p> |
| 301 | Synonym for "-p". |
| 302 | </p> |
| 303 | </dd> |
| 304 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 305 | --raw |
| 306 | </dt> |
| 307 | <dd> |
| 308 | <p> |
| 309 | Generate the raw format. |
| 310 | </p> |
| 311 | </dd> |
| 312 | <dt> |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 313 | --patch-with-raw |
| 314 | </dt> |
| 315 | <dd> |
| 316 | <p> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 317 | Synonym for "-p --raw". |
Junio C Hamano | 54559c8 | 2006-04-13 07:45:12 | [diff] [blame] | 318 | </p> |
| 319 | </dd> |
| 320 | <dt> |
Junio C Hamano | ba7c8d8 | 2006-04-15 06:17:42 | [diff] [blame] | 321 | --stat |
| 322 | </dt> |
| 323 | <dd> |
| 324 | <p> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 325 | Generate a diffstat. |
Junio C Hamano | ba7c8d8 | 2006-04-15 06:17:42 | [diff] [blame] | 326 | </p> |
| 327 | </dd> |
| 328 | <dt> |
Junio C Hamano | 6959c6c | 2006-05-17 10:34:11 | [diff] [blame] | 329 | --summary |
| 330 | </dt> |
| 331 | <dd> |
| 332 | <p> |
| 333 | Output a condensed summary of extended header information |
| 334 | such as creations, renames and mode changes. |
| 335 | </p> |
| 336 | </dd> |
| 337 | <dt> |
Junio C Hamano | d1308c9 | 2006-04-16 11:01:09 | [diff] [blame] | 338 | --patch-with-stat |
| 339 | </dt> |
| 340 | <dd> |
| 341 | <p> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 342 | Synonym for "-p --stat". |
Junio C Hamano | d1308c9 | 2006-04-16 11:01:09 | [diff] [blame] | 343 | </p> |
| 344 | </dd> |
| 345 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 346 | -z |
| 347 | </dt> |
| 348 | <dd> |
| 349 | <p> |
| 350 | \0 line termination on output |
| 351 | </p> |
| 352 | </dd> |
| 353 | <dt> |
| 354 | --name-only |
| 355 | </dt> |
| 356 | <dd> |
| 357 | <p> |
| 358 | Show only names of changed files. |
| 359 | </p> |
| 360 | </dd> |
| 361 | <dt> |
| 362 | --name-status |
| 363 | </dt> |
| 364 | <dd> |
| 365 | <p> |
| 366 | Show only names and status of changed files. |
| 367 | </p> |
| 368 | </dd> |
| 369 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 370 | --color |
| 371 | </dt> |
| 372 | <dd> |
| 373 | <p> |
| 374 | Show colored diff. |
| 375 | </p> |
| 376 | </dd> |
| 377 | <dt> |
| 378 | --no-color |
| 379 | </dt> |
| 380 | <dd> |
| 381 | <p> |
| 382 | Turn off colored diff, even when the configuration file |
| 383 | gives the default to color output. |
| 384 | </p> |
| 385 | </dd> |
| 386 | <dt> |
| 387 | --no-renames |
| 388 | </dt> |
| 389 | <dd> |
| 390 | <p> |
| 391 | Turn off rename detection, even when the configuration |
| 392 | file gives the default to do so. |
| 393 | </p> |
| 394 | </dd> |
| 395 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 396 | --full-index |
| 397 | </dt> |
| 398 | <dd> |
| 399 | <p> |
| 400 | Instead of the first handful characters, show full |
| 401 | object name of pre- and post-image blob on the "index" |
| 402 | line when generating a patch format output. |
| 403 | </p> |
| 404 | </dd> |
| 405 | <dt> |
Junio C Hamano | 9ae1a06 | 2006-07-10 08:12:34 | [diff] [blame] | 406 | --binary |
| 407 | </dt> |
| 408 | <dd> |
| 409 | <p> |
| 410 | In addition to --full-index, output "binary diff" that |
| 411 | can be applied with "git apply". |
| 412 | </p> |
| 413 | </dd> |
| 414 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 415 | --abbrev[=<n>] |
| 416 | </dt> |
| 417 | <dd> |
| 418 | <p> |
| 419 | Instead of showing the full 40-byte hexadecimal object |
| 420 | name in diff-raw format output and diff-tree header |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 421 | lines, show only handful hexdigits prefix. This is |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 422 | independent of --full-index option above, which controls |
| 423 | the diff-patch output format. Non default number of |
| 424 | digits can be specified with --abbrev=<n>. |
| 425 | </p> |
| 426 | </dd> |
| 427 | <dt> |
| 428 | -B |
| 429 | </dt> |
| 430 | <dd> |
| 431 | <p> |
| 432 | Break complete rewrite changes into pairs of delete and create. |
| 433 | </p> |
| 434 | </dd> |
| 435 | <dt> |
| 436 | -M |
| 437 | </dt> |
| 438 | <dd> |
| 439 | <p> |
| 440 | Detect renames. |
| 441 | </p> |
| 442 | </dd> |
| 443 | <dt> |
| 444 | -C |
| 445 | </dt> |
| 446 | <dd> |
| 447 | <p> |
| 448 | Detect copies as well as renames. |
| 449 | </p> |
| 450 | </dd> |
| 451 | <dt> |
Junio C Hamano | 6ec31b9 | 2006-02-10 05:52:01 | [diff] [blame] | 452 | --diff-filter=[ACDMRTUXB*] |
| 453 | </dt> |
| 454 | <dd> |
| 455 | <p> |
| 456 | Select only files that are Added (<tt>A</tt>), Copied (<tt>C</tt>), |
| 457 | Deleted (<tt>D</tt>), Modified (<tt>M</tt>), Renamed (<tt>R</tt>), have their |
| 458 | type (mode) changed (<tt>T</tt>), are Unmerged (<tt>U</tt>), are |
| 459 | Unknown (<tt>X</tt>), or have had their pairing Broken (<tt>B</tt>). |
| 460 | Any combination of the filter characters may be used. |
| 461 | When <tt>*</tt> (All-or-none) is added to the combination, all |
| 462 | paths are selected if there is any file that matches |
| 463 | other criteria in the comparison; if there is no file |
| 464 | that matches other criteria, nothing is selected. |
| 465 | </p> |
| 466 | </dd> |
| 467 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 468 | --find-copies-harder |
| 469 | </dt> |
| 470 | <dd> |
| 471 | <p> |
| 472 | For performance reasons, by default, -C option finds copies only |
| 473 | if the original file of the copy was modified in the same |
| 474 | changeset. This flag makes the command |
| 475 | inspect unmodified files as candidates for the source of |
| 476 | copy. This is a very expensive operation for large |
| 477 | projects, so use it with caution. |
| 478 | </p> |
| 479 | </dd> |
| 480 | <dt> |
| 481 | -l<num> |
| 482 | </dt> |
| 483 | <dd> |
| 484 | <p> |
| 485 | -M and -C options require O(n^2) processing time where n |
| 486 | is the number of potential rename/copy targets. This |
| 487 | option prevents rename/copy detection from running if |
| 488 | the number of rename/copy targets exceeds the specified |
| 489 | number. |
| 490 | </p> |
| 491 | </dd> |
| 492 | <dt> |
| 493 | -S<string> |
| 494 | </dt> |
| 495 | <dd> |
| 496 | <p> |
| 497 | Look for differences that contain the change in <string>. |
| 498 | </p> |
| 499 | </dd> |
| 500 | <dt> |
| 501 | --pickaxe-all |
| 502 | </dt> |
| 503 | <dd> |
| 504 | <p> |
| 505 | When -S finds a change, show all the changes in that |
| 506 | changeset, not just the files that contain the change |
| 507 | in <string>. |
| 508 | </p> |
| 509 | </dd> |
| 510 | <dt> |
Junio C Hamano | bfe9e75 | 2006-04-05 21:43:28 | [diff] [blame] | 511 | --pickaxe-regex |
| 512 | </dt> |
| 513 | <dd> |
| 514 | <p> |
| 515 | Make the <string> not a plain string but an extended POSIX |
| 516 | regex to match. |
| 517 | </p> |
| 518 | </dd> |
| 519 | <dt> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 520 | -O<orderfile> |
| 521 | </dt> |
| 522 | <dd> |
| 523 | <p> |
| 524 | Output the patch in the order specified in the |
| 525 | <orderfile>, which has one shell glob pattern per line. |
| 526 | </p> |
| 527 | </dd> |
| 528 | <dt> |
| 529 | -R |
| 530 | </dt> |
| 531 | <dd> |
| 532 | <p> |
| 533 | Swap two inputs; that is, show differences from index or |
| 534 | on-disk file to tree contents. |
| 535 | </p> |
| 536 | </dd> |
Junio C Hamano | c26f548 | 2006-07-09 09:38:14 | [diff] [blame] | 537 | <dt> |
| 538 | --text |
| 539 | </dt> |
| 540 | <dd> |
| 541 | <p> |
| 542 | Treat all files as text. |
| 543 | </p> |
| 544 | </dd> |
| 545 | <dt> |
| 546 | -a |
| 547 | </dt> |
| 548 | <dd> |
| 549 | <p> |
| 550 | Shorthand for "--text". |
| 551 | </p> |
| 552 | </dd> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 553 | </dl> |
| 554 | <p>For more detailed explanation on these common options, see also |
| 555 | <a href="diffcore.html">diffcore documentation</a>.</p> |
| 556 | <dl> |
| 557 | <dt> |
| 558 | <tree-ish> |
| 559 | </dt> |
| 560 | <dd> |
| 561 | <p> |
| 562 | The id of a tree object to diff against. |
| 563 | </p> |
| 564 | </dd> |
| 565 | <dt> |
| 566 | --cached |
| 567 | </dt> |
| 568 | <dd> |
| 569 | <p> |
| 570 | do not consider the on-disk file at all |
| 571 | </p> |
| 572 | </dd> |
| 573 | <dt> |
| 574 | -m |
| 575 | </dt> |
| 576 | <dd> |
| 577 | <p> |
| 578 | By default, files recorded in the index but not checked |
| 579 | out are reported as deleted. This flag makes |
| 580 | "git-diff-index" say that all non-checked-out files are up |
| 581 | to date. |
| 582 | </p> |
| 583 | </dd> |
| 584 | </dl> |
| 585 | </div> |
| 586 | <h2>Output format</h2> |
| 587 | <div class="sectionbody"> |
| 588 | <p>The output format from "git-diff-index", "git-diff-tree" and |
| 589 | "git-diff-files" are very similar.</p> |
| 590 | <p>These commands all compare two sets of things; what is |
| 591 | compared differs:</p> |
| 592 | <dl> |
| 593 | <dt> |
| 594 | git-diff-index <tree-ish> |
| 595 | </dt> |
| 596 | <dd> |
| 597 | <p> |
| 598 | compares the <tree-ish> and the files on the filesystem. |
| 599 | </p> |
| 600 | </dd> |
| 601 | <dt> |
| 602 | git-diff-index --cached <tree-ish> |
| 603 | </dt> |
| 604 | <dd> |
| 605 | <p> |
| 606 | compares the <tree-ish> and the index. |
| 607 | </p> |
| 608 | </dd> |
| 609 | <dt> |
| 610 | git-diff-tree [-r] <tree-ish-1> <tree-ish-2> [<pattern>…] |
| 611 | </dt> |
| 612 | <dd> |
| 613 | <p> |
| 614 | compares the trees named by the two arguments. |
| 615 | </p> |
| 616 | </dd> |
| 617 | <dt> |
| 618 | git-diff-files [<pattern>…] |
| 619 | </dt> |
| 620 | <dd> |
| 621 | <p> |
| 622 | compares the index and the files on the filesystem. |
| 623 | </p> |
| 624 | </dd> |
| 625 | </dl> |
| 626 | <p>An output line is formatted this way:</p> |
| 627 | <div class="listingblock"> |
| 628 | <div class="content"> |
| 629 | <pre><tt>in-place edit :100644 100644 bcd1234... 0123456... M file0 |
| 630 | copy-edit :100644 100644 abcd123... 1234567... C68 file1 file2 |
| 631 | rename-edit :100644 100644 abcd123... 1234567... R86 file1 file3 |
| 632 | create :000000 100644 0000000... 1234567... A file4 |
| 633 | delete :100644 000000 1234567... 0000000... D file5 |
| 634 | unmerged :000000 000000 0000000... 0000000... U file6</tt></pre> |
| 635 | </div></div> |
| 636 | <p>That is, from the left to the right:</p> |
| 637 | <ol> |
| 638 | <li> |
| 639 | <p> |
| 640 | a colon. |
| 641 | </p> |
| 642 | </li> |
| 643 | <li> |
| 644 | <p> |
| 645 | mode for "src"; 000000 if creation or unmerged. |
| 646 | </p> |
| 647 | </li> |
| 648 | <li> |
| 649 | <p> |
| 650 | a space. |
| 651 | </p> |
| 652 | </li> |
| 653 | <li> |
| 654 | <p> |
| 655 | mode for "dst"; 000000 if deletion or unmerged. |
| 656 | </p> |
| 657 | </li> |
| 658 | <li> |
| 659 | <p> |
| 660 | a space. |
| 661 | </p> |
| 662 | </li> |
| 663 | <li> |
| 664 | <p> |
| 665 | sha1 for "src"; 0{40} if creation or unmerged. |
| 666 | </p> |
| 667 | </li> |
| 668 | <li> |
| 669 | <p> |
| 670 | a space. |
| 671 | </p> |
| 672 | </li> |
| 673 | <li> |
| 674 | <p> |
| 675 | sha1 for "dst"; 0{40} if creation, unmerged or "look at work tree". |
| 676 | </p> |
| 677 | </li> |
| 678 | <li> |
| 679 | <p> |
| 680 | a space. |
| 681 | </p> |
| 682 | </li> |
| 683 | <li> |
| 684 | <p> |
| 685 | status, followed by optional "score" number. |
| 686 | </p> |
| 687 | </li> |
| 688 | <li> |
| 689 | <p> |
| 690 | a tab or a NUL when <em>-z</em> option is used. |
| 691 | </p> |
| 692 | </li> |
| 693 | <li> |
| 694 | <p> |
| 695 | path for "src" |
| 696 | </p> |
| 697 | </li> |
| 698 | <li> |
| 699 | <p> |
| 700 | a tab or a NUL when <em>-z</em> option is used; only exists for C or R. |
| 701 | </p> |
| 702 | </li> |
| 703 | <li> |
| 704 | <p> |
| 705 | path for "dst"; only exists for C or R. |
| 706 | </p> |
| 707 | </li> |
| 708 | <li> |
| 709 | <p> |
| 710 | an LF or a NUL when <em>-z</em> option is used, to terminate the record. |
| 711 | </p> |
| 712 | </li> |
| 713 | </ol> |
| 714 | <p><sha1> is shown as all 0's if a file is new on the filesystem |
| 715 | and it is out of sync with the index.</p> |
| 716 | <p>Example:</p> |
| 717 | <div class="listingblock"> |
| 718 | <div class="content"> |
| 719 | <pre><tt>:100644 100644 5be4a4...... 000000...... M file.c</tt></pre> |
| 720 | </div></div> |
| 721 | <p>When <tt>-z</tt> option is not used, TAB, LF, and backslash characters |
| 722 | in pathnames are represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>, |
| 723 | respectively.</p> |
| 724 | </div> |
| 725 | <h2>Generating patches with -p</h2> |
| 726 | <div class="sectionbody"> |
| 727 | <p>When "git-diff-index", "git-diff-tree", or "git-diff-files" are run |
| 728 | with a <em>-p</em> option, they do not produce the output described above; |
| 729 | instead they produce a patch file.</p> |
| 730 | <p>The patch generation can be customized at two levels.</p> |
| 731 | <ol> |
| 732 | <li> |
| 733 | <p> |
| 734 | When the environment variable <em>GIT_EXTERNAL_DIFF</em> is not set, |
| 735 | these commands internally invoke "diff" like this: |
| 736 | </p> |
| 737 | <div class="literalblock"> |
| 738 | <div class="content"> |
| 739 | <pre><tt>diff -L a/<path> -L b/<path> -pu <old> <new></tt></pre> |
| 740 | </div></div> |
| 741 | <p>For added files, <tt>/dev/null</tt> is used for <old>. For removed |
| 742 | files, <tt>/dev/null</tt> is used for <new></p> |
| 743 | <p>The "diff" formatting options can be customized via the |
| 744 | environment variable <em>GIT_DIFF_OPTS</em>. For example, if you |
| 745 | prefer context diff:</p> |
| 746 | <div class="literalblock"> |
| 747 | <div class="content"> |
| 748 | <pre><tt>GIT_DIFF_OPTS=-c git-diff-index -p HEAD</tt></pre> |
| 749 | </div></div> |
| 750 | </li> |
| 751 | <li> |
| 752 | <p> |
| 753 | When the environment variable <em>GIT_EXTERNAL_DIFF</em> is set, the |
| 754 | program named by it is called, instead of the diff invocation |
| 755 | described above. |
| 756 | </p> |
| 757 | <p>For a path that is added, removed, or modified, |
| 758 | <em>GIT_EXTERNAL_DIFF</em> is called with 7 parameters:</p> |
| 759 | <div class="literalblock"> |
| 760 | <div class="content"> |
| 761 | <pre><tt>path old-file old-hex old-mode new-file new-hex new-mode</tt></pre> |
| 762 | </div></div> |
| 763 | <p>where:</p> |
| 764 | <div class="hlist"><table> |
| 765 | <tr> |
| 766 | <td class="hlist1"> |
| 767 | <old|new>-file |
| 768 | </td> |
| 769 | <td class="hlist2"> |
| 770 | are files GIT_EXTERNAL_DIFF can use to read the |
| 771 | contents of <old|new>, |
| 772 | </td> |
| 773 | </tr> |
| 774 | <tr> |
| 775 | <td class="hlist1"> |
| 776 | <old|new>-hex |
| 777 | </td> |
| 778 | <td class="hlist2"> |
| 779 | are the 40-hexdigit SHA1 hashes, |
| 780 | </td> |
| 781 | </tr> |
| 782 | <tr> |
| 783 | <td class="hlist1"> |
| 784 | <old|new>-mode |
| 785 | </td> |
| 786 | <td class="hlist2"> |
| 787 | are the octal representation of the file modes. |
| 788 | </td> |
| 789 | </tr> |
| 790 | </table></div> |
| 791 | <p>The file parameters can point at the user's working file |
| 792 | (e.g. <tt>new-file</tt> in "git-diff-files"), <tt>/dev/null</tt> (e.g. <tt>old-file</tt> |
| 793 | when a new file is added), or a temporary file (e.g. <tt>old-file</tt> in the |
| 794 | index). <em>GIT_EXTERNAL_DIFF</em> should not worry about unlinking the |
| 795 | temporary file --- it is removed when <em>GIT_EXTERNAL_DIFF</em> exits.</p> |
| 796 | </li> |
| 797 | </ol> |
| 798 | <p>For a path that is unmerged, <em>GIT_EXTERNAL_DIFF</em> is called with 1 |
| 799 | parameter, <path>.</p> |
| 800 | </div> |
| 801 | <h2>git specific extension to diff format</h2> |
| 802 | <div class="sectionbody"> |
| 803 | <p>What -p option produces is slightly different from the |
| 804 | traditional diff format.</p> |
| 805 | <ol> |
| 806 | <li> |
| 807 | <p> |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 808 | It is preceded with a "git diff" header, that looks like |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 809 | this: |
| 810 | </p> |
| 811 | <div class="literalblock"> |
| 812 | <div class="content"> |
| 813 | <pre><tt>diff --git a/file1 b/file2</tt></pre> |
| 814 | </div></div> |
| 815 | <p>The <tt>a/</tt> and <tt>b/</tt> filenames are the same unless rename/copy is |
| 816 | involved. Especially, even for a creation or a deletion, |
| 817 | <tt>/dev/null</tt> is _not_ used in place of <tt>a/</tt> or <tt>b/</tt> filenames.</p> |
| 818 | <p>When rename/copy is involved, <tt>file1</tt> and <tt>file2</tt> show the |
| 819 | name of the source file of the rename/copy and the name of |
| 820 | the file that rename/copy produces, respectively.</p> |
| 821 | </li> |
| 822 | <li> |
| 823 | <p> |
| 824 | It is followed by one or more extended header lines: |
| 825 | </p> |
| 826 | <div class="literalblock"> |
| 827 | <div class="content"> |
| 828 | <pre><tt>old mode <mode> |
| 829 | new mode <mode> |
| 830 | deleted file mode <mode> |
| 831 | new file mode <mode> |
| 832 | copy from <path> |
| 833 | copy to <path> |
| 834 | rename from <path> |
| 835 | rename to <path> |
| 836 | similarity index <number> |
| 837 | dissimilarity index <number> |
| 838 | index <hash>..<hash> <mode></tt></pre> |
| 839 | </div></div> |
| 840 | </li> |
| 841 | <li> |
| 842 | <p> |
| 843 | TAB, LF, and backslash characters in pathnames are |
| 844 | represented as <tt>\t</tt>, <tt>\n</tt>, and <tt>\\</tt>, respectively. |
| 845 | </p> |
| 846 | </li> |
| 847 | </ol> |
| 848 | </div> |
Junio C Hamano | fb56a96 | 2006-01-28 10:38:19 | [diff] [blame] | 849 | <h2>combined diff format</h2> |
| 850 | <div class="sectionbody"> |
| 851 | <p>git-diff-tree and git-diff-files can take <em>-c</em> or <em>--cc</em> option |
| 852 | to produce <em>combined diff</em>, which looks like this:</p> |
| 853 | <div class="listingblock"> |
| 854 | <div class="content"> |
| 855 | <pre><tt>diff --combined describe.c |
| 856 | @@@ +98,7 @@@ |
| 857 | return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1; |
| 858 | } |
| 859 | |
| 860 | - static void describe(char *arg) |
| 861 | -static void describe(struct commit *cmit, int last_one) |
| 862 | ++static void describe(char *arg, int last_one) |
| 863 | { |
| 864 | + unsigned char sha1[20]; |
| 865 | + struct commit *cmit;</tt></pre> |
| 866 | </div></div> |
| 867 | <p>Unlike the traditional <em>unified</em> diff format, which shows two |
| 868 | files A and B with a single column that has <tt>-</tt> (minus — |
| 869 | appears in A but removed in B), <tt>+</tt> (plus — missing in A but |
| 870 | added to B), or <tt> </tt> (space — unchanged) prefix, this format |
| 871 | compares two or more files file1, file2,… with one file X, and |
| 872 | shows how X differs from each of fileN. One column for each of |
| 873 | fileN is prepended to the output line to note how X's line is |
| 874 | different from it.</p> |
| 875 | <p>A <tt>-</tt> character in the column N means that the line appears in |
| 876 | fileN but it does not appear in the last file. A <tt>+</tt> character |
| 877 | in the column N means that the line appears in the last file, |
| 878 | and fileN does not have that line.</p> |
| 879 | <p>In the above example output, the function signature was changed |
| 880 | from both files (hence two <tt>-</tt> removals from both file1 and |
| 881 | file2, plus <tt>++</tt> to mean one line that was added does not appear |
| 882 | in either file1 nor file2). Also two other lines are the same |
| 883 | from file1 but do not appear in file2 (hence prefixed with <tt> +</tt>).</p> |
| 884 | <p>When shown by <tt>git diff-tree -c</tt>, it compares the parents of a |
| 885 | merge commit with the merge result (i.e. file1..fileN are the |
| 886 | parents). When shown by <tt>git diff-files -c</tt>, it compares the |
| 887 | two unresolved merge parents with the working tree file |
| 888 | (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka |
| 889 | "their version").</p> |
| 890 | </div> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 891 | <h2>Operating Modes</h2> |
| 892 | <div class="sectionbody"> |
| 893 | <p>You can choose whether you want to trust the index file entirely |
| 894 | (using the <em>--cached</em> flag) or ask the diff logic to show any files |
| 895 | that don't match the stat state as being "tentatively changed". Both |
| 896 | of these operations are very useful indeed.</p> |
| 897 | </div> |
| 898 | <h2>Cached Mode</h2> |
| 899 | <div class="sectionbody"> |
| 900 | <p>If <em>--cached</em> is specified, it allows you to ask:</p> |
| 901 | <div class="literalblock"> |
| 902 | <div class="content"> |
| 903 | <pre><tt>show me the differences between HEAD and the current index |
| 904 | contents (the ones I'd write with a "git-write-tree")</tt></pre> |
| 905 | </div></div> |
| 906 | <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] | 907 | some files in the index and are ready to commit. You want to see exactly |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 908 | <strong>what</strong> you are going to commit is without having to write a new tree |
| 909 | object and compare it that way, and to do that, you just do</p> |
| 910 | <div class="literalblock"> |
| 911 | <div class="content"> |
| 912 | <pre><tt>git-diff-index --cached HEAD</tt></pre> |
| 913 | </div></div> |
| 914 | <p>Example: let's say I had renamed <tt>commit.c</tt> to <tt>git-commit.c</tt>, and I had |
| 915 | done an "git-update-index" to make that effective in the index file. |
| 916 | "git-diff-files" wouldn't show anything at all, since the index file |
| 917 | matches my working directory. But doing a "git-diff-index" does:</p> |
| 918 | <div class="literalblock"> |
| 919 | <div class="content"> |
| 920 | <pre><tt>torvalds@ppc970:~/git> git-diff-index --cached HEAD |
| 921 | -100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 commit.c |
| 922 | +100644 blob 4161aecc6700a2eb579e842af0b7f22b98443f74 git-commit.c</tt></pre> |
| 923 | </div></div> |
| 924 | <p>You can trivially see that the above is a rename.</p> |
| 925 | <p>In fact, "git-diff-index --cached" <strong>should</strong> always be entirely equivalent to |
| 926 | actually doing a "git-write-tree" and comparing that. Except this one is much |
| 927 | nicer for the case where you just want to check where you are.</p> |
| 928 | <p>So doing a "git-diff-index --cached" is basically very useful when you are |
| 929 | asking yourself "what have I already marked for being committed, and |
| 930 | what's the difference to a previous tree".</p> |
| 931 | </div> |
| 932 | <h2>Non-cached Mode</h2> |
| 933 | <div class="sectionbody"> |
| 934 | <p>The "non-cached" mode takes a different approach, and is potentially |
| 935 | the more useful of the two in that what it does can't be emulated with |
| 936 | a "git-write-tree" + "git-diff-tree". Thus that's the default mode. |
| 937 | The non-cached version asks the question:</p> |
| 938 | <div class="literalblock"> |
| 939 | <div class="content"> |
| 940 | <pre><tt>show me the differences between HEAD and the currently checked out |
| 941 | tree - index contents _and_ files that aren't up-to-date</tt></pre> |
| 942 | </div></div> |
| 943 | <p>which is obviously a very useful question too, since that tells you what |
| 944 | you <strong>could</strong> commit. Again, the output matches the "git-diff-tree -r" |
| 945 | output to a tee, but with a twist.</p> |
| 946 | <p>The twist is that if some file doesn't match the index, we don't have |
| 947 | a backing store thing for it, and we use the magic "all-zero" sha1 to |
| 948 | show that. So let's say that you have edited <tt>kernel/sched.c</tt>, but |
| 949 | have not actually done a "git-update-index" on it yet - there is no |
| 950 | "object" associated with the new state, and you get:</p> |
| 951 | <div class="literalblock"> |
| 952 | <div class="content"> |
| 953 | <pre><tt>torvalds@ppc970:~/v2.6/linux> git-diff-index HEAD |
| 954 | *100644->100664 blob 7476bb......->000000...... kernel/sched.c</tt></pre> |
| 955 | </div></div> |
Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 956 | <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] | 957 | not up-to-date and may contain new stuff. The all-zero sha1 means that to |
| 958 | get the real diff, you need to look at the object in the working directory |
| 959 | directly rather than do an object-to-object diff.</p> |
| 960 | <div class="admonitionblock"> |
| 961 | <table><tr> |
| 962 | <td class="icon"> |
| 963 | <div class="title">Note</div> |
| 964 | </td> |
| 965 | <td class="content">As with other commands of this type, "git-diff-index" does not |
| 966 | actually look at the contents of the file at all. So maybe |
| 967 | <tt>kernel/sched.c</tt> hasn't actually changed, and it's just that you |
| 968 | touched it. In either case, it's a note that you need to |
Junio C Hamano | 235a91e | 2006-01-07 01:13:58 | [diff] [blame] | 969 | "git-update-index" it to make the index be in sync.</td> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 970 | </tr></table> |
| 971 | </div> |
| 972 | <div class="admonitionblock"> |
| 973 | <table><tr> |
| 974 | <td class="icon"> |
| 975 | <div class="title">Note</div> |
| 976 | </td> |
| 977 | <td class="content">You can have a mixture of files show up as "has been updated" |
| 978 | and "is still dirty in the working directory" together. You can always |
| 979 | tell which file is in which state, since the "has been updated" ones |
| 980 | show a valid sha1, and the "not in sync with the index" ones will |
| 981 | always have the special all-zero sha1.</td> |
| 982 | </tr></table> |
| 983 | </div> |
| 984 | </div> |
| 985 | <h2>Author</h2> |
| 986 | <div class="sectionbody"> |
| 987 | <p>Written by Linus Torvalds <torvalds@osdl.org></p> |
| 988 | </div> |
| 989 | <h2>Documentation</h2> |
| 990 | <div class="sectionbody"> |
| 991 | <p>Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.</p> |
| 992 | </div> |
| 993 | <h2>GIT</h2> |
| 994 | <div class="sectionbody"> |
| 995 | <p>Part of the <a href="git.html">git(7)</a> suite</p> |
| 996 | </div> |
| 997 | <div id="footer"> |
| 998 | <div id="footer-text"> |
Junio C Hamano | 7ccb9fd | 2006-07-15 01:38:40 | [diff] [blame] | 999 | Last updated 15-Jul-2006 01:37:42 UTC |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1000 | </div> |
| 1001 | </div> |
| 1002 | </body> |
| 1003 | </html> |