cpliakas / git-wrapper

A PHP wrapper around the Git command line utility.
MIT License
505 stars 68 forks source link

$gitWorkingCopy->init(['bare' => false]) does not work as expected #226

Closed rulatir closed 3 years ago

rulatir commented 3 years ago

Passing ['bare' => false] to $gitWorkingCopy->init() does not seem to have any effect. A bare repository is created no matter what.

How do I use GitWrapper to complete Task Number Zero, i.e. what I normally do with:

cd where-working-tree-will-be
git init --quiet .

?

rulatir commented 3 years ago

Allright, it seems that the doc comment on GitWorkingCopy::init() is kind of confusing:

    /**
     * Create an empty git repository or reinitialize an existing one.
     *
     * @code $git->init(['bare' => true]);
     *
     * @param mixed[] $options
     */

I mistook the @code example to show the defaults for options, and I tried hard to override the supposed default with ['bare'=>false], but GitCommand::buildOptions() doesn't use an option schema and therefore doesn't distinguish between options that take a value and simple flags. It will add an option for every key in the options array, even if the value is false.

TomasVotruba commented 3 years ago

Thank you for the issue!


The work of this package continues in https://github.com/symplify/symplify

See https://github.com/cpliakas/git-wrapper/issues/225