mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-10 05:18:30 +03:00
bin/commit: move parent checking code higher up
No functional change. Prep for the next commit. Closes: #1402 Approved by: cgwalters
This commit is contained in:
parent
2c2e6799be
commit
95e574d09b
@ -466,6 +466,38 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!(opt_branch || opt_orphan))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"A branch must be specified with --branch, or use --orphan");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (opt_parent)
|
||||
{
|
||||
if (g_str_equal (opt_parent, "none"))
|
||||
parent = NULL;
|
||||
else
|
||||
{
|
||||
if (!ostree_validate_checksum_string (opt_parent, error))
|
||||
goto out;
|
||||
parent = g_strdup (opt_parent);
|
||||
}
|
||||
}
|
||||
else if (!opt_orphan)
|
||||
{
|
||||
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
||||
{
|
||||
if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY))
|
||||
{
|
||||
/* A folder exists with the specified ref name,
|
||||
* which is handled by _ostree_repo_write_ref */
|
||||
g_clear_error (error);
|
||||
}
|
||||
else goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_metadata_strings || opt_metadata_variants)
|
||||
{
|
||||
g_autoptr(GVariantBuilder) builder =
|
||||
@ -493,13 +525,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
detached_metadata = g_variant_ref_sink (g_variant_builder_end (builder));
|
||||
}
|
||||
|
||||
if (!(opt_branch || opt_orphan))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"A branch must be specified with --branch, or use --orphan");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (opt_no_xattrs)
|
||||
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
|
||||
if (opt_consume)
|
||||
@ -543,31 +568,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_parent)
|
||||
{
|
||||
if (g_str_equal (opt_parent, "none"))
|
||||
parent = NULL;
|
||||
else
|
||||
{
|
||||
if (!ostree_validate_checksum_string (opt_parent, error))
|
||||
goto out;
|
||||
parent = g_strdup (opt_parent);
|
||||
}
|
||||
}
|
||||
else if (!opt_orphan)
|
||||
{
|
||||
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
||||
{
|
||||
if (g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY))
|
||||
{
|
||||
/* A folder exists with the specified ref name,
|
||||
* which is handled by _ostree_repo_write_ref */
|
||||
g_clear_error (error);
|
||||
}
|
||||
else goto out;
|
||||
}
|
||||
}
|
||||
|
||||
if (opt_editor)
|
||||
{
|
||||
if (!commit_editor (repo, opt_branch, &opt_subject, &commit_body, cancellable, error))
|
||||
|
Loading…
Reference in New Issue
Block a user