obj = deref_tag(the_repository, obj, NULL, 0);
if (!obj)
die(_("invalid object '%s' given."), name);
- if (obj->type == OBJ_COMMIT)
- obj = &repo_get_commit_tree(the_repository,
- ((struct commit *)obj))->object;
+ if (obj->type == OBJ_COMMIT) {
+ struct tree *tree = repo_get_commit_tree(
+ the_repository, (struct commit *)obj);
+ if (!tree)
+ die(_("unable to read tree object for commit '%s'"), name);
+ obj = &tree->object;
+ }
if (obj->type == OBJ_TREE) {
if (sdiff.skip && bitmap_get(sdiff.skip, i))