summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/add.c3
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh25
2 files changed, 21 insertions, 7 deletions
diff --git a/builtin/add.c b/builtin/add.c
index b773b5a..c76e6dd 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -528,6 +528,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize;
require_pathspec = !(take_worktree_changes || (0 < addremove_explicit));
+ prepare_repo_settings(the_repository);
+ the_repository->settings.command_requires_full_index = 0;
+
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
/*
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index 4c3bcb3..77343cb 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -340,21 +340,27 @@ test_expect_success 'status/add: outside sparse cone' '
test_sparse_match git status --porcelain=v2 &&
- # This "git add folder1/a" fails with a warning
- # in the sparse repos, differing from the full
- # repo. This is intentional.
+ # Adding the path outside of the sparse-checkout cone should fail.
test_sparse_match test_must_fail git add folder1/a &&
- test_sparse_match test_must_fail git add --refresh folder1/a &&
- test_all_match git status --porcelain=v2 &&
+
+ test_must_fail git -C sparse-checkout add --refresh folder1/a 2>sparse-checkout-err &&
+ test_must_fail git -C sparse-index add --refresh folder1/a 2>sparse-index-err &&
+ # NEEDSWORK: A sparse index changes the error message.
+ ! test_cmp sparse-checkout-err sparse-index-err &&
+
+ # NEEDSWORK: Adding a newly-tracked file outside the cone succeeds
+ test_sparse_match git add folder1/new &&
test_all_match git add . &&
test_all_match git status --porcelain=v2 &&
test_all_match git commit -m folder1/new &&
+ test_all_match git rev-parse HEAD^{tree} &&
run_on_all ../edit-contents folder1/newer &&
test_all_match git add folder1/ &&
test_all_match git status --porcelain=v2 &&
- test_all_match git commit -m folder1/newer
+ test_all_match git commit -m folder1/newer &&
+ test_all_match git rev-parse HEAD^{tree}
'
test_expect_success 'checkout and reset --hard' '
@@ -641,7 +647,12 @@ test_expect_success 'sparse-index is not expanded' '
git -C sparse-index reset --hard &&
ensure_not_expanded checkout rename-out-to-out -- deep/deeper1 &&
git -C sparse-index reset --hard &&
- ensure_not_expanded restore -s rename-out-to-out -- deep/deeper1
+ ensure_not_expanded restore -s rename-out-to-out -- deep/deeper1 &&
+
+ echo >>sparse-index/README.md &&
+ ensure_not_expanded add -A &&
+ echo >>sparse-index/extra.txt &&
+ ensure_not_expanded add extra.txt
'
# NEEDSWORK: a sparse-checkout behaves differently from a full checkout