@@ -202,6 +202,14 @@ test_expect_success 'status with options' '
test_all_match git status --porcelain=v2 -uno
'
+test_expect_success 'status reports sparse-checkout' '
+ init_repos &&
+ git -C sparse-checkout status >full &&
+ git -C sparse-index status >sparse &&
+ test_i18ngrep "You are in a sparse checkout with " full &&
+ test_i18ngrep "You are in a sparse checkout." sparse
+'
+
test_expect_success 'add, commit, checkout' '
init_repos &&
@@ -1490,9 +1490,12 @@ static void show_sparse_checkout_in_use(struct wt_status *s,
if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_DISABLED)
return;
- status_printf_ln(s, color,
- _("You are in a sparse checkout with %d%% of tracked files present."),
- s->state.sparse_checkout_percentage);
+ if (s->state.sparse_checkout_percentage == SPARSE_CHECKOUT_SPARSE_INDEX)
+ status_printf_ln(s, color, _("You are in a sparse checkout."));
+ else
+ status_printf_ln(s, color,
+ _("You are in a sparse checkout with %d%% of tracked files present."),
+ s->state.sparse_checkout_percentage);
wt_longstatus_print_trailer(s);
}
@@ -1650,6 +1653,11 @@ static void wt_status_check_sparse_checkout(struct repository *r,
return;
}
+ if (r->index->sparse_index) {
+ state->sparse_checkout_percentage = SPARSE_CHECKOUT_SPARSE_INDEX;
+ return;
+ }
+
for (i = 0; i < r->index->cache_nr; i++) {
struct cache_entry *ce = r->index->cache[i];
if (ce_skip_worktree(ce))
@@ -78,6 +78,7 @@ enum wt_status_format {
};
#define SPARSE_CHECKOUT_DISABLED -1
+#define SPARSE_CHECKOUT_SPARSE_INDEX -2
struct wt_status_state {
int merge_in_progress;