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

Function wt_status_check_sparse_checkout

wt-status.c:1791–1821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1789}
1790
1791static void wt_status_check_sparse_checkout(struct repository *r,
1792 struct wt_status_state *state)
1793{
1794 int skip_worktree = 0;
1795 int i;
1796 struct repo_config_values *cfg = repo_config_values(the_repository);
1797
1798 if (!cfg->apply_sparse_checkout ||
1799 r->index->cache_nr == 0) {
1800 /*
1801 * Don't compute percentage of checked out files if we
1802 * aren't in a sparse checkout or would get division by 0.
1803 */
1804 state->sparse_checkout_percentage = SPARSE_CHECKOUT_DISABLED;
1805 return;
1806 }
1807
1808 if (r->index->sparse_index) {
1809 state->sparse_checkout_percentage = SPARSE_CHECKOUT_SPARSE_INDEX;
1810 return;
1811 }
1812
1813 for (i = 0; i < r->index->cache_nr; i++) {
1814 struct cache_entry *ce = r->index->cache[i];
1815 if (ce_skip_worktree(ce))
1816 skip_worktree++;
1817 }
1818
1819 state->sparse_checkout_percentage =
1820 100 - (100 * skip_worktree)/r->index->cache_nr;
1821}
1822
1823void wt_status_get_state(struct repository *r,
1824 struct wt_status_state *state,

Callers 1

wt_status_get_stateFunction · 0.85

Calls 1

repo_config_valuesClass · 0.70

Tested by

no test coverage detected