Re: [PATCH 5/7] sparse-checkout: reject non-cone-mode patterns starting with a '#'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Elijah Newren via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> +	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"));
> +

Whenever I see an error message like this, where it is clear that
the command knows the only viable solution is to the issue, and yet
still refuses to do-what-the-user-clearly-meant-to-do (is there a
valid reason to copy and paste "# comment" line, which clearly is
not about choosing which paths to use/ignore, from an existing file
and feed it to the command?), I question if it should be solved the
opposite way.

That is, to pretend as if "\" + argv[i] was given and then give the
user either a warning saying what we did, or an unsquelcheable advice
message (no need for advice.* config---the user can avoid triggering
it by learning what the advice message would say, which is to use \#
when they mean to give a pattern that begins with a pound).


>  	for (i = 0; i < argc; i++) {
>  		struct cache_entry *ce;
>  		struct index_state *index = the_repository->index;
> diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh
> index 1d95fa47258..32b77415679 100755
> --- a/t/t1091-sparse-checkout-builtin.sh
> +++ b/t/t1091-sparse-checkout-builtin.sh
> @@ -857,4 +857,10 @@ test_expect_success 'by default, non-cone mode will warn on individual files' '
>  	grep "passing directories or less specific patterns is recommended" 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux