MCPcopy Create free account
hub / github.com/git/git / wt_status_collect_changes_initial

Function wt_status_collect_changes_initial

wt-status.c:742–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

740}
741
742static 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;

Callers 1

wt_status_collectFunction · 0.85

Calls 7

ce_path_matchFunction · 0.85
lookup_treeFunction · 0.85
strbuf_addFunction · 0.85
read_tree_atFunction · 0.85
string_list_insertFunction · 0.85
oidcpyFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected