Merge branch 'sd/init-template'
* sd/init-template: wrap-for-bin: do not export an empty GIT_TEMPLATE_DIR t/t0001-init.sh: add test for 'init with init.templatedir set' init: having keywords without value is not a global error. Add a "TEMPLATE DIRECTORY" section to git-init[1]. Add `init.templatedir` configuration variable.
This commit is contained in:
commit
90a2bf9ca1
@ -1210,6 +1210,10 @@ imap::
|
|||||||
The configuration variables in the 'imap' section are described
|
The configuration variables in the 'imap' section are described
|
||||||
in linkgit:git-imap-send[1].
|
in linkgit:git-imap-send[1].
|
||||||
|
|
||||||
|
init.templatedir::
|
||||||
|
Specify the directory from which templates will be copied.
|
||||||
|
(See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].)
|
||||||
|
|
||||||
instaweb.browser::
|
instaweb.browser::
|
||||||
Specify the program that will be used to browse your working
|
Specify the program that will be used to browse your working
|
||||||
repository in gitweb. See linkgit:git-instaweb[1].
|
repository in gitweb. See linkgit:git-instaweb[1].
|
||||||
|
@ -149,8 +149,7 @@ objects from the source repository into a pack in the cloned repository.
|
|||||||
|
|
||||||
--template=<template_directory>::
|
--template=<template_directory>::
|
||||||
Specify the directory from which templates will be used;
|
Specify the directory from which templates will be used;
|
||||||
if unset the templates are taken from the installation
|
(See the "TEMPLATE DIRECTORY" section of linkgit:git-init[1].)
|
||||||
defined default, typically `/usr/share/git-core/templates`.
|
|
||||||
|
|
||||||
--depth <depth>::
|
--depth <depth>::
|
||||||
Create a 'shallow' clone with a history truncated to the
|
Create a 'shallow' clone with a history truncated to the
|
||||||
|
@ -28,14 +28,8 @@ current working directory.
|
|||||||
|
|
||||||
--template=<template_directory>::
|
--template=<template_directory>::
|
||||||
|
|
||||||
Provide the directory from which templates will be used. The default template
|
Specify the directory from which templates will be used. (See the "TEMPLATE
|
||||||
directory is `/usr/share/git-core/templates`.
|
DIRECTORY" section below.)
|
||||||
|
|
||||||
When specified, `<template_directory>` is used as the source of the template
|
|
||||||
files rather than the default. The template files include some directory
|
|
||||||
structure, some suggested "exclude patterns", and copies of non-executing
|
|
||||||
"hook" files. The suggested patterns and hook files are all modifiable and
|
|
||||||
extensible.
|
|
||||||
|
|
||||||
--shared[={false|true|umask|group|all|world|everybody|0xxx}]::
|
--shared[={false|true|umask|group|all|world|everybody|0xxx}]::
|
||||||
|
|
||||||
@ -106,6 +100,25 @@ of the repository, such as installing the default hooks and
|
|||||||
setting the configuration variables. The old name is retained
|
setting the configuration variables. The old name is retained
|
||||||
for backward compatibility reasons.
|
for backward compatibility reasons.
|
||||||
|
|
||||||
|
TEMPLATE DIRECTORY
|
||||||
|
------------------
|
||||||
|
|
||||||
|
The template directory contains files and directories that will be copied to
|
||||||
|
the `$GIT_DIR` after it is created.
|
||||||
|
|
||||||
|
The template directory used will (in order):
|
||||||
|
|
||||||
|
- The argument given with the `--template` option.
|
||||||
|
|
||||||
|
- The contents of the `$GIT_TEMPLATE_DIR` environment variable.
|
||||||
|
|
||||||
|
- The `init.templatedir` configuration variable.
|
||||||
|
|
||||||
|
- The default template directory: `/usr/share/git-core/templates`.
|
||||||
|
|
||||||
|
The default template directory includes some directory structure, some
|
||||||
|
suggested "exclude patterns", and copies of sample "hook" files.
|
||||||
|
The suggested patterns and hook files are all modifiable and extensible.
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
static int init_is_bare_repository = 0;
|
static int init_is_bare_repository = 0;
|
||||||
static int init_shared_repository = -1;
|
static int init_shared_repository = -1;
|
||||||
|
static const char *init_db_template_dir;
|
||||||
|
|
||||||
static void safe_create_dir(const char *dir, int share)
|
static void safe_create_dir(const char *dir, int share)
|
||||||
{
|
{
|
||||||
@ -120,6 +121,8 @@ static void copy_templates(const char *template_dir)
|
|||||||
|
|
||||||
if (!template_dir)
|
if (!template_dir)
|
||||||
template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
|
template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
|
||||||
|
if (!template_dir)
|
||||||
|
template_dir = init_db_template_dir;
|
||||||
if (!template_dir)
|
if (!template_dir)
|
||||||
template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
|
template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
|
||||||
if (!template_dir[0])
|
if (!template_dir[0])
|
||||||
@ -165,6 +168,14 @@ static void copy_templates(const char *template_dir)
|
|||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int git_init_db_config(const char *k, const char *v, void *cb)
|
||||||
|
{
|
||||||
|
if (!strcmp(k, "init.templatedir"))
|
||||||
|
return git_config_pathname(&init_db_template_dir, k, v);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int create_default_files(const char *template_path)
|
static int create_default_files(const char *template_path)
|
||||||
{
|
{
|
||||||
const char *git_dir = get_git_dir();
|
const char *git_dir = get_git_dir();
|
||||||
@ -190,6 +201,9 @@ static int create_default_files(const char *template_path)
|
|||||||
safe_create_dir(git_path("refs/heads"), 1);
|
safe_create_dir(git_path("refs/heads"), 1);
|
||||||
safe_create_dir(git_path("refs/tags"), 1);
|
safe_create_dir(git_path("refs/tags"), 1);
|
||||||
|
|
||||||
|
/* Just look for `init.templatedir` */
|
||||||
|
git_config(git_init_db_config, NULL);
|
||||||
|
|
||||||
/* First copy the templates -- we might have the default
|
/* First copy the templates -- we might have the default
|
||||||
* config file there, in which case we would want to read
|
* config file there, in which case we would want to read
|
||||||
* from it after installing.
|
* from it after installing.
|
||||||
|
@ -167,6 +167,25 @@ test_expect_success 'init with --template (blank)' '
|
|||||||
! test -f template-blank/.git/info/exclude
|
! test -f template-blank/.git/info/exclude
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'init with init.templatedir set' '
|
||||||
|
mkdir templatedir-source &&
|
||||||
|
echo Content >templatedir-source/file &&
|
||||||
|
(
|
||||||
|
HOME="`pwd`" &&
|
||||||
|
export HOME &&
|
||||||
|
test_config="${HOME}/.gitconfig" &&
|
||||||
|
git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" &&
|
||||||
|
mkdir templatedir-set &&
|
||||||
|
cd templatedir-set &&
|
||||||
|
unset GIT_CONFIG_NOGLOBAL &&
|
||||||
|
unset GIT_TEMPLATE_DIR &&
|
||||||
|
NO_SET_GIT_TEMPLATE_DIR=t &&
|
||||||
|
export NO_SET_GIT_TEMPLATE_DIR &&
|
||||||
|
git init
|
||||||
|
) &&
|
||||||
|
test_cmp templatedir-source/file templatedir-set/.git/file
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'init --bare/--shared overrides system/global config' '
|
test_expect_success 'init --bare/--shared overrides system/global config' '
|
||||||
(
|
(
|
||||||
HOME="`pwd`" &&
|
HOME="`pwd`" &&
|
||||||
|
@ -7,9 +7,15 @@
|
|||||||
# @@BUILD_DIR@@ and @@PROG@@.
|
# @@BUILD_DIR@@ and @@PROG@@.
|
||||||
|
|
||||||
GIT_EXEC_PATH='@@BUILD_DIR@@'
|
GIT_EXEC_PATH='@@BUILD_DIR@@'
|
||||||
GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
|
if test -n "$NO_SET_GIT_TEMPLATE_DIR"
|
||||||
|
then
|
||||||
|
unset GIT_TEMPLATE_DIR
|
||||||
|
else
|
||||||
|
GIT_TEMPLATE_DIR='@@BUILD_DIR@@/templates/blt'
|
||||||
|
export GIT_TEMPLATE_DIR
|
||||||
|
fi
|
||||||
GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'
|
GITPERLLIB='@@BUILD_DIR@@/perl/blib/lib'
|
||||||
PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
|
PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
|
||||||
export GIT_EXEC_PATH GIT_TEMPLATE_DIR GITPERLLIB PATH
|
export GIT_EXEC_PATH GITPERLLIB PATH
|
||||||
|
|
||||||
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
|
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
|
||||||
|
Loading…
Reference in New Issue
Block a user