]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: clarify a 'return NULL' in get_reference()
authorChristian Couder <christian.couder@gmail.com>
Wed, 14 Feb 2024 14:25:10 +0000 (15:25 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Feb 2024 17:38:22 +0000 (09:38 -0800)
When we know a pointer variable is NULL, it's clearer to
explicitly return NULL than to return that variable.

In get_reference(), when 'object' is NULL, we already return NULL
when 'revs->exclude_promisor_objects && is_promisor_object(oid)' is
true, but we return 'object' when 'revs->ignore_missing' is true.

Let's make the code clearer and more uniform by also explicitly
returning NULL when 'revs->ignore_missing' is true.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 2424c9bd674e534909df89e25c21b5eb119fda05..4c5cd7c3ce438cbf559d4122f16f1ec8a21e2837 100644 (file)
@@ -385,7 +385,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,
 
        if (!object) {
                if (revs->ignore_missing)
-                       return object;
+                       return NULL;
                if (revs->exclude_promisor_objects && is_promisor_object(oid))
                        return NULL;
                die("bad object %s", name);