-
Notifications
You must be signed in to change notification settings - Fork 97
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 clean
and stash -u
#430
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1068,23 +1068,42 @@ test_expect_success 'clean' ' | |
test_all_match git commit -m "ignore bogus files" && | ||
|
||
run_on_sparse mkdir folder1 && | ||
run_on_all mkdir -p deep/untracked-deep && | ||
run_on_all touch folder1/bogus && | ||
run_on_all touch folder1/untracked && | ||
run_on_all touch deep/untracked-deep/bogus && | ||
run_on_all touch deep/untracked-deep/untracked && | ||
|
||
test_all_match git status --porcelain=v2 && | ||
test_all_match git clean -f && | ||
test_all_match git status --porcelain=v2 && | ||
test_sparse_match ls && | ||
test_sparse_match ls folder1 && | ||
run_on_all test_path_exists folder1/bogus && | ||
run_on_all test_path_is_missing folder1/untracked && | ||
run_on_all test_path_exists deep/untracked-deep/bogus && | ||
run_on_all test_path_exists deep/untracked-deep/untracked && | ||
|
||
test_all_match git clean -fd && | ||
test_all_match git status --porcelain=v2 && | ||
test_sparse_match ls && | ||
test_sparse_match ls folder1 && | ||
run_on_all test_path_exists folder1/bogus && | ||
run_on_all test_path_exists deep/untracked-deep/bogus && | ||
run_on_all test_path_is_missing deep/untracked-deep/untracked && | ||
|
||
test_all_match git clean -xf && | ||
test_all_match git status --porcelain=v2 && | ||
test_sparse_match ls && | ||
test_sparse_match ls folder1 && | ||
run_on_all test_path_is_missing folder1/bogus && | ||
run_on_all test_path_exists deep/untracked-deep/bogus && | ||
|
||
test_all_match git clean -xdf && | ||
test_all_match git status --porcelain=v2 && | ||
test_sparse_match ls && | ||
test_sparse_match ls folder1 && | ||
run_on_all test_path_is_missing deep/untracked-deep/bogus && | ||
|
||
test_sparse_match test_path_is_dir folder1 | ||
' | ||
|
@@ -1202,6 +1221,8 @@ test_expect_success 'sparse-index is not expanded' ' | |
git -C sparse-index add README.md && | ||
ensure_not_expanded diff --staged && | ||
|
||
ensure_not_expanded clean -fd && | ||
|
||
ensure_not_expanded checkout -f update-deep && | ||
( | ||
sane_unset GIT_TEST_MERGE_ALGORITHM && | ||
|
@@ -1280,6 +1301,46 @@ test_expect_success 'sparse index is not expanded: read-tree' ' | |
ensure_not_expanded read-tree --prefix=deep/deeper2 -u deepest | ||
' | ||
|
||
# NEEDSWORK: although the full repository's index is _not_ expanded as part of | ||
# stash, a temporary index, which is _not_ sparse, is created when stashing and | ||
# applying a stash of untracked files. As a result, the test reports that it | ||
# finds an instance of `ensure_full_index`, but it does not carry with it the | ||
# performance implications of expanding the full repository index. | ||
Comment on lines
+1304
to
+1308
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good explanation of the problem. I wonder if there is something we can do to make creating this temporary index as a sparse one be better. Do you have a pointer to the place in the code that creates this index? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It comes from setting the When creating the stash (with untracked entries included) The more complicated case is on the unstashing side - All that to say - I agree that there's more that can be done to preserve "sparseness" of the temp index. I think complications come up when dealing with untracked files in sparse directories (likely part of what caused the segfaults in my earlier testing), but I don't see it being impossible to handle. |
||
test_expect_success 'sparse index is not expanded: stash -u' ' | ||
init_repos && | ||
|
||
mkdir -p sparse-index/folder1 && | ||
echo >>sparse-index/README.md && | ||
echo >>sparse-index/a && | ||
echo >>sparse-index/folder1/new && | ||
|
||
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \ | ||
git -C sparse-index stash -u && | ||
test_region index ensure_full_index trace2.txt && | ||
|
||
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \ | ||
git -C sparse-index stash pop && | ||
test_region index ensure_full_index trace2.txt | ||
' | ||
|
||
# NEEDSWORK: similar to `git add`, untracked files outside of the sparse | ||
# checkout definition are successfully stashed and unstashed. | ||
test_expect_success 'stash -u outside sparse checkout definition' ' | ||
init_repos && | ||
|
||
write_script edit-contents <<-\EOF && | ||
echo text >>$1 | ||
EOF | ||
|
||
run_on_sparse mkdir -p folder1 && | ||
run_on_all ../edit-contents folder1/new && | ||
test_all_match git stash -u && | ||
test_all_match git status --porcelain=v2 && | ||
|
||
test_all_match git stash pop -q && | ||
test_all_match git status --porcelain=v2 | ||
' | ||
|
||
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout | ||
# in this scenario, but it shouldn't. | ||
test_expect_success 'reset mixed and checkout orphan' ' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test that checks that
git clean -fd
correctly removes untracked files in sparse directories?something like:
I expect that the index will be expanded to do this operation, but let's make sure it happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the existing
git clean
tests to check those cases and explicitly verify paths are present or missing. Also, I verified that the index is expanded when untracked files are inside a sparse directory, so no tests were added to theensure_not_expanded
test.