forked from git-for-windows/git
-
Notifications
You must be signed in to change notification settings - Fork 105
Sparse index: git reset
#417
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0fddaa
reset: add test demonstrating mixed reset outside sparse checkout
vdye e934f4f
reset: expand test coverage in sparse checkout
vdye 8d8143a
sparse-index: use `read-tree` for expand/collapse test
vdye 33e9a20
sparse-index: integrate with reset
vdye 9a65b6a
sparse-index: make non-mixed `reset` sparse-aware
vdye e9331c4
sparse-index: make mixed `reset` sparse-aware
vdye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -480,6 +480,113 @@ test_expect_success 'checkout and reset (mixed) [sparse]' ' | |
test_sparse_match git reset update-folder2 | ||
' | ||
|
||
# NEEDSWORK: with mixed reset, files with differences between HEAD and <commit> | ||
# will be added to the work tree even if outside the sparse checkout | ||
# definition, and even if the file is modified to a state of having no local | ||
# changes. The file is "re-ignored" if a hard reset is executed. We may want to | ||
# change this behavior in the future and enforce that files are not written | ||
# outside of the sparse checkout definition. | ||
test_expect_success 'checkout and mixed reset file tracking [sparse]' ' | ||
init_repos && | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
test_all_match git reset update-folder1 && | ||
test_all_match git reset update-deep && | ||
|
||
# At this point, there are no changes in the working tree. However, | ||
# folder1/a now exists locally (even though it is outside of the sparse | ||
# paths). | ||
run_on_sparse test_path_exists folder1 && | ||
|
||
run_on_all rm folder1/a && | ||
test_all_match git status --porcelain=v2 && | ||
|
||
test_all_match git reset --hard update-deep && | ||
run_on_sparse test_path_is_missing folder1 && | ||
test_path_exists full-checkout/folder1 | ||
' | ||
|
||
test_expect_success 'checkout and reset (merge)' ' | ||
init_repos && | ||
|
||
write_script edit-contents <<-\EOF && | ||
echo text >>$1 | ||
EOF | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
run_on_all ../edit-contents a && | ||
test_all_match git reset --merge deepest && | ||
test_all_match git status --porcelain=v2 && | ||
|
||
test_all_match git reset --hard update-deep && | ||
run_on_all ../edit-contents deep/a && | ||
test_all_match test_must_fail git reset --merge deepest | ||
' | ||
|
||
test_expect_success 'checkout and reset (keep)' ' | ||
init_repos && | ||
|
||
write_script edit-contents <<-\EOF && | ||
echo text >>$1 | ||
EOF | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
run_on_all ../edit-contents a && | ||
test_all_match git reset --keep deepest && | ||
test_all_match git status --porcelain=v2 && | ||
|
||
test_all_match git reset --hard update-deep && | ||
run_on_all ../edit-contents deep/a && | ||
test_all_match test_must_fail git reset --keep deepest | ||
' | ||
|
||
test_expect_success 'reset with pathspecs inside sparse definition' ' | ||
init_repos && | ||
|
||
write_script edit-contents <<-\EOF && | ||
echo text >>$1 | ||
EOF | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
run_on_all ../edit-contents deep/a && | ||
|
||
test_all_match git reset base -- deep/a && | ||
test_all_match git status --porcelain=v2 && | ||
|
||
test_all_match git reset base -- nonexistent-file && | ||
test_all_match git status --porcelain=v2 && | ||
|
||
test_all_match git reset deepest -- deep && | ||
test_all_match git status --porcelain=v2 | ||
' | ||
|
||
test_expect_success 'reset with sparse directory pathspec outside definition' ' | ||
init_repos && | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
test_all_match git reset --hard update-folder1 && | ||
test_all_match git reset base -- folder1 && | ||
test_all_match git status --porcelain=v2 | ||
' | ||
|
||
test_expect_success 'reset with pathspec match in sparse directory' ' | ||
init_repos && | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
test_all_match git reset --hard update-folder1 && | ||
test_all_match git reset base -- folder1/a && | ||
test_all_match git status --porcelain=v2 | ||
' | ||
|
||
test_expect_success 'reset with wildcard pathspec' ' | ||
init_repos && | ||
|
||
test_all_match git checkout -b reset-test update-deep && | ||
test_all_match git reset --hard update-folder1 && | ||
test_all_match git reset base -- */a && | ||
test_all_match git status --porcelain=v2 | ||
' | ||
|
||
test_expect_success 'merge, cherry-pick, and rebase' ' | ||
init_repos && | ||
|
||
|
@@ -643,7 +750,7 @@ test_expect_success 'sparse-index is expanded and converted back' ' | |
init_repos && | ||
|
||
GIT_TRACE2_EVENT="$(pwd)/trace2.txt" GIT_TRACE2_EVENT_NESTING=10 \ | ||
git -C sparse-index -c core.fsmonitor="" reset --hard && | ||
git -C sparse-index -c core.fsmonitor="" read-tree -mu HEAD && | ||
test_region index convert_to_sparse trace2.txt && | ||
test_region index ensure_full_index trace2.txt | ||
' | ||
|
@@ -680,9 +787,9 @@ test_expect_success 'sparse-index is not expanded' ' | |
ensure_not_expanded checkout - && | ||
ensure_not_expanded switch rename-out-to-out && | ||
ensure_not_expanded switch - && | ||
git -C sparse-index reset --hard && | ||
ensure_not_expanded reset --hard && | ||
ensure_not_expanded checkout rename-out-to-out -- deep/deeper1 && | ||
git -C sparse-index reset --hard && | ||
ensure_not_expanded reset --hard && | ||
vdye marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ensure_not_expanded restore -s rename-out-to-out -- deep/deeper1 && | ||
|
||
echo >>sparse-index/README.md && | ||
|
@@ -692,6 +799,28 @@ test_expect_success 'sparse-index is not expanded' ' | |
echo >>sparse-index/untracked.txt && | ||
ensure_not_expanded add . && | ||
|
||
for ref in update-deep update-folder1 update-folder2 update-deep | ||
do | ||
echo >>sparse-index/README.md && | ||
ensure_not_expanded reset --mixed $ref | ||
ensure_not_expanded reset --hard $ref | ||
done && | ||
|
||
ensure_not_expanded reset --hard update-deep && | ||
ensure_not_expanded reset --keep base && | ||
ensure_not_expanded reset --merge update-deep && | ||
|
||
ensure_not_expanded reset base -- deep/a && | ||
ensure_not_expanded reset base -- nonexistent-file && | ||
ensure_not_expanded reset deepest -- deep && | ||
|
||
# Although folder1 is outside the sparse definition, it exists as a | ||
# directory entry in the index, so it will be reset without needing to | ||
# expand the full index. | ||
ensure_not_expanded reset --hard update-folder1 && | ||
Comment on lines
+817
to
+820
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. nice! I'm excited to see that this is possible. |
||
ensure_not_expanded reset base -- folder1 && | ||
|
||
ensure_not_expanded reset --hard update-deep && | ||
ensure_not_expanded checkout -f update-deep && | ||
( | ||
sane_unset GIT_TEST_MERGE_ALGORITHM && | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.