From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>, John Cai <johncai86@gmail.com>,
Christian Couder <christian.couder@gmail.com>,
Christian Couder <chriscool@tuxfamily.org>
Subject: [PATCH 1/3] revision: clarify a 'return NULL' in get_reference()
Date: Thu, 1 Feb 2024 12:58:07 +0100 [thread overview]
Message-ID: <20240201115809.1177064-2-christian.couder@gmail.com> (raw)
In-Reply-To: <20240201115809.1177064-1-christian.couder@gmail.com>
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(-)
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);
--
2.43.0.496.gd667eb0d7d.dirty
next prev parent reply other threads:[~2024-02-01 11:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 11:58 [PATCH 0/3] rev-list: allow missing tips with --missing Christian Couder
2024-02-01 11:58 ` Christian Couder [this message]
2024-02-01 14:53 ` [PATCH 1/3] revision: clarify a 'return NULL' in get_reference() Eric Sunshine
2024-02-01 16:49 ` Christian Couder
2024-02-01 11:58 ` [PATCH 2/3] t6022: fix 'even though' typo in comment Christian Couder
2024-02-01 11:58 ` [PATCH 3/3] rev-list: add --allow-missing-tips to be used with --missing= Christian Couder
2024-02-01 20:20 ` Junio C Hamano
2024-02-02 11:29 ` Christian Couder
2024-02-02 16:47 ` Junio C Hamano
2024-02-01 21:27 ` Junio C Hamano
2024-02-02 11:29 ` Christian Couder
2024-02-02 16:54 ` Junio C Hamano
2024-02-07 9:57 ` Linus Arver
2024-02-07 16:34 ` Junio C Hamano
2024-02-07 16:38 ` Christian Couder
2024-02-07 9:40 ` Linus Arver
2024-02-07 16:11 ` Christian Couder
2024-02-07 20:48 ` Linus Arver
2024-02-08 15:03 ` Christian Couder
2024-02-08 20:42 ` Linus Arver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240201115809.1177064-2-christian.couder@gmail.com \
--to=christian.couder@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johncai86@gmail.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).