Re: [PATCH] t0001: check syntax of sample hooks

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

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> diff --git a/t/t0001-init.sh b/t/t0001-init.sh
> index 6757734..3e6e1ed 100755
> --- a/t/t0001-init.sh
> +++ b/t/t0001-init.sh
> @@ -141,6 +141,21 @@ test_expect_success 'reinit' '
>  	test_cmp again/empty again/err2
>  '
>  
> +test_expect_success 'sample hooks use acceptable syntax' '
> +	mkdir boring &&
> +	git init boring &&
> +	test -d boring/.git/hooks &&
> +	fail=f &&
> +	for i in boring/.git/hooks/*.sample
> +	do
> +		read shebang <"$i" &&
> +		shell=${shebang#"#!"} &&
> +		$shell -n "$i" ||

"#!/Program  Files/bin/shell"???

I think, after observing what this outputs,

    $ echo 'a  b c' | (read shebang; echo "<$shebang>")

you would need something like this:

	shell=$(sed -e '1{
        	s/^#!//p
                q
	}' "$i") &&
        "$shell" -n "$i"

> diff --git a/templates/hooks--pre-rebase.sample b/templates/hooks--pre-rebase.sample
> index 053f111..22a9f07 100755
> --- a/templates/hooks--pre-rebase.sample
> +++ b/templates/hooks--pre-rebase.sample
> @@ -91,6 +91,7 @@ fi
>  exit 0
>  
>  ################################################################
> +cat <<\EOF

No need to meow here; just say ":" instead.

>  This sample hook safeguards topic branches that have been
>  published from being rewound.
> @@ -167,3 +168,5 @@ To compute (2):
>  	git rev-list master..topic
>  
>  	if this is empty, it is fully merged to "master".
> +
> +EOF
> -- 
> 1.7.1.rc1
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]