trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
240 stars 58 forks source link

user dir as submodule: git-sync/classes/GitSync.php incorrectly assumes .git is a directory #147

Closed draeath closed 4 years ago

draeath commented 4 years ago

git-sync v2.0.5 on grav v1.6.9 - have not yet tested newer versions.

When keeping my whole grav instance in git, I must use a submodule for the user directory so that git-sync is able to operate.

However, certain changes in the admin panel (such as configuration of git-sync itself) drives git-sync to try to create or access '/.git/info/sparse-checkout' - see git-sync/classes/GitSync.php line 142:

$file = File::instance(rtrim($this->repositoryPath, '/') . '/.git/info/sparse-checkout');

This is bad behavior. In the case of git submodules, .git is a file and not a directory. For example, mine contains the text:

gitdir: ../.git/modules/user

Please consider checking if .git is a file, and if it is checking for gitdir: and following that path for this operation, instead.

w00fz commented 4 years ago

Yeah... I haven't really tested GitSync with submodules at all, that usually isn't a common setup for the Grav user.

If you could help figure out a fix and propose the change that would be helpful