Subject: Re: [PATCH 2/4] builtin/rev-parse: learn --null-oid

From: Andreas Schwab <[email-masked]>
Date: Sun, 20 Sep 2020 18:03:24 +0200

On Sep 18 2020, brian m. carlson wrote:

> What I typically do when I write shell scripts, and which may obviate
> the need for this patch is turn this:
>
>   [ "$oid" = 0000000000000000000000000000000000000000 ]
>
> into this:
>
>   echo "$oid" | grep -qsE '^0+$'
>
> This is slightly less efficient, but it's also backwards compatible
> with older Git version assuming you have a POSIX grep.

You can also use

  case $oid in *[1-9a-f]*) ... ;; *) ... ;; esac

which doesn't need an external process.

Andreas.

-- 
Andreas Schwab, [email-masked]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."