Re: [PATCH 1/3] t1006: update 'run_tests' to test generic object specifiers
From: Junio C Hamano <hidden>
Date: 2024-03-11 21:54:21
"Victoria Dye via GitGitGadget" [off-list ref] writes:
quoted hunk
From: Victoria Dye <redacted> 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, '<OID>:<path>', '<OID>^{<type>}', 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 <redacted> Signed-off-by: Johannes Schindelin <redacted> --- 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.