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

Re: [PATCH 1/2] t5403:introduce check_post_checkout helper function

From
Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Date
Jan 11, 2026, 11:01 UTC
Message-ID
<CALE2CrSHocR-p_zVS8CihtJRpR6Fd72JTy1-KJ7L9iMMubp0sA@mail.gmail.com>
In-Reply-To
<CAPig+cQgF2yHL40OnOB=SWMHCv+z0hLTAwTD8q18-DGPHO48cg@mail.gmail.com>
I agree with Eric’s point about documenting the helper’s arguments.

Since patch 2 also changes the hook output format to a structured "old=… new=… flag=…" layout that "check_post_checkout()" depends on, it would be especially helpful if the function comment spelled out both the meaning of the four parameters and the expected on-disk format of the args file.

That would make the helper’s contract much clearer to future readers and reduce the risk of accidental breakage if the hook output changes.

On Sun, Jan 11, 2026 at 1:23 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 28 quoted lines
>
> On Sun, Jan 11, 2026 at 2:30 AM Deveshi Dwivedi
> <deveshigurgaon@gmail.com> wrote:
> > The test file repeatedly uses the same four-line pattern to validate
> > post-checkout hook arguments: read the args file, then test each of
> > the three values individually.
> >
> > Introduce a check_post_checkout helper function that encapsulates this
> > pattern. This patch does not change test behavior; it prepares the
> > code for improvement in the next step.
> >
> > Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
> > ---
> > diff --git a/t/t5403-post-checkout-hook.sh b/t/t5403-post-checkout-hook.sh
> > @@ -9,6 +9,13 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> > +# Helper function to check post-checkout hook arguments
> > +check_post_checkout () {
> > +       test "$#" = 4 || BUG "check_post_checkout takes 4 args"
> > +       read old new flag <"$1" &&
> > +       test "$old" = "$2" && test "$new" = "$3" && test "$flag" = "$4"
> > +}
>
> Rather than forcing people to read the function body to divine the
> purpose of the four arguments, the function comment should spell out
> their meaning. See the many "Usage:" comments in
> t/test-lib-functions.sh for examples of how to write more useful
> function documentation.
>
Previous: Eric SunshineNext: Deveshi Dwivedi
Message 4 of 14 in “t5403: improve post-checkout hook testing”
  1. 0/2 t5403: improve post-checkout hook testingDeveshi Dwivedi, Jan 11, 2026
  2. 1/2 t5403:introduce check_post_checkout helper functionDeveshi Dwivedi, Jan 11, 2026
  3. Eric SunshineJan 11, 2026
  4. Pushkar SinghJan 11, 2026
  5. Deveshi DwivediJan 12, 2026
  6. t5403: document check_post_checkout helperPushkar Singh, Jan 11, 2026
  7. 2/2 t5403: use test_cmp for post-checkout argument checksDeveshi Dwivedi, Jan 11, 2026
  8. 0/2 t5403: improve post-checkout hook testingDeveshi Dwivedi, Jan 12, 2026
  9. 1/2 t5403:introduce check_post_checkout helper functionDeveshi Dwivedi, Jan 12, 2026
  10. Junio C HamanoJan 12, 2026
  11. 2/2 t5403: use test_cmp for post-checkout argument checksDeveshi Dwivedi, Jan 12, 2026
  12. 0/2 t5403: improve post-checkout hook testingDeveshi Dwivedi, Jan 12, 2026
  13. 1/2 t5403:introduce check_post_checkout helper functionDeveshi Dwivedi, Jan 12, 2026
  14. 2/2 t5403: use test_cmp for post-checkout argument checksDeveshi Dwivedi, Jan 12, 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.