diff options
-rw-r--r-- | Documentation/git-init.txt | 7 | ||||
-rw-r--r-- | builtin-init-db.c | 9 | ||||
-rwxr-xr-x | t/t0001-init.sh | 11 |
3 files changed, 24 insertions, 3 deletions
diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt index b17ae8485c..b48c312899 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' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]] +'git-init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]] OPTIONS @@ -20,6 +20,11 @@ OPTIONS Only print error and warning messages, all other output will be suppressed. +--bare:: + +Create a bare repository. If GIT_DIR environment is not set, it is set to the +current working directory. + --template=<template_directory>:: 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 d8bdf928b1..e23b8438c7 100644 --- a/builtin-init-db.c +++ b/builtin-init-db.c @@ -364,7 +364,7 @@ static int guess_repository_type(const char *git_dir) } static const char init_db_usage[] = -"git-init [-q | --quiet] [--template=<template-directory>] [--shared]"; +"git-init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]"; /* * If you want to, you can share the DB area with any number of branches. @@ -383,7 +383,12 @@ int cmd_init_db(int argc, const char **argv, const char *prefix) const char *arg = argv[1]; if (!prefixcmp(arg, "--template=")) template_dir = arg+11; - else if (!strcmp(arg, "--shared")) + else if (!strcmp(arg, "--bare")) { + static char git_dir[PATH_MAX+1]; + is_bare_repository_cfg = 1; + setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, + sizeof(git_dir)), 0); + } else if (!strcmp(arg, "--shared")) shared_repository = PERM_GROUP; else if (!prefixcmp(arg, "--shared=")) shared_repository = git_config_perm("arg", arg+9); diff --git a/t/t0001-init.sh b/t/t0001-init.sh index b0289e397a..d31887f9bf 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -79,6 +79,17 @@ test_expect_success 'GIT_DIR bare' ' check_config git-dir-bare.git true unset ' +test_expect_success 'init --bare' ' + + ( + unset GIT_DIR GIT_WORK_TREE GIT_CONFIG + mkdir git-init-bare.git && + cd git-init-bare.git && + git init --bare + ) && + check_config git-init-bare.git true unset +' + test_expect_success 'GIT_DIR non-bare' ' ( |