If I have a repository at ~/foo, I can run git status in ~/foo/bar without a problem.
However, with any little tool that I write with this library, I use git.PlainOpen("."). This works fine if I'm at the root of the git repo, but quickly breaks down if I'm in any of its subdirectories.
I propose that a new Open variant be added that would iterate over the parent directories, stopping at the first containing a .git directory or file. This could be func PlainOpenDetect(from string) (*Repository, error), for example, to not have it depend on os.Getwd.
There's also the question of whether anyone would require the current PlainOpen versus this improved one. If the answer is not, perhaps the behavior of PlainOpen could simply be changed.
Happy to submit a patch with tests if this seems like a good idea.
/cc @mcuadros @smola
If I have a repository at
~/foo, I can rungit statusin~/foo/barwithout a problem.However, with any little tool that I write with this library, I use
git.PlainOpen("."). This works fine if I'm at the root of the git repo, but quickly breaks down if I'm in any of its subdirectories.I propose that a new
Openvariant be added that would iterate over the parent directories, stopping at the first containing a.gitdirectory or file. This could befunc PlainOpenDetect(from string) (*Repository, error), for example, to not have it depend onos.Getwd.There's also the question of whether anyone would require the current
PlainOpenversus this improved one. If the answer is not, perhaps the behavior ofPlainOpencould simply be changed.Happy to submit a patch with tests if this seems like a good idea.
/cc @mcuadros @smola