Re: [PATCH 05/10] t0064: make hash size independent
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jun 11, 2018, 08:09 UTC
- Message-ID
- <CAPig+cTm4BYZjsFSV8AZ-jMjVPtze5H_7XUG1wBhmuFghJbc=g@mail.gmail.com>
- In-Reply-To
- <20180604235229.279814-6-sandals@crustytoothpaste.net>
On Mon, Jun 4, 2018 at 7:52 PM, brian m. carlson <sandals@crustytoothpaste.net> wrote:
Show 25 quoted lines
> 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@crustytoothpaste.net>
> ---
> 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.
Show 9 quoted lines
> {
> - echo "append 5555555555555555555555555555555555555555" &&
> - echo "append 555555555555555555555555555555555555555f" &&
> - echo20 lookup 55
> + id1="${root}5" &&
> + id2="${root}f" &&
> + echo "append $id1" &&
> + echo "append $id2" &&
> + echoid lookup 55