Skip to content

Commit d0c3853

Browse files
committed
Merge branch 'al/trace2-clearing-skip-worktree'
Add trace2 counters to the region to clear skip worktree bits in a sparse checkout. * al/trace2-clearing-skip-worktree: index: raise a bug if the index is materialised more than once index: add trace2 region for clear skip worktree
2 parents 561f394 + 8c7abdc commit d0c3853

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

sparse-index.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,24 +493,42 @@ void clear_skip_worktree_from_present_files(struct index_state *istate)
493493
int dir_found = 1;
494494

495495
int i;
496+
int path_count[2] = {0, 0};
497+
int restarted = 0;
496498

497499
if (!core_apply_sparse_checkout ||
498500
sparse_expect_files_outside_of_patterns)
499501
return;
500502

503+
trace2_region_enter("index", "clear_skip_worktree_from_present_files",
504+
istate->repo);
501505
restart:
502506
for (i = 0; i < istate->cache_nr; i++) {
503507
struct cache_entry *ce = istate->cache[i];
504508

505-
if (ce_skip_worktree(ce) &&
506-
path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
507-
if (S_ISSPARSEDIR(ce->ce_mode)) {
508-
ensure_full_index(istate);
509-
goto restart;
509+
if (ce_skip_worktree(ce)) {
510+
path_count[restarted]++;
511+
if (path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
512+
if (S_ISSPARSEDIR(ce->ce_mode)) {
513+
if (restarted)
514+
BUG("ensure-full-index did not fully flatten?");
515+
ensure_full_index(istate);
516+
restarted = 1;
517+
goto restart;
518+
}
519+
ce->ce_flags &= ~CE_SKIP_WORKTREE;
510520
}
511-
ce->ce_flags &= ~CE_SKIP_WORKTREE;
512521
}
513522
}
523+
524+
if (path_count[0])
525+
trace2_data_intmax("index", istate->repo,
526+
"sparse_path_count", path_count[0]);
527+
if (restarted)
528+
trace2_data_intmax("index", istate->repo,
529+
"sparse_path_count_full", path_count[1]);
530+
trace2_region_leave("index", "clear_skip_worktree_from_present_files",
531+
istate->repo);
514532
}
515533

516534
/*

0 commit comments

Comments
 (0)