On 2020-09-20 at 04:25:33, Chris Torek wrote: > On Fri, Sep 18, 2020 at 2:34 PM 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. > > Note that a lot of `grep`s do not have `-q` and/or `-s` so the > portable variant of this is `grep '^0+$' >/dev/null` (you only need > the `2>&1` part if you're concerned about bad input files or > an error on a pipe or something). If we're looking for best compatibility here, then using egrep and /dev/null is best, I agree. I personally use the POSIX version because it's been that way since at least 2001 and I don't have a problem with requiring compliance with a 19-year-old standard. But for Git, we should definitely do whatever we do in the testsuite if we use this approach, since presumably that works everywhere. As Andreas pointed out, there are ways to avoid the external process that we could stuff in a shell function. I'm not picky. > > I'm not sure we need an empty tree and empty blob object, because it's > > pretty easy to write these: > > > > git hash-object -t tree /dev/null > > git hash-object -t blob /dev/null > > > > That's what I've done in some of the transition code at least. > > That's what's recommended in my 2012 stackoverflow Q&A, too. > The use of `/dev/null` directly here is perhaps unsatisfactory on > old Windows systems, though...? I believe all modern versions of Git for Windows provide /dev/null via the shell, since it's required for a lot of things to work, so I'm not worried about this case. It is definitely good to think about Windows, though. -- brian m. carlson: Houston, Texas, US