summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-commit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ostree/ot-builtin-commit.c')
-rw-r--r--src/ostree/ot-builtin-commit.c412
1 files changed, 205 insertions, 207 deletions
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index 1db2e2bc..8f56779f 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -21,15 +21,15 @@
#include "config.h"
-#include "ot-main.h"
+#include "ostree-libarchive-private.h"
+#include "ostree-repo-private.h"
+#include "ostree-sign.h"
+#include "ostree.h"
#include "ot-builtins.h"
#include "ot-editor.h"
-#include "ostree.h"
+#include "ot-main.h"
#include "otutil.h"
#include "parse-datetime.h"
-#include "ostree-repo-private.h"
-#include "ostree-libarchive-private.h"
-#include "ostree-sign.h"
static char *opt_subject;
static char *opt_body;
@@ -74,10 +74,7 @@ static gboolean opt_disable_fsync;
static char *opt_timestamp;
static gboolean
-parse_fsync_cb (const char *option_name,
- const char *value,
- gpointer data,
- GError **error)
+parse_fsync_cb (const char *option_name, const char *value, gpointer data, GError **error)
{
gboolean val;
if (!ot_parse_boolean (value, &val, error))
@@ -93,61 +90,95 @@ parse_fsync_cb (const char *option_name,
*/
static GOptionEntry options[] = {
- { "parent", 0, 0, G_OPTION_ARG_STRING, &opt_parent, "Parent commit checksum, or \"none\"", "COMMIT" },
+ { "parent", 0, 0, G_OPTION_ARG_STRING, &opt_parent, "Parent commit checksum, or \"none\"",
+ "COMMIT" },
{ "subject", 's', 0, G_OPTION_ARG_STRING, &opt_subject, "One line subject", "SUBJECT" },
{ "body", 'm', 0, G_OPTION_ARG_STRING, &opt_body, "Full description", "BODY" },
- { "body-file", 'F', 0, G_OPTION_ARG_FILENAME, &opt_body_file, "Commit message from FILE path", "FILE" },
- { "editor", 'e', 0, G_OPTION_ARG_NONE, &opt_editor, "Use an editor to write the commit message", NULL },
+ { "body-file", 'F', 0, G_OPTION_ARG_FILENAME, &opt_body_file, "Commit message from FILE path",
+ "FILE" },
+ { "editor", 'e', 0, G_OPTION_ARG_NONE, &opt_editor, "Use an editor to write the commit message",
+ NULL },
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &opt_branch, "Branch", "BRANCH" },
{ "orphan", 0, 0, G_OPTION_ARG_NONE, &opt_orphan, "Create a commit without writing a ref", NULL },
- { "no-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_no_bindings, "Do not write any ref bindings", NULL },
- { "bind-ref", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_bind_refs, "Add a ref to ref binding commit metadata", "BRANCH" },
- { "base", 0, 0, G_OPTION_ARG_STRING, &opt_base, "Start from the given commit as a base (no modifiers apply)", "REV" },
- { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_trees, "Overlay the given argument as a tree", "dir=PATH or tar=TARFILE or ref=COMMIT" },
- { "add-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_strings, "Add a key/value pair to metadata", "KEY=VALUE" },
- { "add-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_variants, "Add a key/value pair to metadata, where the KEY is a string, and VALUE is in GVariant Text Format", "KEY=VALUE" },
- { "keep-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_keep, "Keep metadata KEY and its associated VALUE from parent", "KEY" },
- { "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings, "Add a key/value pair to detached metadata", "KEY=VALUE" },
+ { "no-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_no_bindings, "Do not write any ref bindings",
+ NULL },
+ { "bind-ref", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_bind_refs,
+ "Add a ref to ref binding commit metadata", "BRANCH" },
+ { "base", 0, 0, G_OPTION_ARG_STRING, &opt_base,
+ "Start from the given commit as a base (no modifiers apply)", "REV" },
+ { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_trees, "Overlay the given argument as a tree",
+ "dir=PATH or tar=TARFILE or ref=COMMIT" },
+ { "add-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_strings,
+ "Add a key/value pair to metadata", "KEY=VALUE" },
+ { "add-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_variants,
+ "Add a key/value pair to metadata, where the KEY is a string, and VALUE is in GVariant Text "
+ "Format",
+ "KEY=VALUE" },
+ { "keep-metadata", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_metadata_keep,
+ "Keep metadata KEY and its associated VALUE from parent", "KEY" },
+ { "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings,
+ "Add a key/value pair to detached metadata", "KEY=VALUE" },
{ "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Set file ownership user id", "UID" },
{ "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Set file ownership group id", "GID" },
- { "canonical-permissions", 0, 0, G_OPTION_ARG_NONE, &opt_canonical_permissions, "Canonicalize permissions in the same way bare-user does for hardlinked files", NULL },
- { "bootable", 0, 0, G_OPTION_ARG_NONE, &opt_bootable, "Flag this commit as a bootable OSTree (e.g. contains a Linux kernel)", NULL },
- { "mode-ro-executables", 0, 0, G_OPTION_ARG_NONE, &opt_ro_executables, "Ensure executable files are not writable", NULL },
- { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes", NULL },
- { "selinux-policy", 0, 0, G_OPTION_ARG_FILENAME, &opt_selinux_policy, "Set SELinux labels based on policy in root filesystem PATH (may be /)", "PATH" },
- { "selinux-policy-from-base", 'P', 0, G_OPTION_ARG_NONE, &opt_selinux_policy_from_base, "Set SELinux labels based on first --tree argument", NULL },
- { "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup, "Optimize for commits of trees composed of hardlinks into the repository", NULL },
- { "devino-canonical", 'I', 0, G_OPTION_ARG_NONE, &opt_devino_canonical, "Assume hardlinked objects are unmodified. Implies --link-checkout-speedup", NULL },
- { "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
- { "tar-pathname-filter", 0, 0, G_OPTION_ARG_STRING, &opt_tar_pathname_filter, "When loading tar archives, use REGEX,REPLACEMENT against path names", "REGEX,REPLACEMENT" },
- { "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &opt_skip_if_unchanged, "If the contents are unchanged from previous commit, do nothing", NULL },
- { "statoverride", 0, 0, G_OPTION_ARG_FILENAME, &opt_statoverride_file, "File containing list of modifications to make to permissions", "PATH" },
- { "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file, "File containing list of files to skip", "PATH" },
- { "consume", 0, 0, G_OPTION_ARG_NONE, &opt_consume, "Consume (delete) content after commit (for local directories)", NULL },
- { "table-output", 0, 0, G_OPTION_ARG_NONE, &opt_table_output, "Output more information in a KEY: VALUE format", NULL },
+ { "canonical-permissions", 0, 0, G_OPTION_ARG_NONE, &opt_canonical_permissions,
+ "Canonicalize permissions in the same way bare-user does for hardlinked files", NULL },
+ { "bootable", 0, 0, G_OPTION_ARG_NONE, &opt_bootable,
+ "Flag this commit as a bootable OSTree (e.g. contains a Linux kernel)", NULL },
+ { "mode-ro-executables", 0, 0, G_OPTION_ARG_NONE, &opt_ro_executables,
+ "Ensure executable files are not writable", NULL },
+ { "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes",
+ NULL },
+ { "selinux-policy", 0, 0, G_OPTION_ARG_FILENAME, &opt_selinux_policy,
+ "Set SELinux labels based on policy in root filesystem PATH (may be /)", "PATH" },
+ { "selinux-policy-from-base", 'P', 0, G_OPTION_ARG_NONE, &opt_selinux_policy_from_base,
+ "Set SELinux labels based on first --tree argument", NULL },
+ { "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup,
+ "Optimize for commits of trees composed of hardlinks into the repository", NULL },
+ { "devino-canonical", 'I', 0, G_OPTION_ARG_NONE, &opt_devino_canonical,
+ "Assume hardlinked objects are unmodified. Implies --link-checkout-speedup", NULL },
+ { "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents,
+ "When loading tar archives, automatically create parent directories as needed", NULL },
+ { "tar-pathname-filter", 0, 0, G_OPTION_ARG_STRING, &opt_tar_pathname_filter,
+ "When loading tar archives, use REGEX,REPLACEMENT against path names", "REGEX,REPLACEMENT" },
+ { "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &opt_skip_if_unchanged,
+ "If the contents are unchanged from previous commit, do nothing", NULL },
+ { "statoverride", 0, 0, G_OPTION_ARG_FILENAME, &opt_statoverride_file,
+ "File containing list of modifications to make to permissions", "PATH" },
+ { "skip-list", 0, 0, G_OPTION_ARG_FILENAME, &opt_skiplist_file,
+ "File containing list of files to skip", "PATH" },
+ { "consume", 0, 0, G_OPTION_ARG_NONE, &opt_consume,
+ "Consume (delete) content after commit (for local directories)", NULL },
+ { "table-output", 0, 0, G_OPTION_ARG_NONE, &opt_table_output,
+ "Output more information in a KEY: VALUE format", NULL },
#ifndef OSTREE_DISABLE_GPGME
- { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_key_ids, "GPG Key ID to sign the commit with", "KEY-ID"},
- { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "HOMEDIR"},
+ { "gpg-sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_gpg_key_ids,
+ "GPG Key ID to sign the commit with", "KEY-ID" },
+ { "gpg-homedir", 0, 0, G_OPTION_ARG_FILENAME, &opt_gpg_homedir,
+ "GPG Homedir to use when looking for keyrings", "HOMEDIR" },
#endif
- { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Sign the commit with", "KEY_ID"},
- { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name, "Signature type to use (defaults to 'ed25519')", "NAME"},
- { "generate-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_generate_sizes, "Generate size information along with commit metadata", NULL },
- { "disable-fsync", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
- { "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()", "POLICY" },
- { "timestamp", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp, "Override the timestamp of the commit", "TIMESTAMP" },
+ { "sign", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_key_ids, "Sign the commit with", "KEY_ID" },
+ { "sign-type", 0, 0, G_OPTION_ARG_STRING, &opt_sign_name,
+ "Signature type to use (defaults to 'ed25519')", "NAME" },
+ { "generate-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_generate_sizes,
+ "Generate size information along with commit metadata", NULL },
+ { "disable-fsync", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_disable_fsync,
+ "Do not invoke fsync()", NULL },
+ { "fsync", 0, 0, G_OPTION_ARG_CALLBACK, parse_fsync_cb, "Specify how to invoke fsync()",
+ "POLICY" },
+ { "timestamp", 0, 0, G_OPTION_ARG_STRING, &opt_timestamp, "Override the timestamp of the commit",
+ "TIMESTAMP" },
{ NULL }
};
-struct CommitFilterData {
+struct CommitFilterData
+{
GHashTable *mode_adds;
GHashTable *mode_overrides;
GHashTable *skip_list;
};
static gboolean
-handle_statoverride_line (const char *line,
- void *data,
- GError **error)
+handle_statoverride_line (const char *line, void *data, GError **error)
{
struct CommitFilterData *cf = data;
const char *spc = strchr (line, ' ');
@@ -157,23 +188,20 @@ handle_statoverride_line (const char *line,
if (g_str_has_prefix (line, "="))
{
- guint mode_override = (guint32)(gint32)g_ascii_strtod (line+1, NULL);
+ guint mode_override = (guint32)(gint32)g_ascii_strtod (line + 1, NULL);
g_hash_table_insert (cf->mode_overrides, g_strdup (fn),
- GUINT_TO_POINTER((gint32)mode_override));
+ GUINT_TO_POINTER ((gint32)mode_override));
}
else
{
guint mode_add = (guint32)(gint32)g_ascii_strtod (line, NULL);
- g_hash_table_insert (cf->mode_adds, g_strdup (fn),
- GUINT_TO_POINTER((gint32)mode_add));
+ g_hash_table_insert (cf->mode_adds, g_strdup (fn), GUINT_TO_POINTER ((gint32)mode_add));
}
return TRUE;
}
static gboolean
-handle_skiplist_line (const char *line,
- void *data,
- GError **error)
+handle_skiplist_line (const char *line, void *data, GError **error)
{
GHashTable *files = data;
g_hash_table_add (files, g_strdup (line));
@@ -181,10 +209,7 @@ handle_skiplist_line (const char *line,
}
static OstreeRepoCommitFilterResult
-commit_filter (OstreeRepo *self,
- const char *path,
- GFileInfo *file_info,
- gpointer user_data)
+commit_filter (OstreeRepo *self, const char *path, GFileInfo *file_info, gpointer user_data)
{
struct CommitFilterData *data = user_data;
GHashTable *mode_adds = data->mode_adds;
@@ -207,16 +232,14 @@ commit_filter (OstreeRepo *self,
if (mode_adds && g_hash_table_lookup_extended (mode_adds, path, NULL, &value))
{
guint mode_add = GPOINTER_TO_UINT (value);
- g_file_info_set_attribute_uint32 (file_info, "unix::mode",
- mode | mode_add);
+ g_file_info_set_attribute_uint32 (file_info, "unix::mode", mode | mode_add);
g_hash_table_remove (mode_adds, path);
}
else if (mode_overrides && g_hash_table_lookup_extended (mode_overrides, path, NULL, &value))
{
guint current_fmt = g_file_info_get_attribute_uint32 (file_info, "unix::mode") & S_IFMT;
guint mode_override = GPOINTER_TO_UINT (value);
- g_file_info_set_attribute_uint32 (file_info, "unix::mode",
- current_fmt | mode_override);
+ g_file_info_set_attribute_uint32 (file_info, "unix::mode", current_fmt | mode_override);
g_hash_table_remove (mode_adds, path);
}
@@ -230,23 +253,20 @@ commit_filter (OstreeRepo *self,
}
#ifdef HAVE_LIBARCHIVE
-typedef struct {
+typedef struct
+{
GRegex *regex;
const char *replacement;
} TranslatePathnameData;
/* Implement --tar-pathname-filter */
static char *
-handle_translate_pathname (OstreeRepo *repo,
- const struct stat *stbuf,
- const char *path,
+handle_translate_pathname (OstreeRepo *repo, const struct stat *stbuf, const char *path,
gpointer user_data)
{
TranslatePathnameData *tpdata = user_data;
- g_autoptr(GError) tmp_error = NULL;
- char *ret =
- g_regex_replace (tpdata->regex, path, -1, 0,
- tpdata->replacement, 0, &tmp_error);
+ g_autoptr (GError) tmp_error = NULL;
+ char *ret = g_regex_replace (tpdata->regex, path, -1, 0, tpdata->replacement, 0, &tmp_error);
g_assert_no_error (tmp_error);
g_assert (ret);
return ret;
@@ -254,22 +274,17 @@ handle_translate_pathname (OstreeRepo *repo,
#endif
static gboolean
-commit_editor (OstreeRepo *repo,
- const char *branch,
- char **subject,
- char **body,
- GCancellable *cancellable,
- GError **error)
+commit_editor (OstreeRepo *repo, const char *branch, char **subject, char **body,
+ GCancellable *cancellable, GError **error)
{
- g_autofree char *input = g_strdup_printf ("\n"
+ g_autofree char *input = g_strdup_printf (
+ "\n"
"# Please enter the commit message for your changes. The first line will\n"
"# become the subject, and the remainder the body. Lines starting\n"
"# with '#' will be ignored, and an empty message aborts the commit."
- "%s%s%s%s%s%s\n"
- , branch ? "\n#\n# Branch: " : "", branch ? branch : ""
- , *subject ? "\n" : "", *subject ? *subject : ""
- , *body ? "\n" : "", *body ? *body : ""
- );
+ "%s%s%s%s%s%s\n",
+ branch ? "\n#\n# Branch: " : "", branch ? branch : "", *subject ? "\n" : "",
+ *subject ? *subject : "", *body ? "\n" : "", *body ? *body : "");
*subject = NULL;
*body = NULL;
@@ -278,8 +293,8 @@ commit_editor (OstreeRepo *repo,
if (output == NULL)
return FALSE;
- g_auto(GStrv) lines = g_strsplit (output, "\n", -1);
- g_autoptr(GString) bodybuf = NULL;
+ g_auto (GStrv) lines = g_strsplit (output, "\n", -1);
+ g_autoptr (GString) bodybuf = NULL;
for (guint i = 0; lines[i] != NULL; i++)
{
g_strchomp (lines[i]);
@@ -323,12 +338,10 @@ commit_editor (OstreeRepo *repo,
}
static gboolean
-parse_keyvalue_strings (GVariantBuilder *builder,
- char **strings,
- gboolean is_gvariant_print,
- GError **error)
+parse_keyvalue_strings (GVariantBuilder *builder, char **strings, gboolean is_gvariant_print,
+ GError **error)
{
- for (char ** iter = strings; *iter; iter++)
+ for (char **iter = strings; *iter; iter++)
{
const char *s = *iter;
const char *eq = strchr (s, '=');
@@ -338,23 +351,21 @@ parse_keyvalue_strings (GVariantBuilder *builder,
const char *value = eq + 1;
if (is_gvariant_print)
{
- g_autoptr(GVariant) variant = g_variant_parse (NULL, value, NULL, NULL, error);
+ g_autoptr (GVariant) variant = g_variant_parse (NULL, value, NULL, NULL, error);
if (!variant)
return glnx_prefix_error (error, "Parsing %s", s);
g_variant_builder_add (builder, "{sv}", key, variant);
}
else
- g_variant_builder_add (builder, "{sv}", key,
- g_variant_new_string (value));
+ g_variant_builder_add (builder, "{sv}", key, g_variant_new_string (value));
}
return TRUE;
}
static void
-add_collection_binding (OstreeRepo *repo,
- GVariantBuilder *metadata_builder)
+add_collection_binding (OstreeRepo *repo, GVariantBuilder *metadata_builder)
{
const char *collection_id = ostree_repo_get_collection_id (repo);
@@ -379,67 +390,68 @@ add_ref_binding (GVariantBuilder *metadata_builder)
{
g_assert (opt_branch != NULL || opt_orphan);
- g_autoptr(GPtrArray) refs = g_ptr_array_new ();
+ g_autoptr (GPtrArray) refs = g_ptr_array_new ();
if (opt_branch != NULL)
g_ptr_array_add (refs, opt_branch);
for (char **iter = opt_bind_refs; iter != NULL && *iter != NULL; ++iter)
g_ptr_array_add (refs, *iter);
g_ptr_array_sort (refs, compare_strings);
- g_autoptr(GVariant) refs_v = g_variant_new_strv ((const char *const *)refs->pdata,
- refs->len);
+ g_autoptr (GVariant) refs_v = g_variant_new_strv ((const char *const *)refs->pdata, refs->len);
g_variant_builder_add (metadata_builder, "{s@v}", OSTREE_COMMIT_META_KEY_REF_BINDING,
g_variant_new_variant (g_steal_pointer (&refs_v)));
}
/* Note if you're using the API, you currently need to do this yourself */
static void
-fill_bindings (OstreeRepo *repo,
- GVariant *metadata,
- GVariant **out_metadata)
+fill_bindings (OstreeRepo *repo, GVariant *metadata, GVariant **out_metadata)
{
- g_autoptr(GVariantBuilder) metadata_builder =
- ot_util_variant_builder_from_variant (metadata, G_VARIANT_TYPE_VARDICT);
+ g_autoptr (GVariantBuilder) metadata_builder
+ = ot_util_variant_builder_from_variant (metadata, G_VARIANT_TYPE_VARDICT);
add_ref_binding (metadata_builder);
/* Allow the collection ID to be overridden using
* --add-metadata-string=ostree.collection-binding=blah */
- if (metadata == NULL ||
- !g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, "*", NULL))
+ if (metadata == NULL
+ || !g_variant_lookup (metadata, OSTREE_COMMIT_META_KEY_COLLECTION_BINDING, "*", NULL))
add_collection_binding (repo, metadata_builder);
*out_metadata = g_variant_ref_sink (g_variant_builder_end (metadata_builder));
}
gboolean
-ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
+ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocation,
+ GCancellable *cancellable, GError **error)
{
- g_autoptr(GOptionContext) context = NULL;
- g_autoptr(OstreeRepo) repo = NULL;
+ g_autoptr (GOptionContext) context = NULL;
+ g_autoptr (OstreeRepo) repo = NULL;
gboolean ret = FALSE;
gboolean skip_commit = FALSE;
- g_autoptr(GFile) object_to_commit = NULL;
+ g_autoptr (GFile) object_to_commit = NULL;
g_autofree char *parent = NULL;
g_autofree char *commit_checksum = NULL;
- g_autoptr(GFile) root = NULL;
- g_autoptr(GVariant) metadata = NULL;
- g_autoptr(GVariant) detached_metadata = NULL;
- g_autoptr(OstreeMutableTree) mtree = NULL;
+ g_autoptr (GFile) root = NULL;
+ g_autoptr (GVariant) metadata = NULL;
+ g_autoptr (GVariant) detached_metadata = NULL;
+ g_autoptr (OstreeMutableTree) mtree = NULL;
g_autofree char *tree_type = NULL;
- g_autoptr(GHashTable) mode_adds = NULL;
- g_autoptr(GHashTable) mode_overrides = NULL;
- g_autoptr(GHashTable) skip_list = NULL;
+ g_autoptr (GHashTable) mode_adds = NULL;
+ g_autoptr (GHashTable) mode_overrides = NULL;
+ g_autoptr (GHashTable) skip_list = NULL;
OstreeRepoCommitModifierFlags flags = 0;
- g_autoptr(OstreeSePolicy) policy = NULL;
- g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
+ g_autoptr (OstreeSePolicy) policy = NULL;
+ g_autoptr (OstreeRepoCommitModifier) modifier = NULL;
OstreeRepoTransactionStats stats;
- struct CommitFilterData filter_data = { 0, };
+ struct CommitFilterData filter_data = {
+ 0,
+ };
g_autofree char *commit_body = NULL;
g_autoptr (OstreeSign) sign = NULL;
context = g_option_context_new ("[PATH]");
- if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
+ if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable,
+ error))
goto out;
if (!ostree_ensure_repo_writable (repo, error))
@@ -447,18 +459,20 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_statoverride_file)
{
- filter_data.mode_adds = mode_adds = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- filter_data.mode_overrides = mode_overrides = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- if (!ot_parse_file_by_line (opt_statoverride_file, handle_statoverride_line,
- &filter_data, cancellable, error))
+ filter_data.mode_adds = mode_adds
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ filter_data.mode_overrides = mode_overrides
+ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ if (!ot_parse_file_by_line (opt_statoverride_file, handle_statoverride_line, &filter_data,
+ cancellable, error))
goto out;
}
if (opt_skiplist_file)
{
skip_list = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- if (!ot_parse_file_by_line (opt_skiplist_file, handle_skiplist_line,
- skip_list, cancellable, error))
+ if (!ot_parse_file_by_line (opt_skiplist_file, handle_skiplist_line, skip_list, cancellable,
+ error))
goto out;
}
@@ -487,10 +501,11 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
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 */
+ * which is handled by _ostree_repo_write_ref */
g_clear_error (error);
}
- else goto out;
+ else
+ goto out;
}
}
@@ -504,31 +519,30 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_metadata_strings || opt_metadata_variants || opt_metadata_keep || opt_bootable)
{
- g_autoptr(GVariantBuilder) builder =
- g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
- if (opt_metadata_strings &&
- !parse_keyvalue_strings (builder, opt_metadata_strings, FALSE, error))
- goto out;
+ if (opt_metadata_strings
+ && !parse_keyvalue_strings (builder, opt_metadata_strings, FALSE, error))
+ goto out;
- if (opt_metadata_variants &&
- !parse_keyvalue_strings (builder, opt_metadata_variants, TRUE, error))
+ if (opt_metadata_variants
+ && !parse_keyvalue_strings (builder, opt_metadata_variants, TRUE, error))
goto out;
if (opt_metadata_keep)
{
g_assert (parent);
- g_autoptr(GVariant) parent_commit = NULL;
+ g_autoptr (GVariant) parent_commit = NULL;
if (!ostree_repo_load_commit (repo, parent, &parent_commit, NULL, error))
goto out;
- g_auto(GVariantDict) dict;
+ g_auto (GVariantDict) dict;
g_variant_dict_init (&dict, g_variant_get_child_value (parent_commit, 0));
for (char **keyp = opt_metadata_keep; keyp && *keyp; keyp++)
{
const char *key = *keyp;
- g_autoptr(GVariant) val = g_variant_dict_lookup_value (&dict, key, NULL);
+ g_autoptr (GVariant) val = g_variant_dict_lookup_value (&dict, key, NULL);
if (!val)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
@@ -545,8 +559,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_detached_metadata_strings)
{
- g_autoptr(GVariantBuilder) builder =
- g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
+ g_autoptr (GVariantBuilder) builder = g_variant_builder_new (G_VARIANT_TYPE ("a{sv}"));
if (!parse_keyvalue_strings (builder, opt_detached_metadata_strings, FALSE, error))
goto out;
@@ -587,20 +600,13 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_disable_fsync)
ostree_repo_set_disable_fsync (repo, TRUE);
- if (flags != 0
- || opt_owner_uid >= 0
- || opt_owner_gid >= 0
- || opt_statoverride_file != NULL
- || opt_skiplist_file != NULL
- || opt_no_xattrs
- || opt_ro_executables
- || opt_selinux_policy
+ if (flags != 0 || opt_owner_uid >= 0 || opt_owner_gid >= 0 || opt_statoverride_file != NULL
+ || opt_skiplist_file != NULL || opt_no_xattrs || opt_ro_executables || opt_selinux_policy
|| opt_selinux_policy_from_base)
{
filter_data.mode_adds = mode_adds;
filter_data.skip_list = skip_list;
- modifier = ostree_repo_commit_modifier_new (flags, commit_filter,
- &filter_data, NULL);
+ modifier = ostree_repo_commit_modifier_new (flags, commit_filter, &filter_data, NULL);
if (opt_selinux_policy)
{
@@ -621,8 +627,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
}
else if (opt_body_file)
{
- commit_body = glnx_file_get_contents_utf8_at (AT_FDCWD, opt_body_file, NULL,
- cancellable, error);
+ commit_body
+ = glnx_file_get_contents_utf8_at (AT_FDCWD, opt_body_file, NULL, cancellable, error);
if (!commit_body)
goto out;
}
@@ -644,7 +650,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_selinux_policy_from_base)
{
g_assert (modifier);
- if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, opt_base, cancellable, error))
+ if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, opt_base,
+ cancellable, error))
goto out;
/* Don't try to handle it twice */
opt_selinux_policy_from_base = FALSE;
@@ -655,7 +662,6 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
mtree = ostree_mutable_tree_new ();
}
-
/* Convert implicit . or explicit path via argv into
* --tree=dir= so that we only have one primary code path below.
*/
@@ -670,20 +676,20 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
opt_trees[0] = g_strconcat ("dir=", path, NULL);
}
- const char *const*tree_iter;
+ const char *const *tree_iter;
const char *tree;
const char *eq;
g_assert (opt_trees && *opt_trees);
- for (tree_iter = (const char *const*)opt_trees; *tree_iter; tree_iter++)
+ for (tree_iter = (const char *const *)opt_trees; *tree_iter; tree_iter++)
{
- const gboolean first = (tree_iter == (const char *const*)opt_trees);
+ const gboolean first = (tree_iter == (const char *const *)opt_trees);
tree = *tree_iter;
eq = strchr (tree, '=');
if (!eq)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Missing type in tree specification '%s'", tree);
+ "Missing type in tree specification '%s'", tree);
goto out;
}
g_free (tree_type);
@@ -703,8 +709,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
goto out;
ostree_repo_commit_modifier_set_sepolicy (modifier, policy);
}
- if (!ostree_repo_write_dfd_to_mtree (repo, AT_FDCWD, tree, mtree, modifier,
- cancellable, error))
+ if (!ostree_repo_write_dfd_to_mtree (repo, AT_FDCWD, tree, mtree, modifier, cancellable,
+ error))
goto out;
}
else if (strcmp (tree_type, "tar") == 0)
@@ -718,9 +724,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
{
if (strcmp (tree, "-") == 0)
{
- if (!ostree_repo_write_archive_to_mtree_from_fd (repo, STDIN_FILENO, mtree, modifier,
- opt_tar_autocreate_parents,
- cancellable, error))
+ if (!ostree_repo_write_archive_to_mtree_from_fd (
+ repo, STDIN_FILENO, mtree, modifier, opt_tar_autocreate_parents,
+ cancellable, error))
goto out;
}
else
@@ -728,8 +734,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
object_to_commit = g_file_new_for_path (tree);
if (!ostree_repo_write_archive_to_mtree (repo, object_to_commit, mtree, modifier,
- opt_tar_autocreate_parents,
- cancellable, error))
+ opt_tar_autocreate_parents, cancellable,
+ error))
goto out;
}
}
@@ -740,16 +746,19 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!comma)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Missing ',' in --tar-pathname-filter");
+ "Missing ',' in --tar-pathname-filter");
goto out;
}
const char *replacement = comma + 1;
- g_autofree char *regexp_text = g_strndup (opt_tar_pathname_filter, comma - opt_tar_pathname_filter);
+ g_autofree char *regexp_text
+ = g_strndup (opt_tar_pathname_filter, comma - opt_tar_pathname_filter);
/* Use new API if we have a pathname filter */
- OstreeRepoImportArchiveOptions opts = { 0, };
+ OstreeRepoImportArchiveOptions opts = {
+ 0,
+ };
opts.autocreate_parents = opt_tar_autocreate_parents;
opts.translate_pathname = handle_translate_pathname;
- g_autoptr(GRegex) regexp = g_regex_new (regexp_text, 0, 0, error);
+ g_autoptr (GRegex) regexp = g_regex_new (regexp_text, 0, 0, error);
TranslatePathnameData tpdata = { regexp, replacement };
if (!regexp)
{
@@ -758,7 +767,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
}
opts.translate_pathname_user_data = &tpdata;
- g_autoptr(OtAutoArchiveRead) archive;
+ g_autoptr (OtAutoArchiveRead) archive;
if (strcmp (tree, "-") == 0)
archive = ot_open_archive_read_fd (STDIN_FILENO, error);
else
@@ -766,12 +775,12 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!archive)
goto out;
- if (!ostree_repo_import_archive_to_mtree (repo, &opts, archive, mtree,
- modifier, cancellable, error))
+ if (!ostree_repo_import_archive_to_mtree (repo, &opts, archive, mtree, modifier,
+ cancellable, error))
goto out;
#else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- "This version of ostree is not compiled with libarchive support");
+ "This version of ostree is not compiled with libarchive support");
goto out;
#endif
}
@@ -781,20 +790,21 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (first && opt_selinux_policy_from_base)
{
g_assert (modifier);
- if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, tree, cancellable, error))
+ if (!ostree_repo_commit_modifier_set_sepolicy_from_commit (modifier, repo, tree,
+ cancellable, error))
goto out;
}
if (!ostree_repo_read_commit (repo, tree, &object_to_commit, NULL, cancellable, error))
goto out;
if (!ostree_repo_write_directory_to_mtree (repo, object_to_commit, mtree, modifier,
- cancellable, error))
+ cancellable, error))
goto out;
}
else
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Invalid tree type specification '%s'", tree_type);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid tree type specification '%s'",
+ tree_type);
goto out;
}
}
@@ -808,10 +818,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
while (g_hash_table_iter_next (&hash_iter, &key, &value))
{
- g_printerr ("Unmatched statoverride path: %s\n", (char*)key);
+ g_printerr ("Unmatched statoverride path: %s\n", (char *)key);
}
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unmatched statoverride paths");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unmatched statoverride paths");
goto out;
}
@@ -824,10 +833,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
while (g_hash_table_iter_next (&hash_iter, &key, NULL))
{
- g_printerr ("Unmatched skip-list path: %s\n", (char*)key);
+ g_printerr ("Unmatched skip-list path: %s\n", (char *)key);
}
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Unmatched skip-list paths");
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unmatched skip-list paths");
goto out;
}
@@ -836,7 +844,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (opt_skip_if_unchanged && parent)
{
- g_autoptr(GFile) parent_root;
+ g_autoptr (GFile) parent_root;
if (!ostree_repo_read_commit (repo, parent, &parent_root, NULL, cancellable, error))
goto out;
@@ -849,14 +857,14 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
{
if (!opt_no_bindings)
{
- g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
+ g_autoptr (GVariant) old_metadata = g_steal_pointer (&metadata);
fill_bindings (repo, old_metadata, &metadata);
}
if (opt_bootable)
{
- g_autoptr(GVariant) old_metadata = g_steal_pointer (&metadata);
- g_auto(GVariantDict) bootmeta;
+ g_autoptr (GVariant) old_metadata = g_steal_pointer (&metadata);
+ g_auto (GVariantDict) bootmeta;
g_variant_dict_init (&bootmeta, old_metadata);
if (!ostree_commit_metadata_for_bootable (root, &bootmeta, cancellable, error))
goto out;
@@ -867,8 +875,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
if (!opt_timestamp)
{
if (!ostree_repo_write_commit (repo, parent, opt_subject, commit_body, metadata,
- OSTREE_REPO_FILE (root),
- &commit_checksum, cancellable, error))
+ OSTREE_REPO_FILE (root), &commit_checksum, cancellable,
+ error))
goto out;
}
else
@@ -876,23 +884,21 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
struct timespec ts;
if (!parse_datetime (&ts, opt_timestamp, NULL))
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Could not parse '%s'", opt_timestamp);
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Could not parse '%s'",
+ opt_timestamp);
goto out;
}
guint64 timestamp = ts.tv_sec;
if (!ostree_repo_write_commit_with_time (repo, parent, opt_subject, commit_body, metadata,
- OSTREE_REPO_FILE (root),
- timestamp,
+ OSTREE_REPO_FILE (root), timestamp,
&commit_checksum, cancellable, error))
goto out;
}
if (detached_metadata)
{
- if (!ostree_repo_write_commit_detached_metadata (repo, commit_checksum,
- detached_metadata,
+ if (!ostree_repo_write_commit_detached_metadata (repo, commit_checksum, detached_metadata,
cancellable, error))
goto out;
}
@@ -915,13 +921,9 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
secret_key = g_variant_new_string (keyid);
if (!ostree_sign_set_sk (sign, secret_key, error))
- goto out;
+ goto out;
- if (!ostree_sign_commit (sign,
- repo,
- commit_checksum,
- cancellable,
- error))
+ if (!ostree_sign_commit (sign, repo, commit_checksum, cancellable, error))
goto out;
}
}
@@ -935,12 +937,8 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
{
const char *keyid = *iter;
- if (!ostree_repo_sign_commit (repo,
- commit_checksum,
- keyid,
- opt_gpg_homedir,
- cancellable,
- error))
+ if (!ostree_repo_sign_commit (repo, commit_checksum, keyid, opt_gpg_homedir,
+ cancellable, error))
goto out;
}
}
@@ -975,7 +973,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocatio
}
ret = TRUE;
- out:
+out:
if (repo)
ostree_repo_abort_transaction (repo, cancellable, NULL);
return ret;