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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Boris Kolpackov wrote:
> Han Young <hanyang.tony@xxxxxxxxxxxxx> writes:
> 
>> Digging through the changelog, I think the feature is added in v1.5.6.4:
>> 
>>  "git init --template=" with blank "template" parameter linked files
>>  under root directories to .git, which was a total nonsense.  Instead, it
>>  means "I do not want to use anything from the template directory".
> 
> 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@xxxxxxxxxxxxxxxxxxxxx>
on the list.

It's been this way for 17 years and seems unlikely to
change.  Documenting it ought to be a good thing.

I think that may fit best in the TEMPLATE DIRECTORY section
of Documentation/git-init.adoc, if anyone here is interested
in taking a stab at a patch.

You'd probably want to confirm how git init behaves when
`init.templatedir` and `GIT_TEMPLATE_DIR` are set to empty
values as well, to document the effects fully and save a
future user wondering why the docs mention --template= and
not init.templatedir or GIT_TEMPLATE_DIR.

If they all behave the same (which I believe they do), the
docs could just say an empty value causes no templates to be
copied, without listing each of the methods by which it
might be set.

-- 
Todd




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux