Subject: Re: [RTC/PATCH] Add 'update-branch' hook

From: Ilya Bobyr <[email-masked]>
Date: Mon, 21 Apr 2014 14:36:47 -0700

On 4/21/2014 2:15 PM, Felipe Contreras wrote:
> Ilya Bobyr wrote:
>> On 4/20/2014 7:23 PM, Felipe Contreras wrote:
>>> [...]
>>>
>>> diff --git a/t/t5408-update-branch-hook.sh b/t/t5408-update-branch-hook.sh
>>> new file mode 100755
>>> index 0000000..d921c0e
>>> --- /dev/null
>>> +++ b/t/t5408-update-branch-hook.sh
>>> @@ -0,0 +1,39 @@
>>> +#!/bin/sh
>>> +
>>> +test_description='Test the update-branch hook'
>>> +
>>> +. ./test-lib.sh
>>> +
>>> +setup () {
>>> +	mkdir -p .git/hooks &&
>>> +	cat > .git/hooks/update-branch <<-'EOF' &&
>>> +	#!/bin/sh
>>> +	echo $@ > .git/update-branch.args
>>> +	EOF
>>> +	chmod +x .git/hooks/update-branch &&
>>> +	echo one > content &&
>>> +	git add content &&
>>> +	git commit -a -m one
>>> +}
>>> +
>>> +setup
>> According to t/README `setup` should be inside an assertion just as any
>> other test:
> I have a bunch of 'setup' calls outside such assertions already in other test
> scripts. If you know how to put single quotes inside of single quotes in a
> shell script, please share that knowledge, otherwise the setup must be outside.
>
> Of course we could do the extremely reduntant:
>
> test_expect_success 'setup' '
>   setup
> '

Setup does not look any different from the other tests.
If you need single quotes you could use double quotes outside.  Though,
you would have to quote other things as well.
t0000-basic.sh has a lot of tests that do that.
Like this, for example:

test_expect_success 'setup' "
	mkdir -p .git/hooks &&
	cat > .git/hooks/update-branch <<-\\EOF &&
	#!/bin/sh
	echo \$@ > .git/update-branch.args
	EOF
	chmod +x .git/hooks/update-branch &&
	echo one > content &&
	git add content &&
	git commit -a -m one
"