summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d2b3691)
raw | patch | inline | side by side (parent: d2b3691)
author | Luciano Rocha <luciano@eurotux.com> | |
Wed, 28 May 2008 18:53:57 +0000 (19:53 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 29 May 2008 01:31:19 +0000 (18:31 -0700) |
It is unfortunate that "git init --bare" does not work and the only reason
why "init" did not learn its own "--bare" option is because "git --bare
init" already does the job (and as an option to the git 'potty', it is
more generic solution).
This teaches "git init" its own "--bare" option, so that both "git --bare init"
and "git init --bare" works mostly the same way.
[jc: rewrote the log message and added test]
Signed-off-by: Luciano Rocha <strange@nsk.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
why "init" did not learn its own "--bare" option is because "git --bare
init" already does the job (and as an option to the git 'potty', it is
more generic solution).
This teaches "git init" its own "--bare" option, so that both "git --bare init"
and "git init --bare" works mostly the same way.
[jc: rewrote the log message and added test]
Signed-off-by: Luciano Rocha <strange@nsk.pt>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-init.txt | patch | blob | history | |
builtin-init-db.c | patch | blob | history | |
t/t0001-init.sh | patch | blob | history |
index b17ae8485cf2d3eb4fc21acba769942a57d33e67..b48c31289923345d8f50342780d30dbcb4e01399 100644 (file)
SYNOPSIS
--------
-'git-init' [-q | --quiet] [--template=<template_directory>] [--shared[=<permissions>]]
+'git-init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]]
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 d8bdf928b1e97864722352955a2e2e37b5c00806..e23b8438c741651f48bbf529f89d0336cc718fed 100644 (file)
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
}
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.
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 b0289e397ab683c8c5a02ce649d7790d6a876d16..d31887f9bf35a7fa9e31b1eb859a9cf21c918d6c 100755 (executable)
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
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' '
(