git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 1/6] builtin-checkout.c: check error return from read_cache()
Date: Fri,  5 Dec 2008 17:54:10 -0800	[thread overview]
Message-ID: <1228528455-3089-2-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1228528455-3089-1-git-send-email-gitster@pobox.com>

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-checkout.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/builtin-checkout.c b/builtin-checkout.c
index 7f3bd7b..c2c0561 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -228,7 +228,8 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
 	newfd = hold_locked_index(lock_file, 1);
-	read_cache();
+	if (read_cache() < 0)
+		return error("corrupt index file");
 
 	if (source_tree)
 		read_tree_some(source_tree, pathspec);
@@ -371,7 +372,9 @@ static int merge_working_tree(struct checkout_opts *opts,
 	int ret;
 	struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 	int newfd = hold_locked_index(lock_file, 1);
-	read_cache();
+
+	if (read_cache() < 0)
+		return error("corrupt index file");
 
 	if (opts->force) {
 		ret = reset_tree(new->commit->tree, opts, 1);
-- 
1.6.1.rc1.72.ga5ce6

  reply	other threads:[~2008-12-06  1:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06  1:54 [PATCH 0/6] Reusing "checkout [-m]" logic for "reset --merge" Junio C Hamano
2008-12-06  1:54 ` Junio C Hamano [this message]
2008-12-06  1:54   ` [PATCH 2/6] read-cache.c: typofix in comment Junio C Hamano
2008-12-06  1:54     ` [PATCH 3/6] Make reset_tree() in builtin-checkout.c a bit more library-ish Junio C Hamano
2008-12-06  1:54       ` [PATCH 4/6] builtin-checkout.c: refactor merge_working_tree() Junio C Hamano
2008-12-06  1:54         ` [PATCH 5/6] builtin-commit.c: further refactor branch switching Junio C Hamano
2008-12-06  1:54           ` [PATCH 6/6] builtin-reset.c: use reset_index_and_worktree() Junio C Hamano
2008-12-06  2:08           ` [PATCH 5/6] builtin-commit.c: further refactor branch switching Linus Torvalds

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=1228528455-3089-2-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).