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

2018-06-11 Thread brian m. carlson
On Mon, Jun 11, 2018 at 04:09:05AM -0400, Eric Sunshine wrote:
> On Mon, Jun 4, 2018 at 7:52 PM, brian m. carlson
>  wrote:
> >  test_expect_success 'lookup with almost duplicate values' '
> > +   # n-1 5s
> > +   root=$(test_translate 555 \
> > +   
> > 555) &&
> 
> 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.

Sure, that would be nicer.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204


signature.asc
Description: PGP signature


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

2018-06-11 Thread Eric Sunshine
On Mon, Jun 4, 2018 at 7:52 PM, brian m. carlson
 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 
> ---
> 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 555 \
> +   
> 555) &&

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 " &&
> -   echo "append 555f" &&
> -   echo20 lookup 55
> +   id1="${root}5" &&
> +   id2="${root}f" &&
> +   echo "append $id1" &&
> +   echo "append $id2" &&
> +   echoid lookup 55