From 0501e1569c94becdf3196926dcd2c233e7c18dbf Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 27 Sep 2016 12:39:44 +0200 Subject: [PATCH] commit-from: Add "xa.commit-from" to the destination metadata This is nice because it guarantees that we get a new commit id which fixes various issues we had with conflicting commit ids overriding each others signatures. --- app/flatpak-builtins-build-commit-from.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/flatpak-builtins-build-commit-from.c b/app/flatpak-builtins-build-commit-from.c index a1688087..3bec363c 100644 --- a/app/flatpak-builtins-build-commit-from.c +++ b/app/flatpak-builtins-build-commit-from.c @@ -228,6 +228,7 @@ flatpak_builtin_build_commit_from (int argc, char **argv, GCancellable *cancella const char *subject; const char *body; g_autofree char *commit_checksum = NULL; + GVariantBuilder metadata_builder; if (!ostree_repo_resolve_rev (dst_repo, dst_ref, TRUE, &dst_parent, error)) return FALSE; @@ -269,7 +270,13 @@ flatpak_builtin_build_commit_from (int argc, char **argv, GCancellable *cancella if (opt_body) body = (const char *)opt_body; - if (!ostree_repo_write_commit_with_time (dst_repo, dst_parent, subject, body, commitv_metadata, + flatpak_variant_builder_init_from_variant (&metadata_builder, "a{sv}", commitv_metadata); + /* Additionally record the source commit. This is nice to have, but it also means + the commit-from gets a different commit id, which avoids problems with e.g. + sharing .commitmeta files (signatures) */ + g_variant_builder_add (&metadata_builder, "{sv}", "xa.from_commit", g_variant_new_string (resolved_ref)); + + if (!ostree_repo_write_commit_with_time (dst_repo, dst_parent, subject, body, g_variant_builder_end (&metadata_builder), OSTREE_REPO_FILE (dst_root), ostree_commit_get_timestamp (src_commitv), &commit_checksum, cancellable, error))