git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] [GSoC] t5403: use test_path_is_file instead of test -f

From
Deveshi Dwivedi <deveshigurgaon@gmail.com>
Date
Jan 5, 2026, 05:58 UTC
Message-ID
<CAG7UgEQeOJq0S87btjy8TT9as10bCAJWKEUTfNafa811iM8qwA@mail.gmail.com>
In-Reply-To
<xmqqjyy2dvni.fsf@gitster.g>
Show 13 quoted lines
> > Replace 'test -f' with the test_path_is_file in
> > t5403-post-checkout-hook.sh. This helper provides better error
> > messages when tests fail, making it easier to debug issues.
>
> All true, so I'll queue the patch.  Thanks.
>
> A #leftoverbit is to think about what this test checks, if it
> makes sense, and if we can do better.  The expected outcome of this
> clone is stable, so the input fed to the hook should also be stable.
> With the same brain-cycle to write a test that checks the existence
> of the output file (i.e., proving that the hook was run), we should
> be able to concoct a test that validates the contents of the output.
>

Hi Junio, thanks for the feedback and suggestion! I read in githooks.adoc that for clone, the post-checkout hook gets the null-ref as the first parameter, the new HEAD as second, and flag=1 as third. Looking at the other tests in t5403, they read the three arguments from post-checkout.args and then validate them.

I can update the clone test to follow the same pattern as the other tests: read old new flag <clone3/.git/post-checkout.args && test "$old" = $(test_oid zero) && test "$new" = $(git rev-parse HEAD) && test "$flag" = 1

Does this sound reasonable?

Thanks, Deveshi

Show 18 quoted lines
> > Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
> > ---
> >  t/t5403-post-checkout-hook.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
> > index 978f240cda..1462e3365b 100755
> > --- a/t/t5403-post-checkout-hook.sh
> > +++ b/t/t5403-post-checkout-hook.sh
> > @@ -109,7 +109,7 @@ test_expect_success 'post-checkout hook is triggered by clone' '
> >       echo "$@" >"$GIT_DIR/post-checkout.args"
> >       EOF
> >       git clone --template=templates . clone3 &&
> > -     test -f clone3/.git/post-checkout.args
> > +     test_path_is_file clone3/.git/post-checkout.args
> >  '
> >
> >  test_done
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “[GSoC] t5403: use test_path_is_file instead of test -f”
  1. [GSoC] t5403: use test_path_is_file instead of test -fDeveshi Dwivedi, Dec 29, 2025
  2. Junio C HamanoJan 1, 2026
  3. Deveshi DwivediJan 5, 2026
  4. Junio C HamanoJan 5, 2026
  5. Deveshi DwivediJan 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.