| 1789 | } |
| 1790 | |
| 1791 | static 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 | |
| 1823 | void wt_status_get_state(struct repository *r, |
| 1824 | struct wt_status_state *state, |
no test coverage detected