summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-commit.c
diff options
context:
space:
mode:
authorJonathan Lebon <jlebon@redhat.com>2018-01-09 20:00:24 +0000
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-10 01:42:56 +0000
commit95e574d09b36846e1611b5e89e1caf068b2468c3 (patch)
tree68f0e1f456e7b61c0c876f0a98417cc935852300 /src/ostree/ot-builtin-commit.c
parent2c2e6799bed208306dba600c8a2de813660ffd93 (diff)
downloadostree-95e574d09b36846e1611b5e89e1caf068b2468c3.tar.gz
bin/commit: move parent checking code higher up
No functional change. Prep for the next commit. Closes: #1402 Approved by: cgwalters
Diffstat (limited to 'src/ostree/ot-builtin-commit.c')
-rw-r--r--src/ostree/ot-builtin-commit.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 9c05428e..842d07d1 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -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))