Skip to content

Commit 4576518

Browse files
jcolliegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f578825 commit 4576518

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Documentation/git-init-db.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-init-db - Creates an empty git repository
88

99
SYNOPSIS
1010
--------
11-
'git-init-db' [--template=<template_directory>] [--shared[=<permissions>]]
11+
'git-init-db' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
1212

1313

1414
DESCRIPTION

Documentation/git-init.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ git-init - Create an empty git repository or reinitialize an existing one
88

99
SYNOPSIS
1010
--------
11-
'git-init' [--template=<template_directory>] [--shared[=<permissions>]]
11+
'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
1212

1313

1414
OPTIONS
1515
-------
1616

1717
--
1818

19+
-q, \--quiet::
20+
21+
Only print error and warning messages, all other output will be suppressed.
22+
1923
--template=<template_directory>::
2024

2125
Provide the directory from which templates will be used. The default template

builtin-init-db.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
266266
}
267267

268268
static const char init_db_usage[] =
269-
"git-init [--template=<template-directory>] [--shared]";
269+
"git-init [-q | --quiet] [--template=<template-directory>] [--shared]";
270270

271271
/*
272272
* 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)
281281
const char *template_dir = NULL;
282282
char *path;
283283
int len, i, reinit;
284+
int quiet = 0;
284285

285286
for (i = 1; i < argc; i++, argv++) {
286287
const char *arg = argv[1];
@@ -290,6 +291,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
290291
shared_repository = PERM_GROUP;
291292
else if (!prefixcmp(arg, "--shared="))
292293
shared_repository = git_config_perm("arg", arg+9);
294+
else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet"))
295+
quiet = 1;
293296
else
294297
usage(init_db_usage);
295298
}
@@ -336,10 +339,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
336339
git_config_set("receive.denyNonFastforwards", "true");
337340
}
338341

339-
printf("%s%s Git repository in %s/\n",
340-
reinit ? "Reinitialized existing" : "Initialized empty",
341-
shared_repository ? " shared" : "",
342-
git_dir);
342+
if (!quiet)
343+
printf("%s%s Git repository in %s/\n",
344+
reinit ? "Reinitialized existing" : "Initialized empty",
345+
shared_repository ? " shared" : "",
346+
git_dir);
343347

344348
return 0;
345349
}

0 commit comments

Comments
 (0)