Junio C Hamano <gitster@xxxxxxxxx> 于2021年1月9日周六 上午10:11写道: > > +# Display the pack data contained in the bundle file, bypassing the > > +# header that contains the signature, prerequisites and references. > > +convert_bundle_to_pack () { > > + while read x && test -n "$x" > > + do > > + :; > > + done > > + cat > > +} > > This looks somewhat familiar. Perhaps extract out necessary helpers > including this one into t/test-bundle-lib or something similar in a > preparatory step before this patch? Will add a new helper "t/test-bundle-functions.sh". But as how to include this helper, there are several solutions, which is better? 1. For those scripts which use these shared functions include this helper like: . ./test-lib.sh # current directory changed, so add path prefix . "$TEST_DIRECTORY"/test-bundle-functions.sh 2. Include "test-bundle-functions.sh" in "test-lib.sh" like this: . "$TEST_DIRECTORY/test-lib-functions.sh" . "$TEST_DIRECTORY/test-bundle-functions.sh" 3. Create a "t/test-lib.d/" directory, add add “test-bundle-functions.sh” inside "t/test-lib.d/" as an extension, just like chriscool introduced in sharness project. ----8<----- # test_perf subshells can have them too . "$TEST_DIRECTORY/test-lib-functions.sh" +if test -d "$TEST_DIRECTORY/test-lib.d" +then + for file in "$TEST_DIRECTORY/test-lib.d/"*.sh + do + # Ensure glob was not an empty match: + test -e "${file}" || break + + if test -n "$debug" + then + echo >&5 "test-lib: loading extensions from ${file}" + fi + . "${file}" + if test $? != 0 + then + echo >&5 "test-lib: Error loading ${file}. Aborting." + exit 1 + fi + done +fi + ----->8-----