Make sure that the sample hooks do not use any shell features that the shell used to execute them does not support. The documentation at the end of the sample pre-rebase script will never be executed, but "sh -n" does not know that. Convert it to a HERE document to avoid spurious failures. If the shell specified in a hook’s #! line has a space in it, the new test will break it into words, not even taking quoting into account. So #!"c:/Program Files/bin/bash.exe" specifies a shell named ‘"c:/Program’ with argument ‘Files/bin/bash.exe"’. On Unix, that is exactly what exec() would do; on Windows, it is close to what the exec() compatibility layer does (actually, the ‘Files/bin/bash.exe"’ argument is thrown away by parse_interpreter()). To honor quoting during tests would be to set unreasonable expectations for runtime. The user may want to avoid specifying a path to the shell at all, by building with make 'SHELL_PATH=/usr/bin/env bash' The rules used in tests and at runtime on Unix allow this. Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- As before[1], the real motivation is the change to appease sh -n for pre-rebase, since I occasionally run a test like this locally. Patch is against master. Thoughts? [1] http://thread.gmane.org/gmane.comp.version-control.git/145281 t/t0001-init.sh | 18 ++++++++++++++++++ templates/hooks--pre-rebase.sample | 3 +++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 7c0a698..8421b86 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -141,6 +141,24 @@ test_expect_success 'reinit' ' test_cmp again/empty again/err2 ' +test_expect_success 'sample hooks use acceptable syntax' ' + rm -fr hook-syntax && + git init hook-syntax && + ( + cd hook-syntax && + test -d .git/hooks && + fail=f && + for i in .git/hooks/*.sample + do + read shebang <"$i" && + shell=${shebang#"#!"} && + $shell -n $i || + fail=t + done && + test "$fail" = f + ) +' + test_expect_success 'init with --template' ' mkdir template-source && echo content >template-source/file && diff --git a/templates/hooks--pre-rebase.sample b/templates/hooks--pre-rebase.sample index 053f111..6182192 100755 --- a/templates/hooks--pre-rebase.sample +++ b/templates/hooks--pre-rebase.sample @@ -91,6 +91,7 @@ fi exit 0 ################################################################ +: <<\EOF 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.2.rc2.532.g65d9b.dirty -- 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