* This gets a mix of an existing index and a tree, one pathname entry * at a time. The index entry may be a single stage-0 one, but it could * also be multiple unmerged entries (in which case idx_pos/idx_nr will * give you the position and number of entries in the index). */
| 440 | * give you the position and number of entries in the index). |
| 441 | */ |
| 442 | static void do_oneway_diff(struct unpack_trees_options *o, |
| 443 | const struct cache_entry *idx, |
| 444 | const struct cache_entry *tree) |
| 445 | { |
| 446 | struct rev_info *revs = o->unpack_data; |
| 447 | int match_missing, cached; |
| 448 | |
| 449 | /* |
| 450 | * i-t-a entries do not actually exist in the index (if we're |
| 451 | * looking at its content) |
| 452 | */ |
| 453 | if (o->index_only && |
| 454 | revs->diffopt.ita_invisible_in_index && |
| 455 | idx && ce_intent_to_add(idx)) { |
| 456 | idx = NULL; |
| 457 | if (!tree) |
| 458 | return; /* nothing to diff.. */ |
| 459 | } |
| 460 | |
| 461 | /* if the entry is not checked out, don't examine work tree */ |
| 462 | cached = o->index_only || |
| 463 | (idx && ((idx->ce_flags & CE_VALID) || ce_skip_worktree(idx))); |
| 464 | |
| 465 | match_missing = revs->match_missing; |
| 466 | |
| 467 | if (cached && idx && ce_stage(idx)) { |
| 468 | struct diff_filepair *pair; |
| 469 | pair = diff_unmerge(&revs->diffopt, idx->name); |
| 470 | if (tree) |
| 471 | fill_filespec(pair->one, &tree->oid, 1, |
| 472 | tree->ce_mode); |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | /* |
| 477 | * Something added to the tree? |
| 478 | */ |
| 479 | if (!tree) { |
| 480 | show_new_file(revs, idx, cached, match_missing); |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | * Something removed from the tree? |
| 486 | */ |
| 487 | if (!idx) { |
| 488 | if (S_ISSPARSEDIR(tree->ce_mode)) { |
| 489 | diff_tree_oid(&tree->oid, NULL, tree->name, &revs->diffopt); |
| 490 | return; |
| 491 | } |
| 492 | |
| 493 | diff_index_show_file(revs, "-", tree, &tree->oid, 1, |
| 494 | tree->ce_mode, 0); |
| 495 | return; |
| 496 | } |
| 497 | |
| 498 | /* Show difference between old and new */ |
| 499 | show_modified(revs, tree, idx, 1, cached, match_missing); |
no test coverage detected