From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/5] cache-tree.c::cache_tree_find(): simplify inernal API
Date: Sat, 23 May 2009 12:24:35 -0700 [thread overview]
Message-ID: <1243106678-6343-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1243106678-6343-2-git-send-email-gitster@pobox.com>
Earlier cache_tree_find() needs to be called with a valid cache_tree,
but repeated look-up may find an invalid or missing cache_tree in between.
Help simplify the callers by returning NULL to mean "nothing appropriate
found" when the input is NULL.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
cache-tree.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/cache-tree.c b/cache-tree.c
index 6dd8411..5481e43 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -514,6 +514,8 @@ struct cache_tree *cache_tree_read(const char *buffer, unsigned long size)
static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *path)
{
+ if (!it)
+ return NULL;
while (*path) {
const char *slash;
struct cache_tree_sub *sub;
--
1.6.3.1.145.gb74d77
next prev parent reply other threads:[~2009-05-23 19:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-23 19:24 [PATCH 0/5] Speeding up "git status" and "git diff --cached" Junio C Hamano
2009-05-23 19:24 ` [PATCH 1/5] write-tree --ignore-cache-tree Junio C Hamano
2009-05-23 19:24 ` Junio C Hamano [this message]
2009-05-23 19:24 ` [PATCH 3/5] t4007: modernize the style Junio C Hamano
2009-05-23 19:24 ` [PATCH 4/5] Optimize "diff-index --cached" using cache-tree Junio C Hamano
2009-05-23 19:24 ` [PATCH 5/5] Avoid "diff-index --cached" optimization under --find-copies-harder Junio C Hamano
2009-05-25 10:59 ` [PATCH 0/5] Speeding up "git status" and "git diff --cached" Jeff King
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=1243106678-6343-3-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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).