Thread (19 messages) 19 messages, 5 authors, 2020-09-23

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

From: Taylor Blau <hidden>
Date: 2020-09-20 15:35:44

On Fri, Sep 18, 2020 at 09:26:09PM +0000, 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.
Yeah, I mostly just have no idea how common this is in the wild. If many
scripts care about the null OID, then a '--null-oid' makes sense to me.
But if it's only a few, then it does not.
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.
Agreed.
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.
I could go either way. This for some reason seems more common to me, so
I wouldn't mind making it easier for callers, but I don't care so much
because what you already wrote is easy enough as-is.
--
brian m. carlson: Houston, Texas, US
Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help