core: Make --recompose skip passed arguments if they were already composed
This allows us to do "--recompose -b foo bar baz" and add bar and baz iff they weren't already there.
This commit is contained in:
parent
d72d6c5fb1
commit
95d0e94370
|
|
@ -78,6 +78,7 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
OstreeCheckout *checkout = NULL;
|
||||
char *parent = NULL;
|
||||
GFile *destf = NULL;
|
||||
GHashTable *seen_branches = NULL;
|
||||
gboolean compose_metadata_builder_initialized = FALSE;
|
||||
GVariantBuilder compose_metadata_builder;
|
||||
gboolean commit_metadata_builder_initialized = FALSE;
|
||||
|
|
@ -145,6 +146,8 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
g_assert (parent);
|
||||
g_assert (parent_commit);
|
||||
|
||||
seen_branches = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
|
||||
g_variant_get_child (parent_commit, 1, "@a{sv}", &parent_commit_metadata);
|
||||
|
||||
parent_commit_compose = g_variant_lookup_value (parent_commit_metadata,
|
||||
|
|
@ -167,6 +170,8 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
&compose_metadata_builder,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
g_hash_table_insert (seen_branches, g_strdup (branch_name), (char*)branch_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,6 +179,9 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
{
|
||||
const char *src_branch = argv[i];
|
||||
|
||||
if (seen_branches && g_hash_table_lookup (seen_branches, src_branch))
|
||||
continue;
|
||||
|
||||
if (!add_branch (repo, mtree, src_branch,
|
||||
&compose_metadata_builder,
|
||||
error))
|
||||
|
|
@ -239,6 +247,8 @@ ostree_builtin_compose (int argc, char **argv, GFile *repo_path, GError **error)
|
|||
g_free (parent);
|
||||
g_free (contents_checksum);
|
||||
g_free (commit_checksum);
|
||||
if (seen_branches)
|
||||
g_hash_table_destroy (seen_branches);
|
||||
ot_clear_gvariant (&commit_metadata);
|
||||
ot_clear_gvariant (&parent_commit);
|
||||
ot_clear_gvariant (&parent_commit_metadata);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
set -e
|
||||
|
||||
echo "1..6"
|
||||
echo "1..7"
|
||||
|
||||
. libtest.sh
|
||||
|
||||
|
|
@ -91,3 +91,11 @@ $OSTREE checkout some-compose some-compose-checkout
|
|||
cd some-compose-checkout
|
||||
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
||||
echo 'ok recompose'
|
||||
|
||||
cd "${test_tmpdir}"
|
||||
$OSTREE compose --recompose -b some-compose -s 'Recompose' artifact-barapp
|
||||
rm -rf some-compose-checkout
|
||||
$OSTREE checkout some-compose some-compose-checkout
|
||||
cd some-compose-checkout
|
||||
assert_file_has_content ./usr/bin/bar 'updated bar ELF file'
|
||||
echo 'ok recompose with args'
|
||||
|
|
|
|||
Loading…
Reference in New Issue