diff mbox series

[1/3] revision: clarify a 'return NULL' in get_reference()

Message ID 20240201115809.1177064-2-christian.couder@gmail.com (mailing list archive)
State Superseded
Headers show
Series rev-list: allow missing tips with --missing | expand

Commit Message

Christian Couder Feb. 1, 2024, 11:58 a.m. UTC
In general when we know a pointer variable is NULL, it's clearer to
explicitely 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 explicitely
returning NULL when 'revs->ignore_missing' is true.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 revision.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Sunshine Feb. 1, 2024, 2:53 p.m. UTC | #1
On Thu, Feb 1, 2024 at 6:58 AM Christian Couder
<christian.couder@gmail.com> wrote:
> In general when we know a pointer variable is NULL, it's clearer to
> explicitely return NULL than to return that variable.

s/explicitely/explicitly/

> 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 explicitely
> returning NULL when 'revs->ignore_missing' is true.

s/explicitely/explicitly/

> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder Feb. 1, 2024, 4:49 p.m. UTC | #2
On Thu, Feb 1, 2024 at 3:53 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Thu, Feb 1, 2024 at 6:58 AM Christian Couder
> <christian.couder@gmail.com> wrote:
> > In general when we know a pointer variable is NULL, it's clearer to
> > explicitely return NULL than to return that variable.
>
> s/explicitely/explicitly/

[...]

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

Thanks, it's fixed in my current version. Not sure I have to resend
just to fix this though.
diff mbox series

Patch

diff --git a/revision.c b/revision.c
index 2424c9bd67..4c5cd7c3ce 100644
--- a/revision.c
+++ b/revision.c
@@ -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);