| 740 | } |
| 741 | |
| 742 | static void wt_status_collect_changes_initial(struct wt_status *s) |
| 743 | { |
| 744 | struct index_state *istate = s->repo->index; |
| 745 | struct strbuf base = STRBUF_INIT; |
| 746 | int i; |
| 747 | |
| 748 | for (i = 0; i < istate->cache_nr; i++) { |
| 749 | struct string_list_item *it; |
| 750 | struct wt_status_change_data *d; |
| 751 | const struct cache_entry *ce = istate->cache[i]; |
| 752 | |
| 753 | if (!ce_path_match(istate, ce, &s->pathspec, NULL)) |
| 754 | continue; |
| 755 | if (ce_intent_to_add(ce)) |
| 756 | continue; |
| 757 | if (S_ISSPARSEDIR(ce->ce_mode)) { |
| 758 | /* |
| 759 | * This is a sparse directory entry, so we want to collect all |
| 760 | * of the added files within the tree. This requires recursively |
| 761 | * expanding the trees to find the elements that are new in this |
| 762 | * tree and marking them with DIFF_STATUS_ADDED. |
| 763 | */ |
| 764 | struct pathspec ps = { 0 }; |
| 765 | struct tree *tree = lookup_tree(istate->repo, &ce->oid); |
| 766 | |
| 767 | ps.recursive = 1; |
| 768 | ps.has_wildcard = 1; |
| 769 | ps.max_depth = -1; |
| 770 | |
| 771 | strbuf_reset(&base); |
| 772 | strbuf_add(&base, ce->name, ce->ce_namelen); |
| 773 | read_tree_at(istate->repo, tree, &base, 0, &ps, |
| 774 | add_file_to_list, s); |
| 775 | |
| 776 | continue; |
| 777 | } |
| 778 | |
| 779 | it = string_list_insert(&s->change, ce->name); |
| 780 | d = it->util; |
| 781 | if (!d) { |
| 782 | CALLOC_ARRAY(d, 1); |
| 783 | it->util = d; |
| 784 | } |
| 785 | if (ce_stage(ce)) { |
| 786 | d->index_status = DIFF_STATUS_UNMERGED; |
| 787 | d->stagemask |= (1 << (ce_stage(ce) - 1)); |
| 788 | /* |
| 789 | * Don't bother setting {mode,oid}_{head,index} since the print |
| 790 | * code will output the stage values directly and not use the |
| 791 | * values in these fields. |
| 792 | */ |
| 793 | s->committable = 1; |
| 794 | } else { |
| 795 | d->index_status = DIFF_STATUS_ADDED; |
| 796 | /* Leave {mode,oid}_head zero for adds. */ |
| 797 | d->mode_index = ce->ce_mode; |
| 798 | oidcpy(&d->oid_index, &ce->oid); |
| 799 | s->committable = 1; |
no test coverage detected