From: Junio C Hamano Date: Mon, 11 Mar 2024 21:54:15 GMT Subject: Re: [PATCH 1/3] t1006: update 'run_tests' to test generic object specifiers Message-ID: In-Reply-To: <765d7240311e145b43bbe40f00436f3854a4a177.1710183362.git.gitgitgadget@gmail.com> "Victoria Dye via GitGitGadget" writes: > From: Victoria Dye > > Update the 'run_tests' test wrapper so that the first argument may refer to > any specifier that uniquely identifies an object (e.g. a ref name, > ':', '^{}', etc.), rather than only a full object ID. > Also, add a test that uses a non-OID identifier, ensuring appropriate > parsing in 'cat-file'. > > Signed-off-by: Victoria Dye > Signed-off-by: Johannes Schindelin > --- > t/t1006-cat-file.sh | 46 +++++++++++++++++++++++---------------------- > 1 file changed, 24 insertions(+), 22 deletions(-) > > diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh > index e0c6482797e..ac1f754ee32 100755 > --- a/t/t1006-cat-file.sh > +++ b/t/t1006-cat-file.sh > @@ -112,65 +112,66 @@ strlen () { > > run_tests () { > type=$1 > - sha1=$2 > + object_name=$2 > + oid=$(git rev-parse --verify $object_name) > size=$3 > content=$4 > pretty_content=$5 > > - batch_output="$sha1 $type $size > + batch_output="$oid $type $size > $content" As "object_name" is now allowed to be any name in the 'extended SHA-1' syntax (cf. Documentation/revisions.txt), you should be a bit more careful in quoting. oid=$(git rev-parse --verify "$object_name") > test_expect_success "$type exists" ' > - git cat-file -e $sha1 > + git cat-file -e $object_name > ' Likewise. You may not currently use a path with SP in it to name a tree object, e.g., "HEAD:Read Me.txt", but protecting against such a pathname is a cheap investment for futureproofing. Looking good otherwise. Thanks.