{"action":"created","comment":{"url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/comments/32190868","id":32190868,"diff_hunk":"@@ -0,0 +1,10 @@\n+package util\n+\n+// Rel strips the leading \"/\" prefix from the path string, effectively turning\n+// an absolute path into one relative to the root directory.\n+func Rel(path string) string {\n+\tif len(path) > 0 && path[0] == '/' {\n+\t\treturn path[1:]\n+\t}\n+\treturn path","path":"vcs/util/path.go","position":null,"original_position":9,"commit_id":"ee27e70c9d01a5f371693a9f336d33b211149e33","original_commit_id":"fc4419157e7f2386f80f5db405de32432ea55a0f","user":{"login":"slimsag","id":3173176,"avatar_url":"https://avatars.githubusercontent.com/u/3173176?v=3","gravatar_id":"","url":"https://api.github.com/users/slimsag","html_url":"https://github.com/slimsag","followers_url":"https://api.github.com/users/slimsag/followers","following_url":"https://api.github.com/users/slimsag/following{/other_user}","gists_url":"https://api.github.com/users/slimsag/gists{/gist_id}","starred_url":"https://api.github.com/users/slimsag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimsag/subscriptions","organizations_url":"https://api.github.com/users/slimsag/orgs","repos_url":"https://api.github.com/users/slimsag/repos","events_url":"https://api.github.com/users/slimsag/events{/privacy}","received_events_url":"https://api.github.com/users/slimsag/received_events","type":"User","site_admin":false},"body":">  I think you should just use strings.TrimPrefix instead for better readability.\r\n\r\nYep, good point. I've pushed a commit to address this just now.\r\n\r\n> Additionally, are you sure doing the above is the right thing? What if the input is \"/\", then the output is a blank string. Would that work?\r\n\r\nIn all of my testing a blank string does work, but my testing didn't include Lstat which it looks like [has a special case in treating \".\" as \"root directory\"](https://sourcegraph.com/sourcegraph.com/sourcegraph/go-vcs@72633312692c1d28164bda8da8dc3b814a24b0aa/.tree/vcs/gitcmd/repo.go#startline=891&endline=892), so I'll add a special case for \"/\".","created_at":"2015-06-11T05:27:28Z","updated_at":"2015-06-11T05:27:28Z","html_url":"https://github.com/sourcegraph/go-vcs/pull/53#discussion_r32190868","pull_request_url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/comments/32190868"},"html":{"href":"https://github.com/sourcegraph/go-vcs/pull/53#discussion_r32190868"},"pull_request":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53","id":37407908,"html_url":"https://github.com/sourcegraph/go-vcs/pull/53","diff_url":"https://github.com/sourcegraph/go-vcs/pull/53.diff","patch_url":"https://github.com/sourcegraph/go-vcs/pull/53.patch","issue_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues/53","number":53,"state":"open","locked":false,"title":"vcs/*: fix handling of root paths inside VFS backends","user":{"login":"slimsag","id":3173176,"avatar_url":"https://avatars.githubusercontent.com/u/3173176?v=3","gravatar_id":"","url":"https://api.github.com/users/slimsag","html_url":"https://github.com/slimsag","followers_url":"https://api.github.com/users/slimsag/followers","following_url":"https://api.github.com/users/slimsag/following{/other_user}","gists_url":"https://api.github.com/users/slimsag/gists{/gist_id}","starred_url":"https://api.github.com/users/slimsag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slimsag/subscriptions","organizations_url":"https://api.github.com/users/slimsag/orgs","repos_url":"https://api.github.com/users/slimsag/repos","events_url":"https://api.github.com/users/slimsag/events{/privacy}","received_events_url":"https://api.github.com/users/slimsag/received_events","type":"User","site_admin":false},"body":"This change handles root paths (i.e. `/foo`) as if they were relative\r\n(`foo`) such that asking the VFS for a file at the root works properly.\r\n\r\nWithout this change it is impossible to use the VFS provided with:\r\n\r\n`golang.org/x/tools/godoc/vfs/httpfs`\r\n\r\nAs `net/http.FileSystem` will implicitly convert all URL paths into\r\nabsolute paths at the root of the FS.\r\n\r\nAdditionally this makes the behavior of the VFS backends comply with\r\nthe OS VFS implementation provided by the `godoc/vfs` package.\r\n\r\nFixes #23","created_at":"2015-06-10T21:42:50Z","updated_at":"2015-06-11T05:27:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"730918984404d932d27072fbfe6577452db9d214","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53/commits","review_comments_url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53/comments","review_comment_url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues/53/comments","statuses_url":"https://api.github.com/repos/sourcegraph/go-vcs/statuses/ee27e70c9d01a5f371693a9f336d33b211149e33","head":{"label":"sourcegraph:fix-root-paths","ref":"fix-root-paths","sha":"ee27e70c9d01a5f371693a9f336d33b211149e33","user":{"login":"sourcegraph","id":3979584,"avatar_url":"https://avatars.githubusercontent.com/u/3979584?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"repo":{"id":10431493,"name":"go-vcs","full_name":"sourcegraph/go-vcs","owner":{"login":"sourcegraph","id":3979584,"avatar_url":"https://avatars.githubusercontent.com/u/3979584?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcegraph/go-vcs","description":"manipulate and inspect VCS repositories in Go","fork":false,"url":"https://api.github.com/repos/sourcegraph/go-vcs","forks_url":"https://api.github.com/repos/sourcegraph/go-vcs/forks","keys_url":"https://api.github.com/repos/sourcegraph/go-vcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcegraph/go-vcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcegraph/go-vcs/teams","hooks_url":"https://api.github.com/repos/sourcegraph/go-vcs/hooks","issue_events_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues/events{/number}","events_url":"https://api.github.com/repos/sourcegraph/go-vcs/events","assignees_url":"https://api.github.com/repos/sourcegraph/go-vcs/assignees{/user}","branches_url":"https://api.github.com/repos/sourcegraph/go-vcs/branches{/branch}","tags_url":"https://api.github.com/repos/sourcegraph/go-vcs/tags","blobs_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcegraph/go-vcs/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcegraph/go-vcs/languages","stargazers_url":"https://api.github.com/repos/sourcegraph/go-vcs/stargazers","contributors_url":"https://api.github.com/repos/sourcegraph/go-vcs/contributors","subscribers_url":"https://api.github.com/repos/sourcegraph/go-vcs/subscribers","subscription_url":"https://api.github.com/repos/sourcegraph/go-vcs/subscription","commits_url":"https://api.github.com/repos/sourcegraph/go-vcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcegraph/go-vcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcegraph/go-vcs/contents/{+path}","compare_url":"https://api.github.com/repos/sourcegraph/go-vcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcegraph/go-vcs/merges","archive_url":"https://api.github.com/repos/sourcegraph/go-vcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcegraph/go-vcs/downloads","issues_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues{/number}","pulls_url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcegraph/go-vcs/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcegraph/go-vcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcegraph/go-vcs/labels{/name}","releases_url":"https://api.github.com/repos/sourcegraph/go-vcs/releases{/id}","created_at":"2013-06-02T02:36:18Z","updated_at":"2015-06-04T08:02:21Z","pushed_at":"2015-06-11T05:22:46Z","git_url":"git://github.com/sourcegraph/go-vcs.git","ssh_url":"git@github.com:sourcegraph/go-vcs.git","clone_url":"https://github.com/sourcegraph/go-vcs.git","svn_url":"https://github.com/sourcegraph/go-vcs","homepage":"https://sourcegraph.com/sourcegraph/go-vcs","size":1721,"stargazers_count":29,"watchers_count":29,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":16,"forks":8,"open_issues":16,"watchers":29,"default_branch":"master"}},"base":{"label":"sourcegraph:master","ref":"master","sha":"72633312692c1d28164bda8da8dc3b814a24b0aa","user":{"login":"sourcegraph","id":3979584,"avatar_url":"https://avatars.githubusercontent.com/u/3979584?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"repo":{"id":10431493,"name":"go-vcs","full_name":"sourcegraph/go-vcs","owner":{"login":"sourcegraph","id":3979584,"avatar_url":"https://avatars.githubusercontent.com/u/3979584?v=3","gravatar_id":"","url":"https://api.github.com/users/sourcegraph","html_url":"https://github.com/sourcegraph","followers_url":"https://api.github.com/users/sourcegraph/followers","following_url":"https://api.github.com/users/sourcegraph/following{/other_user}","gists_url":"https://api.github.com/users/sourcegraph/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcegraph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcegraph/subscriptions","organizations_url":"https://api.github.com/users/sourcegraph/orgs","repos_url":"https://api.github.com/users/sourcegraph/repos","events_url":"https://api.github.com/users/sourcegraph/events{/privacy}","received_events_url":"https://api.github.com/users/sourcegraph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcegraph/go-vcs","description":"manipulate and inspect VCS repositories in Go","fork":false,"url":"https://api.github.com/repos/sourcegraph/go-vcs","forks_url":"https://api.github.com/repos/sourcegraph/go-vcs/forks","keys_url":"https://api.github.com/repos/sourcegraph/go-vcs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcegraph/go-vcs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcegraph/go-vcs/teams","hooks_url":"https://api.github.com/repos/sourcegraph/go-vcs/hooks","issue_events_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues/events{/number}","events_url":"https://api.github.com/repos/sourcegraph/go-vcs/events","assignees_url":"https://api.github.com/repos/sourcegraph/go-vcs/assignees{/user}","branches_url":"https://api.github.com/repos/sourcegraph/go-vcs/branches{/branch}","tags_url":"https://api.github.com/repos/sourcegraph/go-vcs/tags","blobs_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcegraph/go-vcs/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcegraph/go-vcs/languages","stargazers_url":"https://api.github.com/repos/sourcegraph/go-vcs/stargazers","contributors_url":"https://api.github.com/repos/sourcegraph/go-vcs/contributors","subscribers_url":"https://api.github.com/repos/sourcegraph/go-vcs/subscribers","subscription_url":"https://api.github.com/repos/sourcegraph/go-vcs/subscription","commits_url":"https://api.github.com/repos/sourcegraph/go-vcs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcegraph/go-vcs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcegraph/go-vcs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcegraph/go-vcs/contents/{+path}","compare_url":"https://api.github.com/repos/sourcegraph/go-vcs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcegraph/go-vcs/merges","archive_url":"https://api.github.com/repos/sourcegraph/go-vcs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcegraph/go-vcs/downloads","issues_url":"https://api.github.com/repos/sourcegraph/go-vcs/issues{/number}","pulls_url":"https://api.github.com/repos/sourcegraph/go-vcs/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcegraph/go-vcs/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcegraph/go-vcs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcegraph/go-vcs/labels{/name}","releases_url":"https://api.github.com/repos/sourcegraph/go-vcs/releases{/id}","created_at":"2013-06-02T02:36:18Z","updated_at":"2015-06-04T08:02:21Z","pushed_at":"2015-06-11T05:22:46Z","git_url":"git://github.com/sourcegraph/go-vcs.git","ssh_url":"git@github.com:sourcegraph/go-vcs.git","clone_url":"https://github.com/sourcegraph/go-vcs.git","svn_url":"https://github.com/sourcegraph/go-vcs","homepage":"https://sourcegraph.com/sourcegraph/go-vcs","size":1721,"stargazers_count":29,"watchers_count":29,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":16,"forks":8,"open_issues":16,"watchers":29,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53"},"html":{"href":"https://github.com/sourcegraph/go-vcs/pull/53"},"issue":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/issues/53"},"comments":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/sourcegraph/go-vcs/statuses/ee27e70c9d01a5f371693a9f336d33b211149e33"}}}}