[PATCH 2/2] t1020-subdirectory.sh: check hook pwd, $GIT_PREFIX
- From
- Richard Hansen <rhansen@bbn.com>
- Date
- Jan 10, 2015, 06:49 UTC
- Message-ID
- <1420872598-9609-3-git-send-email-rhansen@bbn.com>
- In-Reply-To
- <1420872598-9609-1-git-send-email-rhansen@bbn.com>
Make sure hooks are executed at the top-level directory and that GIT_PREFIX is set (as documented).
Signed-off-by: Richard Hansen <rhansen@bbn.com> --- t/t1020-subdirectory.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 2edb4f2..03bb0a2 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -128,6 +128,23 @@ test_expect_success !MINGW '!alias expansion' ' test_cmp expect actual ' +test_expect_success 'hook pwd' ' + pwd >expect && + ( + rm -f actual && + mkdir -p .git/hooks && + ! test -e .git/hooks/post-checkout && + cat <<-\EOF >.git/hooks/post-checkout && + #!/bin/sh + pwd >actual + EOF + chmod +x .git/hooks/post-checkout && + (cd dir && git checkout -- two) && + rm -f .git/hooks/post-checkout + ) && + test_cmp expect actual +' + test_expect_success 'GIT_PREFIX for !alias' ' printf "dir/" >expect && ( @@ -154,6 +171,23 @@ test_expect_success 'GIT_PREFIX for built-ins' ' test_cmp expect actual ' +test_expect_success 'GIT_PREFIX for hooks' ' + printf "dir/" >expect && + ( + rm -f actual && + mkdir -p .git/hooks && + ! test -e .git/hooks/post-checkout && + cat <<-\EOF >.git/hooks/post-checkout && + #!/bin/sh + printf %s "$GIT_PREFIX" >actual + EOF + chmod +x .git/hooks/post-checkout && + (cd dir && git checkout -- two) && + rm -f .git/hooks/post-checkout + ) && + test_cmp expect actual +' + test_expect_success 'no file/rev ambiguity check inside .git' ' git commit -a -m 1 && (
-- 2.2.1