core: Error out cleanly if user attempts to commit an empty tree

This commit is contained in:
Colin Walters committed 2012-01-05 18:27:21 -05:00
1 parent 5b0084994e
commit 5c3614d644
1 file changed
+10 -1
+10 -1
View File
@@ -264,8 +264,17 @@ ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
if (!skip_commit)
{
const char *root_metadata = ostree_mutable_tree_get_metadata_checksum (mtree);
if (!root_metadata)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Can't commit an empty tree");
goto out;
}
if (!ostree_repo_stage_commit (repo, branch, parent, subject, body, metadata,
contents_checksum, ostree_mutable_tree_get_metadata_checksum (mtree),
contents_checksum, root_metadata,
&commit_checksum, cancellable, error))
goto out;