[ostree] commit: Hide --disable-fsync option, add --fsync which takes a boolean



commit 54c271001fcda4e8fd2887b03fa20835bf740f95
Author: James Antill <james and org>
Date:   Tue Jun 10 01:44:10 2014 -0400

    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.

 src/ostree/ot-builtin-commit.c |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/src/ostree/ot-builtin-commit.c b/src/ostree/ot-builtin-commit.c
index fb11a05..bd31427 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 }
 };
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]