Closed tolry closed 8 years ago
Thanks for taking your time reporting this.
I don't think we should fix anything here. It is the expected git behavior, and trying to prevent this (I'm not aware of a way to do it) could cause confusion.
@matteosister It was a bit of a stretch, I know :smile: - bit is there a way with GitElephant to check, if a folder really is a repository (other than checking for a .git subfolder)? Currently I run Repository::init() each time, just to make sure. Since init can be called without risk multiple times.
Thanks for the quick reply, btw.
Great library, have enjoyed working with it so far!
it could be easily done with a filesystem check, but I don't want to override any of the default behaviors of the git binary. You could do it in your code...but also doing a git init is fine imo.
and thanks!!! :heart_eyes:
use case
my/folder/workspace/project
location of a php projectmy/folder/workspace/project/data
gitignore'd folder, where I store different data using gitIf I forgot to initialize the git repo under
data
and use GitElephant on that folder, git will automatically traverse upwards, until finding the first.git
folder and will try to execute the commands on that repository.I could not find an easy way fix this, since even when using the "-C" option, git still traverses upwards. One solution I could think of, would be to have
Repository::open()
validate, if the given folder actually contains a git repository, otherwise throwing an exception. In addition there would be anRepository::create()|init()
method. This is obviously a BC break and might not be worth the hassle.But since I fell into this trap just today, I wanted to at least report it :smile: