@@ -710,6 +710,11 @@ static void sanitize_paths(int argc, const char **argv,
if (skip_checks)
return;
+ if (!core_sparse_checkout_cone)
+ for (i = 0; i < argc; i++)
+ if (argv[i][0] == '#')
+ die(_("paths beginning with a '#' must be preceeded by a backslash"));
+
for (i = 0; i < argc; i++) {
struct cache_entry *ce;
struct index_state *index = the_repository->index;
@@ -853,4 +853,10 @@ test_expect_success 'by default, non-cone mode will warn on individual files' '
grep "pass a leading slash before paths.*if you want a single file" warning
'
+test_expect_success 'paths starting with hash must be escaped in non-cone mode' '
+ test_must_fail git -C repo sparse-checkout set --no-cone "#funny-path" 2>error &&
+
+ grep "paths beginning.*#.*must be preceeded by a backslash" error
+'
+
test_done