提交 4576518d 编写于 作者: J Jeffrey C. Ollie 提交者: Junio C Hamano

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: NJeffrey C. Ollie <jeff@ocjtech.us>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 f5788250
...@@ -8,7 +8,7 @@ git-init-db - Creates an empty git repository ...@@ -8,7 +8,7 @@ git-init-db - Creates an empty git repository
SYNOPSIS SYNOPSIS
-------- --------
'git-init-db' [--template=<template_directory>] [--shared[=<permissions>]] 'git-init-db' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
DESCRIPTION DESCRIPTION
......
...@@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one ...@@ -8,7 +8,7 @@ git-init - Create an empty git repository or reinitialize an existing one
SYNOPSIS SYNOPSIS
-------- --------
'git-init' [--template=<template_directory>] [--shared[=<permissions>]] 'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
OPTIONS OPTIONS
...@@ -16,6 +16,10 @@ OPTIONS ...@@ -16,6 +16,10 @@ OPTIONS
-- --
-q, \--quiet::
Only print error and warning messages, all other output will be suppressed.
--template=<template_directory>:: --template=<template_directory>::
Provide the directory from which templates will be used. The default template Provide the directory from which templates will be used. The default template
......
...@@ -266,7 +266,7 @@ static int create_default_files(const char *git_dir, const char *template_path) ...@@ -266,7 +266,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
} }
static const char init_db_usage[] = static const char init_db_usage[] =
"git-init [--template=<template-directory>] [--shared]"; "git-init [-q | --quiet] [--template=<template-directory>] [--shared]";
/* /*
* If you want to, you can share the DB area with any number of branches. * 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) ...@@ -281,6 +281,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
const char *template_dir = NULL; const char *template_dir = NULL;
char *path; char *path;
int len, i, reinit; int len, i, reinit;
int quiet = 0;
for (i = 1; i < argc; i++, argv++) { for (i = 1; i < argc; i++, argv++) {
const char *arg = argv[1]; const char *arg = argv[1];
...@@ -290,6 +291,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) ...@@ -290,6 +291,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
shared_repository = PERM_GROUP; shared_repository = PERM_GROUP;
else if (!prefixcmp(arg, "--shared=")) else if (!prefixcmp(arg, "--shared="))
shared_repository = git_config_perm("arg", arg+9); shared_repository = git_config_perm("arg", arg+9);
else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet"))
quiet = 1;
else else
usage(init_db_usage); usage(init_db_usage);
} }
...@@ -336,10 +339,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) ...@@ -336,10 +339,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
git_config_set("receive.denyNonFastforwards", "true"); git_config_set("receive.denyNonFastforwards", "true");
} }
printf("%s%s Git repository in %s/\n", if (!quiet)
reinit ? "Reinitialized existing" : "Initialized empty", printf("%s%s Git repository in %s/\n",
shared_repository ? " shared" : "", reinit ? "Reinitialized existing" : "Initialized empty",
git_dir); shared_repository ? " shared" : "",
git_dir);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册