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