From: Jeff King <peff@peff.net>
To: Todd Zullinger <tmz@pobox.com>
Cc: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
Boris Kolpackov <boris@codesynthesis.com>,
Han Young <hanyang.tony@bytedance.com>,
git@vger.kernel.org, karen@codesynthesis.com
Subject: Re: Document ability to disable template directory in git-init
Date: Sat, 5 Jul 2025 23:30:54 -0400 [thread overview]
Message-ID: <20250706033054.GC3041790@coredump.intra.peff.net> (raw)
In-Reply-To: <aGfcyfJ0hkZ7kF7_@teonanacatl.net>
On Fri, Jul 04, 2025 at 09:53:13AM -0400, Todd Zullinger wrote:
> > Thanks for digging this up. So in a sense this is an obscurely-
> > documented behavior that people could reasonably choose to rely
> > upon. I think only more reason to document this more prominently.
>
> The commit which added it, d65d2b2fb4 (init: handle empty
> "template" parameter, 2008-07-28), notes the behavior:
>
> init: handle empty "template" parameter
>
> If a user passes "--template=", then our template parameter
> is blank. Unfortunately, copy_templates() assumes it has at
> least one character, and does all sorts of bad things like
> reading from template[-1] and then proceeding to link all of
> '/' into the .git directory.
>
> This patch just checks for that condition in copy_templates
> and aborts. As a side effect, this means that --template=
> now has the meaning "don't copy any templates."
>
> It was released in 1.5.6.5, just in case anyone is looking
> at the release notes for 1.5.6.4 and wondering why this
> isn't mentioned. :)
>
> It came up in <20080722200911.GA3097@sigill.intra.peff.net>
> on the list.
>
> It's been this way for 17 years and seems unlikely to
> change. Documenting it ought to be a good thing.
Oops, I suppose this is my fault. I agree that this is the intended
behavior, and probably ought to be documented.
However, as Kristoffer mentioned, "--no-template" should work in the
same way and is IMHO a bit more ergonomic. It didn't exist back when
that commit was made (we weren't using parse-options yet).
So perhaps the documentation for --template ought to point people in
that direction. But probably we should still mention the "empty string"
behavior in all of the other spots, since as you mentioned it works
equally for the config and environment variables (where is no "--no-"
equivalent).
-Peff
next prev parent reply other threads:[~2025-07-06 3:30 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 [this message]
2025-07-04 14:57 ` Kristoffer Haugsbakk
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=20250706033054.GC3041790@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=boris@codesynthesis.com \
--cc=git@vger.kernel.org \
--cc=hanyang.tony@bytedance.com \
--cc=karen@codesynthesis.com \
--cc=kristofferhaugsbakk@fastmail.com \
--cc=tmz@pobox.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).