git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Document ability to disable template directory in git-init

From
Jeff King <peff@peff.net>
Date
Jul 6, 2025, 03:30 UTC
Message-ID
<20250706033054.GC3041790@coredump.intra.peff.net>
In-Reply-To
<aGfcyfJ0hkZ7kF7_@teonanacatl.net>
On Fri, Jul 04, 2025 at 09:53:13AM -0400, Todd Zullinger wrote:
Show 28 quoted lines
> > 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
Previous: Todd ZullingerNext: Kristoffer Haugsbakk
Message 5 of 7 in “Document ability to disable template directory in git-init”
  1. Boris KolpackovJul 3, 2025
  2. Han YoungJul 4, 2025
  3. Boris KolpackovJul 4, 2025
  4. Todd ZullingerJul 4, 2025
  5. Jeff KingJul 6, 2025
  6. Kristoffer HaugsbakkJul 4, 2025
  7. Kristoffer HaugsbakkJul 4, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.