{"action":"created","issue":{"url":"https://api.github.com/repos/src-d/go-git/issues/765","repository_url":"https://api.github.com/repos/src-d/go-git","labels_url":"https://api.github.com/repos/src-d/go-git/issues/765/labels{/name}","comments_url":"https://api.github.com/repos/src-d/go-git/issues/765/comments","events_url":"https://api.github.com/repos/src-d/go-git/issues/765/events","html_url":"https://github.com/src-d/go-git/issues/765","id":301473494,"number":765,"title":"A version of PlainOpen that detects the root of the repository","user":{"login":"mvdan","id":3576549,"avatar_url":"https://avatars0.githubusercontent.com/u/3576549?v=4","gravatar_id":"","url":"https://api.github.com/users/mvdan","html_url":"https://github.com/mvdan","followers_url":"https://api.github.com/users/mvdan/followers","following_url":"https://api.github.com/users/mvdan/following{/other_user}","gists_url":"https://api.github.com/users/mvdan/gists{/gist_id}","starred_url":"https://api.github.com/users/mvdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvdan/subscriptions","organizations_url":"https://api.github.com/users/mvdan/orgs","repos_url":"https://api.github.com/users/mvdan/repos","events_url":"https://api.github.com/users/mvdan/events{/privacy}","received_events_url":"https://api.github.com/users/mvdan/received_events","type":"User","site_admin":false},"labels":[{"id":276436460,"url":"https://api.github.com/repos/src-d/go-git/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":276436461,"url":"https://api.github.com/repos/src-d/go-git/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2018-03-01T16:36:46Z","updated_at":"2018-03-14T16:40:17Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"If I have a repository at `~/foo`, I can run `git status` in `~/foo/bar` without a problem.\r\n\r\nHowever, 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.\r\n\r\nI 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`.\r\n\r\nThere'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.\r\n\r\nHappy to submit a patch with tests if this seems like a good idea.\r\n\r\n/cc @mcuadros @smola "},"comment":{"url":"https://api.github.com/repos/src-d/go-git/issues/comments/373090213","html_url":"https://github.com/src-d/go-git/issues/765#issuecomment-373090213","issue_url":"https://api.github.com/repos/src-d/go-git/issues/765","id":373090213,"user":{"login":"maguro","id":165060,"avatar_url":"https://avatars2.githubusercontent.com/u/165060?v=4","gravatar_id":"","url":"https://api.github.com/users/maguro","html_url":"https://github.com/maguro","followers_url":"https://api.github.com/users/maguro/followers","following_url":"https://api.github.com/users/maguro/following{/other_user}","gists_url":"https://api.github.com/users/maguro/gists{/gist_id}","starred_url":"https://api.github.com/users/maguro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maguro/subscriptions","organizations_url":"https://api.github.com/users/maguro/orgs","repos_url":"https://api.github.com/users/maguro/repos","events_url":"https://api.github.com/users/maguro/events{/privacy}","received_events_url":"https://api.github.com/users/maguro/received_events","type":"User","site_admin":false},"created_at":"2018-03-14T16:40:17Z","updated_at":"2018-03-14T16:40:17Z","author_association":"NONE","body":"To me\r\n\r\n    r, err := git.Open(s, worktree, WithGlobalConfig(), DetectDotGit())\r\n\r\nseems more elegant.  If you don't want to use options you get the backwards compatible\r\n\r\n    r, err := git.Open(s, worktree)\r\n"}}
{"actor":{"display_login":"maguro"}}