Re: [PATCH 1/3] t1006: update 'run_tests' to test generic object specifiers
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 11, 2024, 21:54 UTC
- Message-ID
- <xmqqle6oo2ns.fsf@gitster.g>
- In-Reply-To
- <765d7240311e145b43bbe40f00436f3854a4a177.1710183362.git.gitgitgadget@gmail.com>
"Victoria Dye via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 32 quoted lines
> From: Victoria Dye <vdye@github.com>
>
> 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 <vdye@github.com>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> 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.