summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Antill <james@and.org>2014-06-10 01:44:10 -0400
committerColin Walters <walters@verbum.org>2014-06-18 17:33:03 -0400
commit54c271001fcda4e8fd2887b03fa20835bf740f95 (patch)
treeb4be0d39d4a0107326a030806a09508182adc287
parentf2f3b67804c59610cbe0530501a77ee6346399dd (diff)
downloadostree-54c271001fcda4e8fd2887b03fa20835bf740f95.tar.gz
commit: Hide --disable-fsync option, add --fsync which takes a boolean
Per discussion on mailing list, the --disable-fsync has a double-negative thing going on; --fsync=false is clearer.
-rw-r--r--src/ostree/ot-builtin-commit.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index fb11a056..bd31427e 100644
--- a/src/ostree/ot-builtin-commit.c
+++ b/src/ostree/ot-builtin-commit.c
@@ -48,6 +48,40 @@ static char *opt_gpg_homedir;
static gboolean opt_generate_sizes;
static gboolean opt_disable_fsync;
+#define ARG_EQ(x, y) (g_ascii_strcasecmp(x, y) == 0)
+/* create a function to parse the --fsync option, and current parse it the
+ * same as --disable-fsync. Allows us to add other things later, and not have
+ * a double negative. */
+static gboolean opt__fsync(const gchar *option_name,
+ const gchar *value,
+ gpointer data,
+ GError **error)
+{
+ g_assert(g_str_equal(option_name, "--fsync"));
+
+ if (0) {}
+ else if (ARG_EQ(value, "1"))
+ opt_disable_fsync = 0;
+ else if (ARG_EQ(value, "true"))
+ opt_disable_fsync = 0;
+ else if (ARG_EQ(value, "yes"))
+ opt_disable_fsync = 0;
+ else if (ARG_EQ(value, "0"))
+ opt_disable_fsync = 1;
+ else if (ARG_EQ(value, "false"))
+ opt_disable_fsync = 1;
+ else if (ARG_EQ(value, "none"))
+ opt_disable_fsync = 1;
+ else if (ARG_EQ(value, "no"))
+ opt_disable_fsync = 1;
+ else
+ /* do we want to complain here? */
+ return 0;
+
+
+ return 1;
+}
+
static GOptionEntry options[] = {
{ "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" },
@@ -68,7 +102,8 @@ static GOptionEntry options[] = {
{ "gpg-homedir", 0, 0, G_OPTION_ARG_STRING, &opt_gpg_homedir, "GPG Homedir to use when looking for keyrings", "homedir"},
#endif
{ "generate-sizes", 0, 0, G_OPTION_ARG_NONE, &opt_generate_sizes, "Generate size information along with commit metadata", NULL },
- { "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", 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, opt__fsync, "Specify how to invoke fsync()", NULL },
{ NULL }
};