Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sparse Index] Integrate with git status #374

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2a4a725
sparse-index: skip indexes with unmerged entries
derrickstolee Apr 29, 2021
f5bae86
sparse-index: include EXTENDED flag when expanding
derrickstolee May 4, 2021
d965669
t1092: replace incorrect 'echo' with 'cat'
derrickstolee May 26, 2021
44a9402
t1092: expand repository data shape
derrickstolee May 14, 2021
701ac0e
t1092: add tests for status/add and sparse files
derrickstolee Apr 12, 2021
587333f
unpack-trees: preserve cache_bottom
derrickstolee Apr 21, 2021
6fc898a
unpack-trees: compare sparse directories correctly
derrickstolee Apr 21, 2021
b676ef4
unpack-trees: unpack sparse directory entries
derrickstolee May 27, 2021
d693f00
dir.c: accept a directory as part of cone-mode patterns
derrickstolee Jan 11, 2021
ed11cfc
diff-lib: handle index diffs with sparse dirs
derrickstolee Jun 1, 2021
48fd25a
status: skip sparse-checkout percentage with sparse-index
derrickstolee Jan 15, 2021
3499105
status: use sparse-index throughout
derrickstolee Jan 8, 2021
60a6706
wt-status: expand added sparse directory entries
derrickstolee May 4, 2021
76bd8ec
fsmonitor: integrate with sparse index
derrickstolee Jan 15, 2021
a1a570a
Merge sparse-aware 'git status' into vfs-2.32.0
derrickstolee Jun 15, 2021
093a832
t1092: cleanups
derrickstolee Jun 17, 2021
722e7cd
fixup! unpack-trees: unpack sparse directory entries
derrickstolee Jun 17, 2021
9edbebf
fixup! unpack-trees: unpack sparse directory entries
derrickstolee Jun 17, 2021
0fda21d
fixup! t1092: expand repository data shape
derrickstolee Jun 17, 2021
610518c
fixup! unpack-trees: unpack sparse directory entries
derrickstolee Jun 17, 2021
320586f
fixup! dir.c: accept a directory as part of cone-mode patterns
derrickstolee Jun 17, 2021
ddaebb7
fixup! wt-status: expand added sparse directory entries
derrickstolee Jun 17, 2021
44bfb50
fixup! sparse-index: implement ensure_full_index()
derrickstolee Jun 17, 2021
0c20b94
fixup! fsmonitor: integrate with sparse index
derrickstolee Jun 17, 2021
f462956
fixup! fixup! t1092: expand repository data shape
derrickstolee Jun 18, 2021
87a3a29
fixup! wt-status: expand added sparse directory entries
derrickstolee Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sparse-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ int convert_to_sparse(struct index_state *istate)
cache_tree_free(&istate->cache_tree);
cache_tree_update(istate, 0);

istate->fsmonitor_has_run_once = 0;
FREE_AND_NULL(istate->fsmonitor_dirty);
FREE_AND_NULL(istate->fsmonitor_last_update);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to map the old extension data (which is essentially a compressed version of the fsmonitor_dirty bitmap, which we should be able to map relatively easily by iterating over the full and the sparse index simultaneously).

I do not suggest to implement this here, but maybe mention it as a potential future improvement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you recommending a translation of the old bitmap into a new bitmap based on the new path positions? Yes, that would work, but I don't think it is worth pursuing much at all. We are better off investing in the sparse-index work such that we only change the sparse directory entries during git sparse-checkout set, which is rare and likely is on a clean working directory.

istate->sparse_index = 1;
trace2_region_leave("index", "convert_to_sparse", istate->repo);
return 0;
Expand Down Expand Up @@ -282,6 +286,9 @@ void ensure_full_index(struct index_state *istate)
istate->cache = full->cache;
istate->cache_nr = full->cache_nr;
istate->cache_alloc = full->cache_alloc;
istate->fsmonitor_has_run_once = 0;
FREE_AND_NULL(istate->fsmonitor_dirty);
FREE_AND_NULL(istate->fsmonitor_last_update);
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved

strbuf_release(&base);
free(full);
Expand Down
48 changes: 48 additions & 0 deletions t/t7519-status-fsmonitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ test_expect_success 'setup' '
expect*
actual*
marker*
trace2*
EOF
'

Expand Down Expand Up @@ -383,4 +384,51 @@ test_expect_success 'status succeeds after staging/unstaging' '
)
'

# Usage:
# check_sparse_index_behavior [!]
# If "!" is supplied, then we verify that we do not call ensure_full_index
# during a call to 'git status'. Otherwise, we verify that we _do_ call it.
check_sparse_index_behavior () {
git status --porcelain=v2 >expect &&
git sparse-checkout init --cone --sparse-index &&
git sparse-checkout set dir1 dir2 &&
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \
git status --porcelain=v2 >actual &&
test_region $1 index ensure_full_index trace2.txt &&
derrickstolee marked this conversation as resolved.
Show resolved Hide resolved
test_cmp expect actual &&
rm trace2.txt &&
git sparse-checkout disable
}

test_expect_success 'status succeeds with sparse index' '
git reset --hard &&

test_config core.fsmonitor "$TEST_DIRECTORY/t7519/fsmonitor-all" &&
check_sparse_index_behavior ! &&

write_script .git/hooks/fsmonitor-test<<-\EOF &&
printf "last_update_token\0"
EOF
git config core.fsmonitor .git/hooks/fsmonitor-test &&
check_sparse_index_behavior ! &&

write_script .git/hooks/fsmonitor-test<<-\EOF &&
printf "last_update_token\0"
printf "dir1/modified\0"
EOF
check_sparse_index_behavior ! &&

cp -r dir1 dir1a &&
git add dir1a &&
git commit -m "add dir1a" &&

# This one modifies outside the sparse-checkout definition
# and hence we expect to expand the sparse-index.
write_script .git/hooks/fsmonitor-test<<-\EOF &&
printf "last_update_token\0"
printf "dir1a/modified\0"
EOF
check_sparse_index_behavior
'

test_done