* Re: [PATCH 2/2] make init-db use GIT_TEMPLATE_DIR if --template option is not specified
@ 2006-05-27 13:25 Petr Baudis
2006-05-27 18:57 ` [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template Matthias Lederhofer
0 siblings, 1 reply; 4+ messages in thread
From: Petr Baudis @ 2006-05-27 13:25 UTC (permalink / raw)
To: Matthias Lederhofer; +Cc: git
Dear diary, on Sat, May 27, 2006 at 12:25:39PM CEST, I got a letter
where Matthias Lederhofer <matled@gmx.net> said that...
> f61e19360f9b5965dda1ae762ffdab8ede860430
> diff --git a/builtin-init-db.c b/builtin-init-db.c
> index 2a1384c..cf5bd39 100644
> --- a/builtin-init-db.c
> +++ b/builtin-init-db.c
> @@ -253,6 +253,9 @@ int cmd_init_db(int argc, const char **a
> die(init_db_usage);
> }
>
> + if (!template_dir)
> + template_dir = getenv("GIT_TEMPLATE_DIR");
> +
> /*
> * Set up the default .git directory contents
> */
Please document such changes, in the spirit of
diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt
index 8a150d8..378810e 100644
--- a/Documentation/git-init-db.txt
+++ b/Documentation/git-init-db.txt
@@ -15,6 +15,8 @@ OPTIONS
-------
--template=<template_directory>::
Provide the directory from which templates will be used.
+ If not specified, the value of the `GIT_TEMPLATE_DIR` environment
+ variable is used instead.
The default template directory is `/usr/share/git-core/templates`.
--shared::
(Signed-off-by: Petr Baudis <pasky@suse.cz>, whatever...)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template
2006-05-27 13:25 [PATCH 2/2] make init-db use GIT_TEMPLATE_DIR if --template option is not specified Petr Baudis
@ 2006-05-27 18:57 ` Matthias Lederhofer
2006-05-28 17:33 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Matthias Lederhofer @ 2006-05-27 18:57 UTC (permalink / raw)
To: git
directory and --template=<template_directory> option for to git-clone
---
> Please document such changes, in the spirit of
That's right, here are both patches in one because the second patch
would also change the documentation of the first one.
---
ac3c3fdd2423d2184306af3e6e93397475953284
Documentation/git-clone.txt | 10 ++++++++--
Documentation/git-init-db.txt | 2 ++
builtin-init-db.c | 3 +++
git-clone.sh | 7 +++++--
4 files changed, 18 insertions(+), 4 deletions(-)
ac3c3fdd2423d2184306af3e6e93397475953284
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index b333f51..8e833aa 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -9,8 +9,8 @@ git-clone - Clones a repository
SYNOPSIS
--------
[verse]
-'git-clone' [-l [-s]] [-q] [-n] [--bare] [-o <name>] [-u <upload-pack>]
- [--reference <repository>]
+'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
+ [-o <name>] [-u <upload-pack>] [--reference <repository>]
<repository> [<directory>]
DESCRIPTION
@@ -34,6 +34,12 @@ branch you are currently working on. Re
OPTIONS
-------
+--template=<template_directory>::
+ Provide the directory from which templates will be used.
+ The default template directory is `/usr/share/git-core/templates`.
+ You can override the default template directory with the
+ `$GIT_TEMPLATE_DIR` environment variable.
+
--local::
-l::
When the repository to clone from is on a local machine,
diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt
index 8a150d8..273f394 100644
--- a/Documentation/git-init-db.txt
+++ b/Documentation/git-init-db.txt
@@ -16,6 +16,8 @@ OPTIONS
--template=<template_directory>::
Provide the directory from which templates will be used.
The default template directory is `/usr/share/git-core/templates`.
+ You can override the default template directory with the
+ `$GIT_TEMPLATE_DIR` environment variable.
--shared::
Specify that the git repository is to be shared amongst several users.
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 2a1384c..cf5bd39 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -253,6 +253,9 @@ int cmd_init_db(int argc, const char **a
die(init_db_usage);
}
+ if (!template_dir)
+ template_dir = getenv("GIT_TEMPLATE_DIR");
+
/*
* Set up the default .git directory contents
*/
diff --git a/git-clone.sh b/git-clone.sh
index d96894d..1c7ae12 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -9,7 +9,7 @@ # See git-sh-setup why.
unset CDPATH
usage() {
- echo >&2 "Usage: $0 [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
+ echo >&2 "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
exit 1
}
@@ -102,6 +102,7 @@ quiet=
local=no
use_local=no
local_shared=no
+template=
no_checkout=
upload_pack=
bare=
@@ -120,6 +121,8 @@ while
*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
*,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
local_shared=yes; use_local=yes ;;
+ *,--template=*)
+ template="$1" ;;
*,-q|*,--quiet) quiet=-q ;;
*,--use-separate-remote)
use_separate_remote=t ;;
@@ -203,7 +206,7 @@ trap 'err=$?; cd ..; rm -r "$D"; exit $e
case "$bare" in
yes) GIT_DIR="$D" ;;
*) GIT_DIR="$D/.git" ;;
-esac && export GIT_DIR && git-init-db || usage
+esac && export GIT_DIR && git-init-db "$template" || usage
case "$bare" in
yes)
GIT_DIR="$D" ;;
--
1.3.3.g40505
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template
2006-05-27 18:57 ` [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template Matthias Lederhofer
@ 2006-05-28 17:33 ` Junio C Hamano
2006-05-28 18:15 ` Matthias Lederhofer
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2006-05-28 17:33 UTC (permalink / raw)
To: Matthias Lederhofer; +Cc: git
Matthias Lederhofer <matled@gmx.net> writes:
> directory and --template=<template_directory> option for to git-clone
>
> ---
>> Please document such changes, in the spirit of
>
> That's right, here are both patches in one because the second patch
> would also change the documentation of the first one.
Thanks.
* Please don't put the beginning of one sentence on Subject
line and start the body of the message with the rest of that
sentence. Instead, come up with a short (meaning "fits on
the Subject line without wrapping with 80-column terminal")
title that describes what the patch does -- it is a good
sanity check to make sure your patch is doing one thing and
one thing only, instead of mixing unrelated mess together.
* Please sign-off your patch.
* Please test your patch for existing usage, not just for the
new usage you added, to avoid regressions.
I like the part to let git-clone pass --template down to git-init-db,
but once it is in place I doubt you would still need GIT_TEMPLATE_DIR.
I'd rather not to introduce new environment variables if we can
avoid them.
> diff --git a/git-clone.sh b/git-clone.sh
> index d96894d..1c7ae12 100755
> --- a/git-clone.sh
> +++ b/git-clone.sh
> @@ -102,6 +102,7 @@ quiet=
> local=no
> use_local=no
> local_shared=no
> +template=
> no_checkout=
> upload_pack=
> bare=
> @@ -120,6 +121,8 @@ while
> *,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
> *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
> local_shared=yes; use_local=yes ;;
> + *,--template=*)
> + template="$1" ;;
> *,-q|*,--quiet) quiet=-q ;;
> *,--use-separate-remote)
> use_separate_remote=t ;;
Here, $template is either empty string "", or "--template=dir"
after argument parsing. But then it does this:
> @@ -203,7 +206,7 @@ trap 'err=$?; cd ..; rm -r "$D"; exit $e
> case "$bare" in
> yes) GIT_DIR="$D" ;;
> *) GIT_DIR="$D/.git" ;;
> -esac && export GIT_DIR && git-init-db || usage
> +esac && export GIT_DIR && git-init-db "$template" || usage
which I suspect would make git-init-db barf if you did not pass
any --template=foo option to git-clone. Did you test your patch?
So I'd do it like this instead.
-- >8 --
[PATCH] Let git-clone to pass --template=dir option to git-init-db.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
Documentation/git-clone.txt | 9 +++++++--
git-clone.sh | 10 ++++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index b333f51..94d9393 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -9,8 +9,8 @@ git-clone - Clones a repository
SYNOPSIS
--------
[verse]
-'git-clone' [-l [-s]] [-q] [-n] [--bare] [-o <name>] [-u <upload-pack>]
- [--reference <repository>]
+'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
+ [-o <name>] [-u <upload-pack>] [--reference <repository>]
<repository> [<directory>]
DESCRIPTION
@@ -89,6 +89,11 @@ OPTIONS
the command to specify non-default path for the command
run on the other end.
+--template=<template_directory>::
+ Specify the directory from which templates will be used;
+ if unset the templates are taken from the installation
+ defined default, typically `/usr/share/git-core/templates`.
+
<repository>::
The (possibly remote) repository to clone from. It can
be any URL git-fetch supports.
diff --git a/git-clone.sh b/git-clone.sh
index d96894d..de59904 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -9,7 +9,7 @@ # See git-sh-setup why.
unset CDPATH
usage() {
- echo >&2 "Usage: $0 [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
+ echo >&2 "Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
exit 1
}
@@ -102,6 +102,7 @@ quiet=
local=no
use_local=no
local_shared=no
+unset template
no_checkout=
upload_pack=
bare=
@@ -120,6 +121,11 @@ while
*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;
*,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared)
local_shared=yes; use_local=yes ;;
+ 1,--template) usage ;;
+ *,--template)
+ shift; template="--template=$1" ;;
+ *,--template=*)
+ template="$1" ;;
*,-q|*,--quiet) quiet=-q ;;
*,--use-separate-remote)
use_separate_remote=t ;;
@@ -203,7 +209,7 @@ trap 'err=$?; cd ..; rm -r "$D"; exit $e
case "$bare" in
yes) GIT_DIR="$D" ;;
*) GIT_DIR="$D/.git" ;;
-esac && export GIT_DIR && git-init-db || usage
+esac && export GIT_DIR && git-init-db ${template+"$template"} || usage
case "$bare" in
yes)
GIT_DIR="$D" ;;
--
1.3.3.g2a0a
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template
2006-05-28 17:33 ` Junio C Hamano
@ 2006-05-28 18:15 ` Matthias Lederhofer
0 siblings, 0 replies; 4+ messages in thread
From: Matthias Lederhofer @ 2006-05-28 18:15 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
> I like the part to let git-clone pass --template down to git-init-db,
> but once it is in place I doubt you would still need GIT_TEMPLATE_DIR.
> I'd rather not to introduce new environment variables if we can
> avoid them.
I like the variable because it makes it very easy to change the
default template directory (so I don't have to remember passing
--template every time I clone or create a new repository). But
aliases/default options (~/.git/config thread) this would make this
possible too.
> Here, $template is either empty string "", or "--template=dir"
> after argument parsing. But then it does this:
>
> > @@ -203,7 +206,7 @@ trap 'err=$?; cd ..; rm -r "$D"; exit $e
> > case "$bare" in
> > yes) GIT_DIR="$D" ;;
> > *) GIT_DIR="$D/.git" ;;
> > -esac && export GIT_DIR && git-init-db || usage
> > +esac && export GIT_DIR && git-init-db "$template" || usage
>
> which I suspect would make git-init-db barf if you did not pass
> any --template=foo option to git-clone. Did you test your patch?
Sorry, I did not run make test and did not test it without the option.
Shall I send a new patch?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-05-28 18:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-27 13:25 [PATCH 2/2] make init-db use GIT_TEMPLATE_DIR if --template option is not specified Petr Baudis
2006-05-27 18:57 ` [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template Matthias Lederhofer
2006-05-28 17:33 ` Junio C Hamano
2006-05-28 18:15 ` Matthias Lederhofer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).