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.
This commit is contained in:
James Antill 2014-06-10 01:44:10 -04:00 committed by Colin Walters
parent f2f3b67804
commit 54c271001f

View File

@ -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 }
};