Skip to content

Commit

Permalink
Add an option to quiet git-init.
Browse files Browse the repository at this point in the history
git-init lacks an option to suppress non-error and non-warning output -
this patch adds one.

Signed-off-by: Jeffrey C. Ollie <jeff@ocjtech.us>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeffrey C. Ollie authored and Junio C Hamano committed Jun 28, 2007
1 parent f578825 commit 4576518
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Documentation/git-init-db.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ git-init-db - Creates an empty git repository

SYNOPSIS
--------
'git-init-db' [--template=<template_directory>] [--shared[=<permissions>]]
'git-init-db' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]


DESCRIPTION
Expand Down
6 changes: 5 additions & 1 deletion Documentation/git-init.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ git-init - Create an empty git repository or reinitialize an existing one

SYNOPSIS
--------
'git-init' [--template=<template_directory>] [--shared[=<permissions>]]
'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]


OPTIONS
-------

--

-q, \--quiet::

Only print error and warning messages, all other output will be suppressed.

--template=<template_directory>::

Provide the directory from which templates will be used. The default template
Expand Down
14 changes: 9 additions & 5 deletions builtin-init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -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=<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.
Expand All @@ -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];
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}

0 comments on commit 4576518

Please sign in to comment.