From: Eric Sunshine Date: Sun, 11 Jan 2026 07:53:37 GMT Subject: Re: [PATCH 1/2] t5403:introduce check_post_checkout helper function Message-ID: In-Reply-To: <20260111072950.9463-2-deveshigurgaon@gmail.com> On Sun, Jan 11, 2026 at 2:30 AM Deveshi Dwivedi 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 > --- > 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.