{"thread":{"id":"38358","subject":"[PATCH] init-db: use OPT__QUIET macro instead OPT_BIT","startedAt":"2015-01-14T17:32:42Z","lastAt":"2015-01-14T19:08:47Z","messageCount":2,"participants":["Alexander Kuleshov","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"254663","messageId":"1421256762-26765-1-git-send-email-kuleshovmail@gmail.com","threadId":"38358","inReplyTo":null,"subject":"[PATCH] init-db: use OPT__QUIET macro instead OPT_BIT","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-01-14T17:32:42Z","receivedAt":"2015-01-14T17:32:42Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"There is OPT__QUIET macro for easily -q/--quiet option defenition,\nlet's use it instead OPT_BIT\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n builtin/init-db.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 280454a..a89343b 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -368,7 +368,7 @@ static void separate_git_dir(const char *git_dir)\n \twrite_file(git_link, 1, \"gitdir: %s\\n\", git_dir);\n }\n \n-int init_db(const char *template_dir, unsigned int flags)\n+int init_db(const char *template_dir, unsigned int quiet)\n {\n \tint reinit;\n \tconst char *git_dir = get_git_dir();\n@@ -411,8 +411,7 @@ int init_db(const char *template_dir, unsigned int flags)\n \t\tgit_config_set(\"core.sharedrepository\", buf);\n \t\tgit_config_set(\"receive.denyNonFastforwards\", \"true\");\n \t}\n-\tif (!(flags & INIT_DB_QUIET)) {\n+\tif (!(quiet & INIT_DB_QUIET)) {\n \t\tint len = strlen(git_dir);\n \n \t\t/* TRANSLATORS: The first '%s' is either \"Reinitialized\n@@ -483,7 +482,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \tconst char *real_git_dir = NULL;\n \tconst char *work_tree;\n \tconst char *template_dir = NULL;\n-\tunsigned int flags = 0;\n+\tunsigned int quiet = 0;\n \tconst struct option init_db_options[] = {\n \t\tOPT_STRING(0, \"template\", &template_dir, N_(\"template-directory\"),\n \t\t\t\tN_(\"directory from which templates will be used\")),\n@@ -493,7 +492,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t\t\tN_(\"permissions\"),\n \t\t\tN_(\"specify that the git repository is to be shared amongst several users\"),\n \t\t\tPARSE_OPT_OPTARG | PARSE_OPT_NONEG, shared_callback, 0},\n-\t\tOPT_BIT('q', \"quiet\", &flags, N_(\"be quiet\"), INIT_DB_QUIET),\n+\t\tOPT__QUIET(&quiet, N_(\"suppress progress reporting\")),\n \t\tOPT_STRING(0, \"separate-git-dir\", &real_git_dir, N_(\"gitdir\"),\n \t\t\t   N_(\"separate git dir from working tree\")),\n \t\tOPT_END()\n@@ -593,5 +592,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \n \tset_git_dir_init(git_dir, real_git_dir, 1);\n \n-\treturn init_db(template_dir, flags);\n+\treturn init_db(template_dir, quiet);\n }\n-- \n2.3.0.rc0.256.g17f147e\n"},{"id":"254680","messageId":"xmqqa91l9o3k.fsf@gitster.dls.corp.google.com","threadId":"38358","inReplyTo":"1421256762-26765-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH] init-db: use OPT__QUIET macro instead OPT_BIT","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-14T19:08:47Z","receivedAt":"2015-01-14T19:08:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alexander Kuleshov <kuleshovmail@gmail.com> writes:\n\n> There is OPT__QUIET macro for easily -q/--quiet option defenition,\n> let's use it instead OPT_BIT\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n>  builtin/init-db.c | 11 +++++------\n>  1 file changed, 5 insertions(+), 6 deletions(-)\n\nThis is questionable for three reasons.\n\n - OPT__QUIET() takes an integer and counts up; a single -q and\n   double -q -q will give different values to the given variable so\n   that the user can express varying levels of quietness.  You can\n   no longer check the value with \"& INIT_DB_QUIET\".\n\n - We did \"flags\" very deliberately because we wanted to make sure\n   we do not have to add different parameters to init_db() every\n   time we wanted a new small knob to tweak its operation like\n   \"quiet\", \"verbose\", etc.\n\n - We have been trying to move away from OPT__VERBOSE() and\n   OPT__QUIET() to OPT__VERBOSITY(), so that we can handle\n   combinations of --quiet and --verbose on the command line in a\n   more sensible manner.\n\nI am OK if you switched to OPT__VERBOSITY(), in anticipation of more\nverbose output from the command in the future, though.\n\n\n> diff --git a/builtin/init-db.c b/builtin/init-db.c\n> index 280454a..a89343b 100644\n> --- a/builtin/init-db.c\n> +++ b/builtin/init-db.c\n> @@ -368,7 +368,7 @@ static void separate_git_dir(const char *git_dir)\n>  \twrite_file(git_link, 1, \"gitdir: %s\\n\", git_dir);\n>  }\n>  \n> -int init_db(const char *template_dir, unsigned int flags)\n> +int init_db(const char *template_dir, unsigned int quiet)\n>  {\n>  \tint reinit;\n>  \tconst char *git_dir = get_git_dir();\n> @@ -411,8 +411,7 @@ int init_db(const char *template_dir, unsigned int flags)\n>  \t\tgit_config_set(\"core.sharedrepository\", buf);\n>  \t\tgit_config_set(\"receive.denyNonFastforwards\", \"true\");\n>  \t}\n> -\tif (!(flags & INIT_DB_QUIET)) {\n> +\tif (!(quiet & INIT_DB_QUIET)) {\n"}]}