length = strlen(src);
if (lstat(src, &st) < 0) {
- /* only error if existence is expected. */
- if (modes[i] != SPARSE) {
+ int pos;
+ const struct cache_entry *ce;
+
+ pos = cache_name_pos(src, length);
+ if (pos < 0) {
+ /* only error if existence is expected. */
+ if (modes[i] != SPARSE)
+ bad = _("bad source");
+ goto act_on_entry;
+ }
+
+ ce = active_cache[pos];
+ if (!ce_skip_worktree(ce)) {
bad = _("bad source");
goto act_on_entry;
}
+
+ if (!ignore_sparse)
+ string_list_append(&only_match_skip_worktree, src);
+ else
+ modes[i] = SPARSE;
+ goto act_on_entry;
}
if (!strncmp(src, dst, length) &&
(dst[length] == 0 || dst[length] == '/')) {
test_path_is_file sub/folder1/file1
'
-test_expect_failure 'refuse to move out-of-cone file without --sparse' '
+test_expect_success 'refuse to move out-of-cone file without --sparse' '
test_when_finished "cleanup_sparse_checkout" &&
setup_sparse_checkout &&
test_cmp expect stderr
'
-test_expect_failure 'can move out-of-cone file with --sparse' '
+test_expect_success 'can move out-of-cone file with --sparse' '
test_when_finished "cleanup_sparse_checkout" &&
setup_sparse_checkout &&