aboutsummaryrefslogtreecommitdiffstats
path: root/wt-status.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-07-14 13:12:36 +0000
committerJunio C Hamano <gitster@pobox.com>2021-07-14 13:42:49 -0700
commitbf48e5acdbf25a98fd142d9c90157c10b427119a (patch)
treed293eb9bf8f7122fe3635714b3354f4b5e72afef /wt-status.c
parent9eb00af5627f1a04ca083128085ca6774fce0524 (diff)
downloadgit-bf48e5acdbf25a98fd142d9c90157c10b427119a.tar.gz
status: skip sparse-checkout percentage with sparse-index
'git status' began reporting a percentage of populated paths when sparse-checkout is enabled in 051df3cf (wt-status: show sparse checkout status as well, 2020-07-18). This percentage is incorrect when the index has sparse directories. It would also be expensive to calculate as we would need to parse trees to count the total number of possible paths. Avoid the expensive computation by simplifying the output to only report that a sparse checkout exists, without the percentage. This change is the reason we use 'git status --porcelain=v2' in t1092-sparse-checkout-compatibility.sh. We don't want to ensure that this message is equal across both modes, but instead just the important information about staged, modified, and untracked files are compared. Reviewed-by: Elijah Newren <newren@gmail.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/wt-status.c b/wt-status.c
index 42b6735716..96db3e7496 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1493,9 +1493,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);
}
@@ -1653,6 +1656,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))