Re: [PATCH v5 3/3] completion: handle unusual characters for sparse-checkout

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

 



"Lessley Dennington via GitGitGadget" <gitgitgadget@xxxxxxxxx>
writes:

> +test_expect_success FUNNYNAMES 'cone mode sparse-checkout completes directory names with special characters' '
> +	# reset sparse-checkout
> +	git -C sparse-checkout sparse-checkout disable &&
> +	(
> +		cd sparse-checkout &&
> +		mkdir "directory with spaces" &&
> +		mkdir "$(printf "directory\twith\ttabs")" &&
> +		mkdir "directory\with\backslashes" &&
> +		mkdir "directory-with-áccent" &&
> +		>"directory with spaces/randomfile" &&
> +		>"$(printf "directory\twith\ttabs")/randomfile" &&
> +		>"directory\with\backslashes/randomfile" &&
> +		>"directory-with-áccent/randomfile" &&
> +		git add . &&
> +		git commit -m "Add directories containing unusual characters" &&
> +		git sparse-checkout set --cone "directory with spaces" \
> +			"$(printf "directory\twith\ttabs")" "directory\with\backslashes" \
> +			"directory-with-áccent" &&
> +		test_completion "git sparse-checkout add dir" <<-\EOF
> +		directory with spaces/
> +		directory	with	tabs/
> +		directory\with\backslashes/
> +		directory-with-áccent/
> +		EOF
> +	)
> +'

I wonder if we care about the repetition, which can burden anybody
who will later have to change this script.  "directory with spaces"
appears three times in the above (i.e. mkdir uses it, then redirection
to create a file under it uses it, and "sparse-checkout set" uses it,
and then finally the expected output has it.

An obvious way to reduce repetition is to add variables for them,
and because this is in a subshell, we do not have to worry about the
use of extra variables contaminating the namespace for later tests.

	D1="directory with spaces" &&
	D2=$(printf "directory\t\with\ttabs") &&
	D3="directory\with\backslashes" &&
        D4="directory-with-áccent" &&
	for D in "$D1" "$D2" "$D3" "$D4"
	do
		>"$D/samplefile" || return 1
	done &&
	git add . &&
	git commit -m "add many" &&
	git sparse-checkout set --cone "$D1" "$D2" "$D3" "$D4" &&
	test_completion "git sparse-checkout add dir" <<-EOF
	$D1/
	$D2/
	$D3/
	$D4/
	EOF

Having written it, I am undecided.  It does reduce repetition, and
it does reduce the chance to make typo, but did I make it easier to
follow?  I am not sure about the last part.

Thanks.




[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