mirror of
https://github.com/git/git.git
synced 2024-12-20 15:24:09 +08:00
7d782416cb
Don't update files in the worktree from cache entries which are flagged with CE_WT_REMOVE. When a user does a sparse checkout, git removes files that are marked with CE_WT_REMOVE (because they are out-of-scope for the sparse checkout). If those files are also marked CE_UPDATE (for instance, because they differ in the branch that is being checked out and the outgoing branch), git would previously recreate them. This patch prevents them from being recreated. These erroneously-created files would also interfere with merges, causing pre-merge revisions of out-of-scope files to appear in the worktree. apply_sparse_checkout() is the function where all "action" manipulation (add, delete, update files..) for sparse checkout occurs; it should not ask to delete and update both at the same time. Signed-off-by: Anatole Shaw <git-devel@omni.poc.net> Signed-off-by: David Turner <dturner@twopensource.com> Helped-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='sparse checkout scope tests'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
echo "initial" >a &&
|
|
echo "initial" >b &&
|
|
echo "initial" >c &&
|
|
git add a b c &&
|
|
git commit -m "initial commit"
|
|
'
|
|
|
|
test_expect_success 'create feature branch' '
|
|
git checkout -b feature &&
|
|
echo "modified" >b &&
|
|
echo "modified" >c &&
|
|
git add b c &&
|
|
git commit -m "modification"
|
|
'
|
|
|
|
test_expect_success 'perform sparse checkout of master' '
|
|
git config --local --bool core.sparsecheckout true &&
|
|
echo "!/*" >.git/info/sparse-checkout &&
|
|
echo "/a" >>.git/info/sparse-checkout &&
|
|
echo "/c" >>.git/info/sparse-checkout &&
|
|
git checkout master &&
|
|
test_path_is_file a &&
|
|
test_path_is_missing b &&
|
|
test_path_is_file c
|
|
'
|
|
|
|
test_expect_success 'merge feature branch into sparse checkout of master' '
|
|
git merge feature &&
|
|
test_path_is_file a &&
|
|
test_path_is_missing b &&
|
|
test_path_is_file c &&
|
|
test "$(cat c)" = "modified"
|
|
'
|
|
|
|
test_expect_success 'return to full checkout of master' '
|
|
git checkout feature &&
|
|
echo "/*" >.git/info/sparse-checkout &&
|
|
git checkout master &&
|
|
test_path_is_file a &&
|
|
test_path_is_file b &&
|
|
test_path_is_file c &&
|
|
test "$(cat b)" = "modified"
|
|
'
|
|
|
|
test_done
|