aboutsummaryrefslogtreecommitdiffstats
path: root/reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'reset.c')
-rw-r--r--reset.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/reset.c b/reset.c
index 0f2ff0fe31..d619cb7115 100644
--- a/reset.c
+++ b/reset.c
@@ -157,6 +157,11 @@ int reset_head(struct repository *r, const struct reset_head_opts *opts)
}
tree = parse_tree_indirect(oid);
+ if (!tree) {
+ ret = error(_("unable to read tree (%s)"), oid_to_hex(oid));
+ goto leave_reset_head;
+ }
+
prime_cache_tree(r, r->index, tree);
if (write_locked_index(r->index, &lock, COMMIT_LOCK) < 0) {