Web lists-archives.com

Re: [PATCH 05/10] t0064: make hash size independent




On Mon, Jun 4, 2018 at 7:52 PM, brian m. carlson
<sandals@xxxxxxxxxxxxxxxxxxxx> wrote:
> Compute test values of the appropriate size instead of hard-coding
> 40-character values.  Rename the echo20 function to echoid, since the
> values may be of varying sizes.
>
> Signed-off-by: brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx>
> ---
> diff --git a/t/t0064-sha1-array.sh b/t/t0064-sha1-array.sh
> @@ -3,30 +3,30 @@
> -echo20 () {
> +echoid () {
>         prefix="${1:+$1 }"
>         shift
>         while test $# -gt 0
>         do
> -               echo "$prefix$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1$1"
> +               echo "$prefix$ZERO_OID" | sed -e "s/00/$1/g"
>                 shift
>         done
>  }
>
>
>  test_expect_success 'lookup with almost duplicate values' '
> +       # n-1 5s
> +       root=$(test_translate 555555555555555555555555555555555555555 \
> +               555555555555555555555555555555555555555555555555555555555555555) &&

This is rather unwieldy and ugly. How about simply re-using echoid()
to compute the value, like this:

    root=$(echoid "" 55) &&
    root=${root%5} &&

That is, use echoid() to generate the all-5's OID of correct length
and then chop the last '5' off the end.

>         {
> -               echo "append 5555555555555555555555555555555555555555" &&
> -               echo "append 555555555555555555555555555555555555555f" &&
> -               echo20 lookup 55
> +               id1="${root}5" &&
> +               id2="${root}f" &&
> +               echo "append $id1" &&
> +               echo "append $id2" &&
> +               echoid lookup 55