Re: [PATCH v8 7/8] cache: add empty_tree_oid object
- From
Jacob Keller <jacob.keller@gmail.com>
- Date
- Aug 19, 2016, 20:35 UTC
- Message-ID
- <CA+P7+xp6VDdMnh-srDzToSwh3mZrQei+B8DjpB2N6OkqAuARkw@mail.gmail.com>
- In-Reply-To
- <xmqqfuq01oww.fsf@gitster.mtv.corp.google.com>
On Fri, Aug 19, 2016 at 1:31 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 15 quoted lines
> Jacob Keller <jacob.e.keller@intel.com> writes: > >> From: Jacob Keller <jacob.keller@gmail.com> >> >> Add an empty_tree_oid object which can be used in place of >> EMPTY_TREE_SHA1_BIN_LITERAL for code which is being converted to struct >> object_id. > > How widely do you envision the users of this symbol would be spread > across the entire codebase? I am debating myself if we need a > singleton in-core copy like this (if we end up referring to it from > everywhere), or we only need one level higher abstraction, > e.g. "is_empty_tree_oid()" helper (in which case I do not think we > even need a singleton; just imitate how is_empty_blob_sha1() is > implemented).
If I do this, I'd also add an "is_empty_tree_sha1()" as well?
> > Even if we need such a singleton, I think we avoid ".field = value" > struct initializations in our code. >
Is there a reason for that? I've found that .field = value is safer because it ensures that you don't end up initializing the wrong values? Or is it a compatibility thing?
Thanks, Jake