object-file: move empty_tree struct into find_cached_object()

The fake empty_tree struct is a static global, but the only code that looks at it is find_cached_object(). The struct itself is a little odd, with an invalid "oid" field that is handled specially by that function. Since it's really just an implementation detail, let's move it to a static within the function. That future-proofs against other code trying to use it and seeing the weird oid value. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 18, 2024 at 04:55 UTC b2a95dfd63e812dc4abe5750371f2f0596d2d063
1 file changed +5 -6
object-file.c
+5 -6
@@ -325,14 +325,13 @@ static struct cached_object {
325 } *cached_objects;
326 static int cached_object_nr, cached_object_alloc;
327
328 -static struct cached_object empty_tree = {
329 - /* no oid needed; we'll look it up manually based on the_hash_algo */
330 - .type = OBJ_TREE,
331 - .buf = "",
332 -};
333 -
328 static struct cached_object *find_cached_object(const struct object_id *oid)
329 {
330 + static struct cached_object empty_tree = {
331 + /* no oid needed; we'll look it up manually based on the_hash_algo */
332 + .type = OBJ_TREE,
333 + .buf = "",
334 + };
335 int i;
336 struct cached_object *co = cached_objects;
337