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

rm/sparse-index-integration #6

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
6 changes: 4 additions & 2 deletions builtin/rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
char *seen;

git_config(git_default_config, NULL);
if (the_repository->gitdir) {
prepare_repo_settings(the_repository);
the_repository->settings.command_requires_full_index = 0;
}

argc = parse_options(argc, argv, prefix, builtin_rm_options,
builtin_rm_usage, 0);
Expand Down Expand Up @@ -296,8 +300,6 @@ int cmd_rm(int argc, const char **argv, const char *prefix)

seen = xcalloc(pathspec.nr, 1);

/* TODO: audit for interaction with sparse-index. */
ensure_full_index(&the_index);
for (i = 0; i < active_nr; i++) {
const struct cache_entry *ce = active_cache[i];

Expand Down
61 changes: 61 additions & 0 deletions t/t1092-sparse-checkout-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1853,4 +1853,65 @@ test_expect_success 'mv directory from out-of-cone to in-cone' '
grep -e "H deep/0/1" actual
'

test_expect_success 'rm pathspec inside sparse definition' '
init_repos &&

for file in deep/a deep/deeper1/0/0/0 deep/deeper1/deepest/a
ffyuanda marked this conversation as resolved.
Show resolved Hide resolved
do
test_all_match git rm $file &&
test_all_match git status --porcelain=v2
done &&

# test wildcard
run_on_all git reset --hard &&
test_all_match git rm deep/* &&
test_all_match git status --porcelain=v2 &&

# test recursive rm
run_on_all git reset --hard &&
test_all_match git rm -r deep &&
test_all_match git status --porcelain=v2
'

test_expect_failure 'rm pathspec outside sparse definition' '
init_repos &&

for file in folder1/a folder1/0/1 folder1/0/0/0
ffyuanda marked this conversation as resolved.
Show resolved Hide resolved
do
test_sparse_match test_must_fail git rm $file &&
test_sparse_match test_must_fail git rm --cached $file &&
test_sparse_match git rm --sparse $file &&
test_sparse_match git status --porcelain=v2
done &&

# test wildcard
run_on_sparse git reset --hard &&
test_sparse_match test_must_fail git rm folder1/* &&
test_sparse_match git rm --sparse folder1/* &&
test_sparse_match git status --porcelain=v2 &&

# test recursive rm
run_on_sparse git reset --hard &&
test_sparse_match test_must_fail git rm folder1 &&
ffyuanda marked this conversation as resolved.
Show resolved Hide resolved
test_sparse_match git rm -r --sparse folder1 &&
test_sparse_match git status --porcelain=v2
'

test_expect_success 'sparse index is not expanded: rm' '
init_repos &&

for file in deep/a deep/deeper1/a deep/deeper1/deepest/a
ffyuanda marked this conversation as resolved.
Show resolved Hide resolved
do
ensure_not_expanded rm $file
done &&

# test in-cone wildcard not expand
ffyuanda marked this conversation as resolved.
Show resolved Hide resolved
git -C sparse-index reset --hard &&
ensure_not_expanded rm deep/* &&

# test recursive rm not expand
git -C sparse-index reset --hard &&
ensure_not_expanded rm -r deep
'

test_done