On 2020-09-18 at 14:11:25, Taylor Blau wrote: > Hi Denton, > > On Fri, Sep 18, 2020 at 04:19:03AM -0700, Denton Liu wrote: > > When a user needed the null OID for scripting purposes, it used to be > > very easy: hardcode 40 zeros. However, since Git started supporting > > SHA-256, this assumption became false which may break some scripts. > > Allow users to fix their broken scripts by providing users with a > > hash-agnostic method of obtaining the null OID. > > I have not been very involved in the hash transition, so please take my > comments with a grain of salt (and if they are misplaced, feel free to > ignore them). > > This '--null-oid' thing makes me wonder exactly what it does. Yours > gives a type-less object back, but what about scripts that want the OID > of the empty blob or tree? > > Would having something like '--null-oid[=<type>]' be useful for them? On > the one hand, it seems like a thing that would be useful, but on the > other, those aren't *the* null OID when 'type' is 'blob' or 'tree'. A > more appropriate name in that case might be '--empty-oid=tree'. > > So, that's an argument that '--null-oid' and '--empty-oid[=<type>]' > should be two distinct things. I think I like that best. Do you have any > thoughts about it? So I definitely want to distinguish between the null (all-zeros) OID and the OID of an empty object, and I think using "null" and "empty" are fine. 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. If you still want this option, then that's fine, but please make --null-oid take the same arguments as --show-object-format (and default to the same value). Git will soon learn about writing SHA-1 while storing in SHA-256, and it makes everyone's life better if we can plan for the future by making it understand these options now. 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. -- brian m. carlson: Houston, Texas, US
Attachment:
signature.asc
Description: PGP signature