{"thread":{"id":"4310","subject":"Re: [PATCH 2/2] make init-db use GIT_TEMPLATE_DIR if --template option is not specified","startedAt":"2006-05-27T13:25:54Z","lastAt":"2006-05-28T18:15:09Z","messageCount":4,"participants":["Petr Baudis","Matthias Lederhofer","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"20797","messageId":"20060527132554.GC10488@pasky.or.cz","threadId":"4310","inReplyTo":null,"subject":"Re: [PATCH 2/2] make init-db use GIT_TEMPLATE_DIR if --template option is not specified","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2006-05-27T13:25:54Z","receivedAt":"2006-05-27T13:25:54Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, May 27, 2006 at 12:25:39PM CEST, I got a letter\nwhere Matthias Lederhofer <matled@gmx.net> said that...\n> f61e19360f9b5965dda1ae762ffdab8ede860430\n> diff --git a/builtin-init-db.c b/builtin-init-db.c\n> index 2a1384c..cf5bd39 100644\n> --- a/builtin-init-db.c\n> +++ b/builtin-init-db.c\n> @@ -253,6 +253,9 @@ int cmd_init_db(int argc, const char **a\n>  \t\t\tdie(init_db_usage);\n>  \t}\n>  \n> +\tif (!template_dir)\n> +\t\ttemplate_dir = getenv(\"GIT_TEMPLATE_DIR\");\n> +\n>  \t/*\n>  \t * Set up the default .git directory contents\n>  \t */\n\nPlease document such changes, in the spirit of\n\ndiff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt\nindex 8a150d8..378810e 100644\n--- a/Documentation/git-init-db.txt\n+++ b/Documentation/git-init-db.txt\n@@ -15,6 +15,8 @@ OPTIONS\n -------\n --template=<template_directory>::\n \tProvide the directory from which templates will be used.\n+\tIf not specified, the value of the `GIT_TEMPLATE_DIR` environment\n+\tvariable is used instead.\n \tThe default template directory is `/usr/share/git-core/templates`.\n \n --shared::\n\n(Signed-off-by: Petr Baudis <pasky@suse.cz>, whatever...)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nA person is just about as big as the things that make them angry.\n"},{"id":"20810","messageId":"E1Fk3yR-0006Gd-36@moooo.ath.cx","threadId":"4310","inReplyTo":"20060527132554.GC10488@pasky.or.cz","subject":"[PATCH] new environment variable GIT_TEMPLATE_DIR to override default template","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-05-27T18:57:19Z","receivedAt":"2006-05-27T18:57:19Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"directory and --template=<template_directory> option for to git-clone\n\n---\n> Please document such changes, in the spirit of\n\nThat's right, here are both patches in one because the second patch\nwould also change the documentation of the first one.\n\n---\n\n\nac3c3fdd2423d2184306af3e6e93397475953284\n Documentation/git-clone.txt   |   10 ++++++++--\n Documentation/git-init-db.txt |    2 ++\n builtin-init-db.c             |    3 +++\n git-clone.sh                  |    7 +++++--\n 4 files changed, 18 insertions(+), 4 deletions(-)\n\nac3c3fdd2423d2184306af3e6e93397475953284\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex b333f51..8e833aa 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -9,8 +9,8 @@ git-clone - Clones a repository\n SYNOPSIS\n --------\n [verse]\n-'git-clone' [-l [-s]] [-q] [-n] [--bare] [-o <name>] [-u <upload-pack>]\n-\t  [--reference <repository>]\n+'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]\n+\t  [-o <name>] [-u <upload-pack>] [--reference <repository>]\n \t  <repository> [<directory>]\n \n DESCRIPTION\n@@ -34,6 +34,12 @@ branch you are currently working on.  Re\n \n OPTIONS\n -------\n+--template=<template_directory>::\n+\tProvide the directory from which templates will be used.\n+\tThe default template directory is `/usr/share/git-core/templates`.\n+\tYou can override the default template directory with the\n+\t`$GIT_TEMPLATE_DIR` environment variable.\n+\n --local::\n -l::\n \tWhen the repository to clone from is on a local machine,\ndiff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt\nindex 8a150d8..273f394 100644\n--- a/Documentation/git-init-db.txt\n+++ b/Documentation/git-init-db.txt\n@@ -16,6 +16,8 @@ OPTIONS\n --template=<template_directory>::\n \tProvide the directory from which templates will be used.\n \tThe default template directory is `/usr/share/git-core/templates`.\n+\tYou can override the default template directory with the\n+\t`$GIT_TEMPLATE_DIR` environment variable.\n \n --shared::\n \tSpecify that the git repository is to be shared amongst several users.\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 2a1384c..cf5bd39 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -253,6 +253,9 @@ int cmd_init_db(int argc, const char **a\n \t\t\tdie(init_db_usage);\n \t}\n \n+\tif (!template_dir)\n+\t\ttemplate_dir = getenv(\"GIT_TEMPLATE_DIR\");\n+\n \t/*\n \t * Set up the default .git directory contents\n \t */\ndiff --git a/git-clone.sh b/git-clone.sh\nindex d96894d..1c7ae12 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -9,7 +9,7 @@ # See git-sh-setup why.\n unset CDPATH\n \n usage() {\n-\techo >&2 \"Usage: $0 [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]\"\n+\techo >&2 \"Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]\"\n \texit 1\n }\n \n@@ -102,6 +102,7 @@ quiet=\n local=no\n use_local=no\n local_shared=no\n+template=\n no_checkout=\n upload_pack=\n bare=\n@@ -120,6 +121,8 @@ while\n \t*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;\n         *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) \n           local_shared=yes; use_local=yes ;;\n+\t*,--template=*)\n+\t  template=\"$1\" ;;\n \t*,-q|*,--quiet) quiet=-q ;;\n \t*,--use-separate-remote)\n \t\tuse_separate_remote=t ;;\n@@ -203,7 +206,7 @@ trap 'err=$?; cd ..; rm -r \"$D\"; exit $e\n case \"$bare\" in\n yes) GIT_DIR=\"$D\" ;;\n *) GIT_DIR=\"$D/.git\" ;;\n-esac && export GIT_DIR && git-init-db || usage\n+esac && export GIT_DIR && git-init-db \"$template\" || usage\n case \"$bare\" in\n yes)\n \tGIT_DIR=\"$D\" ;;\n-- \n1.3.3.g40505\n"},{"id":"20824","messageId":"7v4pzadpfr.fsf@assigned-by-dhcp.cox.net","threadId":"4310","inReplyTo":"E1Fk3yR-0006Gd-36@moooo.ath.cx","subject":"Re: [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-28T17:33:44Z","receivedAt":"2006-05-28T17:33:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> directory and --template=<template_directory> option for to git-clone\n>\n> ---\n>> Please document such changes, in the spirit of\n>\n> That's right, here are both patches in one because the second patch\n> would also change the documentation of the first one.\n\nThanks.\n\n * Please don't put the beginning of one sentence on Subject\n   line and start the body of the message with the rest of that\n   sentence.  Instead, come up with a short (meaning \"fits on\n   the Subject line without wrapping with 80-column terminal\")\n   title that describes what the patch does -- it is a good\n   sanity check to make sure your patch is doing one thing and\n   one thing only, instead of mixing unrelated mess together.\n\n * Please sign-off your patch.\n\n * Please test your patch for existing usage, not just for the\n   new usage you added, to avoid regressions.\n\nI like the part to let git-clone pass --template down to git-init-db,\nbut once it is in place I doubt you would still need GIT_TEMPLATE_DIR.\nI'd rather not to introduce new environment variables if we can\navoid them.\n\n> diff --git a/git-clone.sh b/git-clone.sh\n> index d96894d..1c7ae12 100755\n> --- a/git-clone.sh\n> +++ b/git-clone.sh\n> @@ -102,6 +102,7 @@ quiet=\n>  local=no\n>  use_local=no\n>  local_shared=no\n> +template=\n>  no_checkout=\n>  upload_pack=\n>  bare=\n> @@ -120,6 +121,8 @@ while\n>  \t*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;\n>          *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) \n>            local_shared=yes; use_local=yes ;;\n> +\t*,--template=*)\n> +\t  template=\"$1\" ;;\n>  \t*,-q|*,--quiet) quiet=-q ;;\n>  \t*,--use-separate-remote)\n>  \t\tuse_separate_remote=t ;;\n\nHere, $template is either empty string \"\", or \"--template=dir\"\nafter argument parsing.  But then it does this:\n\n> @@ -203,7 +206,7 @@ trap 'err=$?; cd ..; rm -r \"$D\"; exit $e\n>  case \"$bare\" in\n>  yes) GIT_DIR=\"$D\" ;;\n>  *) GIT_DIR=\"$D/.git\" ;;\n> -esac && export GIT_DIR && git-init-db || usage\n> +esac && export GIT_DIR && git-init-db \"$template\" || usage\n\nwhich I suspect would make git-init-db barf if you did not pass\nany --template=foo option to git-clone.  Did you test your patch?\n\nSo I'd do it like this instead.\n\n-- >8 --\n[PATCH] Let git-clone to pass --template=dir option to git-init-db.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n Documentation/git-clone.txt |    9 +++++++--\n git-clone.sh                |   10 ++++++++--\n 2 files changed, 15 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex b333f51..94d9393 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -9,8 +9,8 @@ git-clone - Clones a repository\n SYNOPSIS\n --------\n [verse]\n-'git-clone' [-l [-s]] [-q] [-n] [--bare] [-o <name>] [-u <upload-pack>]\n-\t  [--reference <repository>]\n+'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]\n+\t  [-o <name>] [-u <upload-pack>] [--reference <repository>]\n \t  <repository> [<directory>]\n \n DESCRIPTION\n@@ -89,6 +89,11 @@ OPTIONS\n \tthe command to specify non-default path for the command\n \trun on the other end.\n \n+--template=<template_directory>::\n+\tSpecify the directory from which templates will be used;\n+\tif unset the templates are taken from the installation\n+\tdefined default, typically `/usr/share/git-core/templates`.\n+\n <repository>::\n \tThe (possibly remote) repository to clone from.  It can\n \tbe any URL git-fetch supports.\ndiff --git a/git-clone.sh b/git-clone.sh\nindex d96894d..de59904 100755\n--- a/git-clone.sh\n+++ b/git-clone.sh\n@@ -9,7 +9,7 @@ # See git-sh-setup why.\n unset CDPATH\n \n usage() {\n-\techo >&2 \"Usage: $0 [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]\"\n+\techo >&2 \"Usage: $0 [--template=<template_directory>] [--use-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]\"\n \texit 1\n }\n \n@@ -102,6 +102,7 @@ quiet=\n local=no\n use_local=no\n local_shared=no\n+unset template\n no_checkout=\n upload_pack=\n bare=\n@@ -120,6 +121,11 @@ while\n \t*,-l|*,--l|*,--lo|*,--loc|*,--loca|*,--local) use_local=yes ;;\n         *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) \n           local_shared=yes; use_local=yes ;;\n+\t1,--template) usage ;;\n+\t*,--template)\n+\t\tshift; template=\"--template=$1\" ;;\n+\t*,--template=*)\n+\t  template=\"$1\" ;;\n \t*,-q|*,--quiet) quiet=-q ;;\n \t*,--use-separate-remote)\n \t\tuse_separate_remote=t ;;\n@@ -203,7 +209,7 @@ trap 'err=$?; cd ..; rm -r \"$D\"; exit $e\n case \"$bare\" in\n yes) GIT_DIR=\"$D\" ;;\n *) GIT_DIR=\"$D/.git\" ;;\n-esac && export GIT_DIR && git-init-db || usage\n+esac && export GIT_DIR && git-init-db ${template+\"$template\"} || usage\n case \"$bare\" in\n yes)\n \tGIT_DIR=\"$D\" ;;\n-- \n1.3.3.g2a0a\n"},{"id":"20827","messageId":"E1FkPnB-0005yW-UY@moooo.ath.cx","threadId":"4310","inReplyTo":"7v4pzadpfr.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] new environment variable GIT_TEMPLATE_DIR to override default template","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-05-28T18:15:09Z","receivedAt":"2006-05-28T18:15:09Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"> I like the part to let git-clone pass --template down to git-init-db,\n> but once it is in place I doubt you would still need GIT_TEMPLATE_DIR.\n> I'd rather not to introduce new environment variables if we can\n> avoid them.\n\nI like the variable because it makes it very easy to change the\ndefault template directory (so I don't have to remember passing\n--template every time I clone or create a new repository). But\naliases/default options (~/.git/config thread) this would make this\npossible too.\n\n> Here, $template is either empty string \"\", or \"--template=dir\"\n> after argument parsing.  But then it does this:\n> \n> > @@ -203,7 +206,7 @@ trap 'err=$?; cd ..; rm -r \"$D\"; exit $e\n> >  case \"$bare\" in\n> >  yes) GIT_DIR=\"$D\" ;;\n> >  *) GIT_DIR=\"$D/.git\" ;;\n> > -esac && export GIT_DIR && git-init-db || usage\n> > +esac && export GIT_DIR && git-init-db \"$template\" || usage\n> \n> which I suspect would make git-init-db barf if you did not pass\n> any --template=foo option to git-clone.  Did you test your patch?\n\nSorry, I did not run make test and did not test it without the option.\nShall I send a new patch?\n"}]}