git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init-db: use OPT__QUIET macro instead OPT_BIT
@ 2015-01-14 17:32 Alexander Kuleshov
  2015-01-14 19:08 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kuleshov @ 2015-01-14 17:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Alexander Kuleshov

There is OPT__QUIET macro for easily -q/--quiet option defenition,
let's use it instead OPT_BIT

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 builtin/init-db.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/builtin/init-db.c b/builtin/init-db.c
index 280454a..a89343b 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -368,7 +368,7 @@ static void separate_git_dir(const char *git_dir)
 	write_file(git_link, 1, "gitdir: %s\n", git_dir);
 }
 
-int init_db(const char *template_dir, unsigned int flags)
+int init_db(const char *template_dir, unsigned int quiet)
 {
 	int reinit;
 	const char *git_dir = get_git_dir();
@@ -411,8 +411,7 @@ int init_db(const char *template_dir, unsigned int flags)
 		git_config_set("core.sharedrepository", buf);
 		git_config_set("receive.denyNonFastforwards", "true");
 	}
-	if (!(flags & INIT_DB_QUIET)) {
+	if (!(quiet & INIT_DB_QUIET)) {
 		int len = strlen(git_dir);
 
 		/* TRANSLATORS: The first '%s' is either "Reinitialized
@@ -483,7 +482,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	const char *real_git_dir = NULL;
 	const char *work_tree;
 	const char *template_dir = NULL;
-	unsigned int flags = 0;
+	unsigned int quiet = 0;
 	const struct option init_db_options[] = {
 		OPT_STRING(0, "template", &template_dir, N_("template-directory"),
 				N_("directory from which templates will be used")),
@@ -493,7 +492,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 			N_("permissions"),
 			N_("specify that the git repository is to be shared amongst several users"),
 			PARSE_OPT_OPTARG | PARSE_OPT_NONEG, shared_callback, 0},
-		OPT_BIT('q', "quiet", &flags, N_("be quiet"), INIT_DB_QUIET),
+		OPT__QUIET(&quiet, N_("suppress progress reporting")),
 		OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
 			   N_("separate git dir from working tree")),
 		OPT_END()
@@ -593,5 +592,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 
 	set_git_dir_init(git_dir, real_git_dir, 1);
 
-	return init_db(template_dir, flags);
+	return init_db(template_dir, quiet);
 }
-- 
2.3.0.rc0.256.g17f147e

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] init-db: use OPT__QUIET macro instead OPT_BIT
  2015-01-14 17:32 [PATCH] init-db: use OPT__QUIET macro instead OPT_BIT Alexander Kuleshov
@ 2015-01-14 19:08 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2015-01-14 19:08 UTC (permalink / raw)
  To: Alexander Kuleshov; +Cc: git

Alexander Kuleshov <kuleshovmail@gmail.com> writes:

> There is OPT__QUIET macro for easily -q/--quiet option defenition,
> let's use it instead OPT_BIT
>
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
>  builtin/init-db.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

This is questionable for three reasons.

 - OPT__QUIET() takes an integer and counts up; a single -q and
   double -q -q will give different values to the given variable so
   that the user can express varying levels of quietness.  You can
   no longer check the value with "& INIT_DB_QUIET".

 - We did "flags" very deliberately because we wanted to make sure
   we do not have to add different parameters to init_db() every
   time we wanted a new small knob to tweak its operation like
   "quiet", "verbose", etc.

 - We have been trying to move away from OPT__VERBOSE() and
   OPT__QUIET() to OPT__VERBOSITY(), so that we can handle
   combinations of --quiet and --verbose on the command line in a
   more sensible manner.

I am OK if you switched to OPT__VERBOSITY(), in anticipation of more
verbose output from the command in the future, though.


> diff --git a/builtin/init-db.c b/builtin/init-db.c
> index 280454a..a89343b 100644
> --- a/builtin/init-db.c
> +++ b/builtin/init-db.c
> @@ -368,7 +368,7 @@ static void separate_git_dir(const char *git_dir)
>  	write_file(git_link, 1, "gitdir: %s\n", git_dir);
>  }
>  
> -int init_db(const char *template_dir, unsigned int flags)
> +int init_db(const char *template_dir, unsigned int quiet)
>  {
>  	int reinit;
>  	const char *git_dir = get_git_dir();
> @@ -411,8 +411,7 @@ int init_db(const char *template_dir, unsigned int flags)
>  		git_config_set("core.sharedrepository", buf);
>  		git_config_set("receive.denyNonFastforwards", "true");
>  	}
> -	if (!(flags & INIT_DB_QUIET)) {
> +	if (!(quiet & INIT_DB_QUIET)) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-14 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14 17:32 [PATCH] init-db: use OPT__QUIET macro instead OPT_BIT Alexander Kuleshov
2015-01-14 19:08 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).