builtin-commit: Don't parse the parent's GVariant by hand
Instead, use OstreeRepoFile as a handle for the parent commit. We need to add an accessor for the metadata checksum, as that hasn't been exposed before. https://bugzilla.gnome.org/show_bug.cgi?id=707727
This commit is contained in:
parent
8ac0f99ed6
commit
f49ed9e74d
|
|
@ -362,6 +362,12 @@ ostree_repo_file_tree_get_contents_checksum (OstreeRepoFile *self)
|
||||||
return self->tree_contents_checksum;
|
return self->tree_contents_checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ostree_repo_file_tree_get_metadata_checksum (OstreeRepoFile *self)
|
||||||
|
{
|
||||||
|
return self->tree_metadata_checksum;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_repo_file_nontree_get_local:
|
* ostree_repo_file_nontree_get_local:
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ void ostree_repo_file_tree_set_metadata (OstreeRepoFile *self,
|
||||||
GVariant *metadata);
|
GVariant *metadata);
|
||||||
|
|
||||||
const char *ostree_repo_file_tree_get_contents_checksum (OstreeRepoFile *self);
|
const char *ostree_repo_file_tree_get_contents_checksum (OstreeRepoFile *self);
|
||||||
|
const char *ostree_repo_file_tree_get_metadata_checksum (OstreeRepoFile *self);
|
||||||
|
|
||||||
gboolean ostree_repo_file_is_tree (OstreeRepoFile *self);
|
gboolean ostree_repo_file_is_tree (OstreeRepoFile *self);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -227,15 +227,10 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
|
||||||
gs_unref_object GFile *arg = NULL;
|
gs_unref_object GFile *arg = NULL;
|
||||||
gs_free char *parent = NULL;
|
gs_free char *parent = NULL;
|
||||||
gs_free char *commit_checksum = NULL;
|
gs_free char *commit_checksum = NULL;
|
||||||
gs_unref_variant GVariant *parent_commit = NULL;
|
|
||||||
gs_free char *contents_checksum = NULL;
|
gs_free char *contents_checksum = NULL;
|
||||||
gs_unref_object OstreeMutableTree *mtree = NULL;
|
gs_unref_object OstreeMutableTree *mtree = NULL;
|
||||||
gs_free char *tree_type = NULL;
|
gs_free char *tree_type = NULL;
|
||||||
gs_unref_hashtable GHashTable *mode_adds = NULL;
|
gs_unref_hashtable GHashTable *mode_adds = NULL;
|
||||||
gs_unref_variant GVariant *parent_content_csum_v = NULL;
|
|
||||||
gs_unref_variant GVariant *parent_metadata_csum_v = NULL;
|
|
||||||
gs_free char *parent_content_checksum = NULL;
|
|
||||||
gs_free char *parent_metadata_checksum = NULL;
|
|
||||||
OstreeRepoCommitModifier *modifier = NULL;
|
OstreeRepoCommitModifier *modifier = NULL;
|
||||||
OstreeRepoTransactionStats stats;
|
OstreeRepoTransactionStats stats;
|
||||||
|
|
||||||
|
|
@ -270,13 +265,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
|
||||||
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (opt_skip_if_unchanged && parent)
|
|
||||||
{
|
|
||||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT,
|
|
||||||
parent, &parent_commit, error))
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!opt_subject && !opt_body)
|
if (!opt_subject && !opt_body)
|
||||||
{
|
{
|
||||||
if (!commit_editor (repo, opt_branch, &opt_subject, &opt_body, cancellable, error))
|
if (!commit_editor (repo, opt_branch, &opt_subject, &opt_body, cancellable, error))
|
||||||
|
|
@ -390,17 +378,18 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
|
||||||
if (!ostree_repo_write_mtree (repo, mtree, &contents_checksum, cancellable, error))
|
if (!ostree_repo_write_mtree (repo, mtree, &contents_checksum, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (opt_skip_if_unchanged && parent_commit)
|
if (opt_skip_if_unchanged && parent)
|
||||||
{
|
{
|
||||||
g_variant_get_child (parent_commit, 6, "@ay", &parent_content_csum_v);
|
const char *metadata_checksum;
|
||||||
g_variant_get_child (parent_commit, 7, "@ay", &parent_metadata_csum_v);
|
gs_unref_object OstreeRepoFile *parent_root;
|
||||||
|
|
||||||
parent_content_checksum = ostree_checksum_from_bytes_v (parent_content_csum_v);
|
if (!ostree_repo_read_commit (repo, parent, (GFile **) &parent_root, cancellable, error))
|
||||||
parent_metadata_checksum = ostree_checksum_from_bytes_v (parent_metadata_csum_v);
|
goto out;
|
||||||
|
|
||||||
if (strcmp (contents_checksum, parent_content_checksum) == 0
|
metadata_checksum = ostree_mutable_tree_get_metadata_checksum (mtree);
|
||||||
&& strcmp (ostree_mutable_tree_get_metadata_checksum (mtree),
|
|
||||||
parent_metadata_checksum) == 0)
|
if (strcmp (contents_checksum, ostree_repo_file_tree_get_contents_checksum (parent_root)) == 0 &&
|
||||||
|
strcmp (metadata_checksum, ostree_repo_file_tree_get_metadata_checksum (parent_root)) == 0)
|
||||||
skip_commit = TRUE;
|
skip_commit = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue