Re: [PATCH v4 0/9] Allow overriding the default name of the default branch

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

 



Hi Ed,

On Sun, 12 Jul 2020, Edward Thomson wrote:

> On Mon, Jun 29, 2020 at 11:42 PM brian m. carlson
> <sandals@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > I'm very happy with this and the way it's progressed since v1.  This
> > seems simpler than earlier designs, and I appreciate the improved focus
> > on avoiding special-casing branches, since I think that will make it
> > easier for folks to choose branch naming that suits them.
> >
> > Thanks for working on this.
>
> I agree, this is an improvement.
>
> One thing that isn't obvious to me, though, is why templates take
> precedence over the command-line option.  I would expect the command-line
> option to be the highest priority option given, just like configuration
> values specified on the command-line override values from configuration
> files.

Side note: I have not tested this, but I trust you did, and my reading of
the code agrees that it does this.

The reason why it works that way is that while the `copy_templates()`
function is called before the `create_symref()` call that creates the
`HEAD` symref, the latter call is guarded by the condition that `HEAD`
does not yet exist. Here is a link that highlights both calls (and the
code in between):
https://github.com/git/git/blob/v2.27.0/builtin/init-db.c#L229-L270

Now, it is probably not the intention of the code to prohibit the
config setting from overriding the template files, but instead it intends
to guard against overwriting files by running `git init` in an
_already-initialized_ repository. And I don't think that it possible,
really, to change the logic without making the effect quite hard to
explain.

The truth is that overriding the default name via editing the templates is
just not a very good strategy, it is fraught with peril, as e.g.
`init.templateDir` is a thing that can be easily specified via the
command-line (`git -c init.templateDir=/tmp/my-templates init`).

Ciao,
Dscho




[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