From: Junio C Hamano Date: Mon, 26 Feb 2024 17:25:28 GMT Subject: Re: [PATCH 3/3] read_ref_at(): special-case ref@{0} for an empty reflog Message-ID: In-Reply-To: <20240226100803.GC2685600@coredump.intra.peff.net> Jeff King writes: > if (!cb.reccnt) { > + if (cnt == 0) { Style "if (!cnt)" ? In this particular case I do not think it actually is an improvement, though, simply because zero is really special in this logic. > + /* > + * The caller asked for ref@{0}, and we had no entries. > + * It's a bit subtle, but in practice all callers have > + * prepped the "oid" field with the current value of > + * the ref, which is the most reasonable fallback. > + * > + * We'll put dummy values into the out-parameters (so > + * they're not just uninitialized garbage), and the > + * caller can take our return value as a hint that > + * we did not find any such reflog. > + */ > + set_read_ref_cutoffs(&cb, 0, 0, "empty reflog"); > + return 1; > + } The dummy value I 100% agree with ;-). You mentioned the convenience special case for time-based reflog query for a time older than (e.g. @{20.years.ago}) the reflog itself, and perhaps this one should be treated as its counterpart, that is only useful for count-based access.