diff --git a/src/app/rpmostree-compose-builtin-tree.c b/src/app/rpmostree-compose-builtin-tree.c index a2b6131155..fd27a0dedb 100644 --- a/src/app/rpmostree-compose-builtin-tree.c +++ b/src/app/rpmostree-compose-builtin-tree.c @@ -69,6 +69,7 @@ static gboolean opt_dry_run; static gboolean opt_print_only; static char *opt_write_commitid_to; static char *opt_write_composejson_to; +static gboolean opt_no_parent; /* shared by both install & commit */ static GOptionEntry common_option_entries[] = { @@ -103,6 +104,7 @@ static GOptionEntry commit_option_entries[] = { { "add-metadata-from-json", 0, 0, G_OPTION_ARG_STRING, &opt_metadata_json, "Parse the given JSON file as object, convert to GVariant, append to OSTree commit", "JSON" }, { "write-commitid-to", 0, 0, G_OPTION_ARG_STRING, &opt_write_commitid_to, "File to write the composed commitid to instead of updating the ref", "FILE" }, { "write-composejson-to", 0, 0, G_OPTION_ARG_STRING, &opt_write_composejson_to, "Write JSON to FILE containing information about the compose run", "FILE" }, + { "no-parent", 0, 0, G_OPTION_ARG_NONE, &opt_no_parent, "Always commit without a parent", NULL }, { NULL } }; @@ -1002,7 +1004,7 @@ impl_commit_tree (RpmOstreeTreeComposeContext *self, } g_autofree char *parent_revision = NULL; - if (self->ref) + if (self->ref && !opt_no_parent) { if (!ostree_repo_resolve_rev (self->repo, self->ref, TRUE, &parent_revision, error)) return FALSE; diff --git a/tests/compose-tests/test-basic-unified.sh b/tests/compose-tests/test-basic-unified.sh index 81d43f1915..b97bca34a2 100755 --- a/tests/compose-tests/test-basic-unified.sh +++ b/tests/compose-tests/test-basic-unified.sh @@ -63,10 +63,15 @@ fi rm ${co} -rf echo "ok no cachedir zero-sized hardlinks" -# And redo it to trigger relabeling +# And redo it to trigger relabeling. Also test --no-parent at the same time. origrev=$(ostree --repo=${repobuild} rev-parse ${treeref}) -runcompose --force-nocache --ex-unified-core +runcompose --force-nocache --ex-unified-core --no-parent newrev=$(ostree --repo=${repobuild} rev-parse ${treeref}) assert_not_streq "${origrev}" "${newrev}" - echo "ok rerun" + +# And check that --no-parent worked. +if ostree rev-parse ${newrev}^; then + assert_not_reached "New revision has a parent even with --no-parent?" +fi +echo "ok --no-parent" diff --git a/tests/compose-tests/test-basic.sh b/tests/compose-tests/test-basic.sh index fe354f8066..5289777019 100755 --- a/tests/compose-tests/test-basic.sh +++ b/tests/compose-tests/test-basic.sh @@ -44,3 +44,8 @@ EOF export treefile=$treefile.yaml runcompose echo "ok yaml" + +# also check that --no-parent doesn't invalidate change detection +runcompose --no-parent |& tee out.txt +assert_file_has_content_literal out.txt "No apparent changes since previous commit" +echo "ok --no-parent"