add: warn when asked to update SKIP_WORKTREE entries
`git add` already refrains from updating SKIP_WORKTREE entries, but it
silently exits with zero code when it is asked to do so. Instead, let's
warn the user and display a hint on how to update these entries.
Note that we only warn the user whey they give a pathspec item that
matches no eligible path for updating, but it does match one or more
SKIP_WORKTREE entries. A warning was chosen over erroring out right away
to reproduce the same behavior `add` already exhibits with ignored
files. This also allow users to continue their workflow without having
to invoke `add` again with only the eligible paths (as those will have
already been added).
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Matheus Tavares4 years agocommitted byJunio C Hamano
test_expect_success 'git add does not remove sparse entries' '
setup_sparse_entry &&
rm sparse_entry &&
git add sparse_entry &&
test_must_fail git add sparse_entry 2>stderr &&
test_cmp error_and_hint stderr &&
test_sparse_entry_unchanged
'
@ -47,7 +63,8 @@ test_expect_success 'git add -A does not remove sparse entries' '
@@ -47,7 +63,8 @@ test_expect_success 'git add -A does not remove sparse entries' '
setup_sparse_entry &&
rm sparse_entry &&
setup_gitignore &&
git add -A &&
git add -A 2>stderr &&
test_must_be_empty stderr &&
test_sparse_entry_unchanged
'
@ -55,7 +72,13 @@ test_expect_success 'git add . does not remove sparse entries' '
@@ -55,7 +72,13 @@ test_expect_success 'git add . does not remove sparse entries' '
setup_sparse_entry &&
rm sparse_entry &&
setup_gitignore &&
git add . &&
test_must_fail git add . 2>stderr &&
cat sparse_error_header >expect &&
echo . >>expect &&
cat sparse_hint >>expect &&
test_cmp expect stderr &&
test_sparse_entry_unchanged
'
@ -64,7 +87,8 @@ do
@@ -64,7 +87,8 @@ do
test_expect_success "git add${opt:+ $opt} does not update sparse entries" '