Skip to content

Commit

Permalink
builtin-checkout.c: check error return from read_cache()
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Dec 8, 2008
1 parent f371d3e commit b96524f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions builtin-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b96524f

Please sign in to comment.