From 4576518dd7459f44583f33375dbd8799792fc1f3 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Thu, 7 Jun 2007 07:50:29 -0500 Subject: [PATCH] Add an option to quiet git-init. git-init lacks an option to suppress non-error and non-warning output - this patch adds one. Signed-off-by: Jeffrey C. Ollie Signed-off-by: Junio C Hamano --- Documentation/git-init-db.txt | 2 +- Documentation/git-init.txt | 6 +++++- builtin-init-db.c | 14 +++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt index ab0201aec2..d4e01cb325 100644 --- a/Documentation/git-init-db.txt +++ b/Documentation/git-init-db.txt @@ -8,7 +8,7 @@ git-init-db - Creates an empty git repository SYNOPSIS -------- -'git-init-db' [--template=] [--shared[=]] +'git-init-db' [-q | --quiet] [--template=] [--shared[=]] DESCRIPTION diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index 413ed65143..07484a4fd0 100644 --- a/Documentation/git-init.txt +++ b/Documentation/git-init.txt @@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one SYNOPSIS -------- -'git-init' [--template=] [--shared[=]] +'git-init' [-q | --quiet] [--template=] [--shared[=]] OPTIONS @@ -16,6 +16,10 @@ OPTIONS -- +-q, \--quiet:: + +Only print error and warning messages, all other output will be suppressed. + --template=:: Provide the directory from which templates will be used. The default template diff --git a/builtin-init-db.c b/builtin-init-db.c index 976f47b323..d429ceda36 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -266,7 +266,7 @@ static int create_default_files(const char *git_dir, const char *template_path) } static const char init_db_usage[] = -"git-init [--template=] [--shared]"; +"git-init [-q | --quiet] [--template=] [--shared]"; /* * If you want to, you can share the DB area with any number of branches. @@ -281,6 +281,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *template_dir = NULL; char *path; int len, i, reinit; + int quiet = 0; for (i = 1; i < argc; i++, argv++) { const char *arg = argv[1]; @@ -290,6 +291,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) shared_repository = PERM_GROUP; else if (!prefixcmp(arg, "--shared=")) shared_repository = git_config_perm("arg", arg+9); + else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet")) + quiet = 1; else usage(init_db_usage); } @@ -336,10 +339,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) git_config_set("receive.denyNonFastforwards", "true"); } - printf("%s%s Git repository in %s/\n", - reinit ? "Reinitialized existing" : "Initialized empty", - shared_repository ? " shared" : "", - git_dir); + if (!quiet) + printf("%s%s Git repository in %s/\n", + reinit ? "Reinitialized existing" : "Initialized empty", + shared_repository ? " shared" : "", + git_dir); return 0; } -- 2.11.4.GIT