git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com>
To: "Boris Kolpackov" <boris@codesynthesis.com>, git@vger.kernel.org
Cc: karen@codesynthesis.com
Subject: Re: Document ability to disable template directory in git-init
Date: Fri, 04 Jul 2025 16:57:25 +0200	[thread overview]
Message-ID: <c20e2e7b-8471-4398-9bfb-6534f8ad2b39@app.fastmail.com> (raw)
In-Reply-To: <boris.20250703161436@codesynthesis.com>

On Thu, Jul 3, 2025, at 16:40, Boris Kolpackov wrote:
> Hello,
>
> Looking at the git-init(1) man page, there doesn't appear to be a way
> to disable copying the contents of the default template directory, other
> than passing a path pointing to an empty directory.
>
> However, if one passes an empty path, for example with the --template
> option, then git does not complain and does not copy anything:
>
> git init --template=
>
> Looking at the code, this undocumented (AFAICS) behavior appears to
> be there at least from git 2.1:
>
>
> static void copy_templates(const char *template_dir)
> {
> 	...
>
> 	if (!template_dir)
> 		template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
> 	if (!template_dir)
> 		template_dir = init_db_template_dir;
> 	if (!template_dir)
> 		template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
> 	if (!template_dir[0])
> 		return;
>
>
> For reference, the corresponding code in 2.50:
>
>
> static void copy_templates(const char *option_template)
> {
> 	const char *template_dir = get_template_dir(option_template);
>	
> 	...
>
> 	if (!template_dir || !*template_dir)
> 		return;
>
>
> I would like to suggest that we document this behavior so that it can
> be relied upon. The motivation for omitting the default template are
> repositories created by tools, such as package managers, for the sole
> purpose of fetching some information from remotes. In this case all
> the stuff copied from the template (such as hooks) is an unnecessary
> waste of time and space.
>
> Looking at the git-init(1) man page, the TEMPLATE DIRECTORY section
> seems like the natural place to document this semantics. For example,
> we could add the following sentence after the list of all the places
> where the template directory can be specified:
>
> "If the specified template directory is an empty path (for example,
> --template=), then no template will be copied."
>
> Let me know what you think.
>
>
> Thanks,
> Boris

You can apparently pass `--no-templates`

```
git init --template=$HOME/git-template --no-templates
```

I had a distinct `description` in the template directory.  That was not
used in the above.

  parent reply	other threads:[~2025-07-04 14:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-03 14:40 Document ability to disable template directory in git-init Boris Kolpackov
2025-07-04  2:49 ` [External] " Han Young
2025-07-04 10:33   ` Boris Kolpackov
2025-07-04 13:53     ` Todd Zullinger
2025-07-06  3:30       ` Jeff King
2025-07-04 14:57 ` Kristoffer Haugsbakk [this message]
2025-07-04 15:17   ` Kristoffer Haugsbakk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c20e2e7b-8471-4398-9bfb-6534f8ad2b39@app.fastmail.com \
    --to=kristofferhaugsbakk@fastmail.com \
    --cc=boris@codesynthesis.com \
    --cc=git@vger.kernel.org \
    --cc=karen@codesynthesis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).