On Tue, Sep 27, 2016 at 11:23:24AM -0400, David Turner wrote:

> +test_expect_success 'malformed mode in tree' '
> +     hex_sha1=$(echo foo | git hash-object --stdin -w) &&
> +     bin_sha1=$(echo $hex_sha1 | perl -ne "printf \"\\\\%03o\", ord for 
> /../g") &&

Sorry, the perl snippet I posted earlier was totally braindead. It gives
you the octal for the raw bytes, but we really just want to convert the
hex to octal (we could also print the raw bytes from the hex, but I
didn't want to take chances on shells that can't handle NULs in
environment variables).

I also find it helps to define a helper function outside of the test
block to avoid quoting hell. So something like:

  hex2oct () {
        perl -ne 'printf "\\%03o", hex for /../g'

  test_expect_success ... '
        bin_sha1=$(echo $hex_sha1 | hex2oct)


Reply via email to