From: Junio C Hamano <gitster@pobox.com>
To: Richard Hansen <rhansen@bbn.com>
Cc: j6t@kdbg.org, git@vger.kernel.org
Subject: Re: [PATCH v2 2/2] t1020-subdirectory.sh: check hook pwd, $GIT_PREFIX
Date: Mon, 12 Jan 2015 14:38:23 -0800 [thread overview]
Message-ID: <xmqq4mrv7hgg.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1420931503-22857-3-git-send-email-rhansen@bbn.com> (Richard Hansen's message of "Sat, 10 Jan 2015 18:11:43 -0500")
Richard Hansen <rhansen@bbn.com> writes:
> Make sure hooks are executed at the top-level directory and that
> GIT_PREFIX is set (as documented).
The same comment as the one for 1/2 applies here. If we substitute
'hook' everywhere with 'post-checkout hook' in this patch, it makes
perfect sense to me, but otherwise this is far from "check _hook_"
in general.
> Signed-off-by: Richard Hansen <rhansen@bbn.com>
> ---
> t/t1020-subdirectory.sh | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
> index 2edb4f2..0ccbb7e 100755
> --- a/t/t1020-subdirectory.sh
> +++ b/t/t1020-subdirectory.sh
> @@ -128,6 +128,17 @@ test_expect_success !MINGW '!alias expansion' '
> test_cmp expect actual
> '
>
> +test_expect_success 'hook pwd' '
> + rm -f actual &&
> + mkdir -p .git/hooks &&
> + write_script .git/hooks/post-checkout <<-\EOF &&
> + pwd >actual
> + EOF
> + test_when_finished "rm -f .git/hooks/post-checkout actual" &&
> + (cd dir && git checkout -- two) &&
> + test_path_is_file actual
Cute, but it is misleading to use "pwd" there, because the contents
of the file does not matter for this test, even though the test is
about the current directory. It forces the reader to look for the
place where you are comparing the contents of that file with
expected path to the current directory, and no such code exists.
"date >actual", "echo >actual", or even just a redirection without
command, i.e. ">actual", woudl have been easier to see what is going
on (I would have used the last form if I were doing this patch).
> +'
> +
> test_expect_success 'GIT_PREFIX for !alias' '
> printf "dir/" >expect &&
> (
> @@ -154,6 +165,18 @@ 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 &&
> + write_script .git/hooks/post-checkout <<-\EOF &&
> + printf %s "$GIT_PREFIX" >actual
> + EOF
> + test_when_finished "rm -f .git/hooks/post-checkout expect actual" &&
> + (cd dir && git checkout -- two) &&
> + test_cmp expect actual
> +'
It is not wrong per-se, but the same cute trick could have been
used, i.e.
write_script ... post-checkout <<-\EOF &&
>"$GIT_PREFIX/actual"
EOF
...
test_path_is_file dir/actual
> +
> test_expect_success 'no file/rev ambiguity check inside .git' '
> git commit -a -m 1 &&
> (
prev parent reply other threads:[~2015-01-12 22:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-10 6:49 [PATCH 0/2] Documentation/githooks: mention pwd, $GIT_PREFIX Richard Hansen
2015-01-10 6:49 ` [PATCH 1/2] " Richard Hansen
2015-01-10 6:49 ` [PATCH 2/2] t1020-subdirectory.sh: check hook " Richard Hansen
2015-01-10 8:25 ` Johannes Sixt
2015-01-10 23:11 ` [PATCH v2 0/2] Documentation/githooks: mention " Richard Hansen
2015-01-10 23:11 ` [PATCH v2 1/2] " Richard Hansen
2015-01-12 19:56 ` Junio C Hamano
2015-01-10 23:11 ` [PATCH v2 2/2] t1020-subdirectory.sh: check hook " Richard Hansen
2015-01-12 22:38 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4mrv7hgg.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=rhansen@bbn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.