{"action":"created","comment":{"url":"https://api.github.com/repos/ostreedev/ostree/pulls/comments/202452724","pull_request_review_id":137164617,"id":202452724,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjQ1MjcyNA==","diff_hunk":"@@ -4379,6 +4379,171 @@ ostree_repo_read_commit (OstreeRepo   *self,\n   return TRUE;\n }\n \n+\n+static gboolean resolve_sha_to_tree (OstreeRepo       *self,\n+                                     const char*       sha,\n+                                     OstreeRepoFile  **out,\n+                                     char            **out_commit_sha,\n+                                     GCancellable     *cancellable,\n+                                     GError           **error);\n+\n+/**\n+ * _ostree_repo_open_file:\n+ * @self: Repo\n+ * @ref: ref, commit checksum, tree checksum with optional :path suffix\n+ * @path: subpath under ref to return.  Many of the command-line utilities take\n+ *     a --subpath or similar argument.  This is provided as a convenience to\n+ *     handle those.  Set to %NULL if not needed.\n+ * @flags: Specify what kind of file the caller is expecting - a tree, a blob\n+ *     or either.\n+ * @out_root: (out): An #OstreeRepoFile corresponding to the tree/blob.\n+ * @out_commit_sha: (out): SHA of the commit that the file belongs to if any.\n+ *    If the commit is unknown *out will be set to %NULL.\n+ * @cancellable: Cancellable\n+ * @error: Error\n+ *\n+ * This is a helper for the command line utilities.  It's used to convert a\n+ * reference to a tree or a file from the user into an OstreeRepoFile.  It takes\n+ * care to provide good error messages.\n+ *\n+ * @ref can take the form:\n+ *\n+ *    REMOTE:REF\n+ *    :REF\n+ *    REF\n+ *    COMMIT_SHA\n+ *\n+ * Not currently supported (but could be implemented):\n+ *\n+ *    BLOB_SHA\n+ *\n+ * Note: if specifying `TREE_SHA` PATH must not be empty otherwise we won't have\n+ * a valid metadata checksum for the directory.\n+ */\n+gboolean\n+_ostree_repo_open_file (OstreeRepo               *self,\n+                        const char               *ref,\n+                        const char               *path,\n+                        OstreeRepoOpenFileFlags   flags,\n+                        OstreeRepoFile          **out,\n+                        char                    **out_commit_sha,\n+                        GCancellable             *cancellable,\n+                        GError                  **error)\n+{\n+  g_return_val_if_fail (ref, FALSE);\n+\n+  g_autofree char * rev = g_strdup (ref);\n+  g_autofree char * commit_sha = NULL;\n+\n+  g_autofree char * sha = NULL;\n+  /* ostree_repo_resolve_rev passes things that look like SHAs through, so we're\n+   * safe passing tree SHAs in here. */\n+  if (!ostree_repo_resolve_rev (self, rev, FALSE, &sha, error))\n+    return FALSE;\n+\n+  g_autoptr (OstreeRepoFile) ret_out = NULL;\n+  if (!resolve_sha_to_tree (self, sha, &ret_out, &commit_sha, cancellable,\n+                            error))\n+    return FALSE;\n+\n+  if (path && g_strcmp0 (path, \"\") != 0 && g_strcmp0 (path, \"/\") != 0 &&\n+      g_strcmp0 (path, \"/.\") != 0)\n+    {\n+      g_set_object (&ret_out, OSTREE_REPO_FILE (\n+            g_file_resolve_relative_path ((GFile*) ret_out, path)));\n+      if (!ret_out)\n+        {\n+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,\n+                       \"File \\\"%s\\\" not found\", path);\n+          return FALSE;\n+        }\n+    }\n+\n+  if (g_strcmp0 (ostree_repo_file_tree_get_metadata_checksum (ret_out),\n+                 \"00000000000000000000000000000000\") == 0)","path":"src/libostree/ostree-repo.c","position":102,"original_position":85,"commit_id":"cdfb9e8643eedf4ff8ce958c55a80e4583ad4b3a","original_commit_id":"b71b83fc6decabce8b5e6c150082370b141e2284","user":{"login":"wmanley","id":494659,"node_id":"MDQ6VXNlcjQ5NDY1OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/494659?v=4","gravatar_id":"","url":"https://api.github.com/users/wmanley","html_url":"https://github.com/wmanley","followers_url":"https://api.github.com/users/wmanley/followers","following_url":"https://api.github.com/users/wmanley/following{/other_user}","gists_url":"https://api.github.com/users/wmanley/gists{/gist_id}","starred_url":"https://api.github.com/users/wmanley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmanley/subscriptions","organizations_url":"https://api.github.com/users/wmanley/orgs","repos_url":"https://api.github.com/users/wmanley/repos","events_url":"https://api.github.com/users/wmanley/events{/privacy}","received_events_url":"https://api.github.com/users/wmanley/received_events","type":"User","site_admin":false},"body":"I set it explicitly below in `resolve_sha_to_tree`.","created_at":"2018-07-13T19:37:17Z","updated_at":"2018-07-13T19:37:17Z","html_url":"https://github.com/ostreedev/ostree/pull/1658#discussion_r202452724","pull_request_url":"https://api.github.com/repos/ostreedev/ostree/pulls/1658","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ostreedev/ostree/pulls/comments/202452724"},"html":{"href":"https://github.com/ostreedev/ostree/pull/1658#discussion_r202452724"},"pull_request":{"href":"https://api.github.com/repos/ostreedev/ostree/pulls/1658"}},"in_reply_to_id":202444920},"pull_request":{"url":"https://api.github.com/repos/ostreedev/ostree/pulls/1658","id":198040942,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4MDQwOTQy","html_url":"https://github.com/ostreedev/ostree/pull/1658","diff_url":"https://github.com/ostreedev/ostree/pull/1658.diff","patch_url":"https://github.com/ostreedev/ostree/pull/1658.patch","issue_url":"https://api.github.com/repos/ostreedev/ostree/issues/1658","number":1658,"state":"open","locked":false,"title":"Enhance command line utils to take a tree/file sha","user":{"login":"wmanley","id":494659,"node_id":"MDQ6VXNlcjQ5NDY1OQ==","avatar_url":"https://avatars0.githubusercontent.com/u/494659?v=4","gravatar_id":"","url":"https://api.github.com/users/wmanley","html_url":"https://github.com/wmanley","followers_url":"https://api.github.com/users/wmanley/followers","following_url":"https://api.github.com/users/wmanley/following{/other_user}","gists_url":"https://api.github.com/users/wmanley/gists{/gist_id}","starred_url":"https://api.github.com/users/wmanley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wmanley/subscriptions","organizations_url":"https://api.github.com/users/wmanley/orgs","repos_url":"https://api.github.com/users/wmanley/repos","events_url":"https://api.github.com/users/wmanley/events{/privacy}","received_events_url":"https://api.github.com/users/wmanley/received_events","type":"User","site_admin":false},"body":"...in place of a commit sha where reasonable.\r\n\r\nTODO\r\n=====\r\n\r\n- [x] Remove debug prints\r\n- [x] Remove private API from symbol table\r\n- [x] Fix code formatting WRT space between function name and argument list\r\n- [x] Make CI pass\r\n- [ ] Comment on \"000000000000000000000000\" SHA check\r\n- [ ] Use `g_file_query_info` in place of `g_file_query_file_type`\r\n\r\nDescription\r\n=========\r\n\r\nThe motivation for this is to enhance `ostree commit --tree=ref` to allow composing subtrees.  For example: in our build system we strip away everything not under `/usr` as the last step when building containers.  This PR (in combination with #1651) allows you to do:\r\n\r\n    ostree commit --tree=prefix=/usr/lib/machines/container/usr --tree=ref=:container:usr\r\n\r\nTo do this.  It's fast.\r\n\r\nAs I was going along I thought it would be useful to have this ability generally in the command line tools. So now many of them accept a treeish instead of a commit.\r\n\r\nPreviously these tools accepted a COMMIT as:\r\n\r\n* REF\r\n* REMOTE:REF\r\n* COMMIT_SHA\r\n\r\nAnd now in addition:\r\n\r\n* REMOTE:REF:PATH\r\n* :REF:PATH\r\n* COMMIT_SHA:PATH\r\n* TREE_SHA:PATH\r\n\r\nSo the idea is that you append `:PATH` to a commit and you can select a tree.  This is the same as the git syntax.  As a ref may already contain a colon if the REMOTE is specified we disambiguate by requiring the remote to be specified, even if it is left empty.","created_at":"2018-06-28T14:03:04Z","updated_at":"2018-07-13T19:37:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"123d66ebcebebe493749c57d360c0d7fd270aa5c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ostreedev/ostree/pulls/1658/commits","review_comments_url":"https://api.github.com/repos/ostreedev/ostree/pulls/1658/comments","review_comment_url":"https://api.github.com/repos/ostreedev/ostree/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ostreedev/ostree/issues/1658/comments","statuses_url":"https://api.github.com/repos/ostreedev/ostree/statuses/cdfb9e8643eedf4ff8ce958c55a80e4583ad4b3a","head":{"label":"stb-tester:treeish","ref":"treeish","sha":"cdfb9e8643eedf4ff8ce958c55a80e4583ad4b3a","user":{"login":"stb-tester","id":5528358,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU1MjgzNTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5528358?v=4","gravatar_id":"","url":"https://api.github.com/users/stb-tester","html_url":"https://github.com/stb-tester","followers_url":"https://api.github.com/users/stb-tester/followers","following_url":"https://api.github.com/users/stb-tester/following{/other_user}","gists_url":"https://api.github.com/users/stb-tester/gists{/gist_id}","starred_url":"https://api.github.com/users/stb-tester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stb-tester/subscriptions","organizations_url":"https://api.github.com/users/stb-tester/orgs","repos_url":"https://api.github.com/users/stb-tester/repos","events_url":"https://api.github.com/users/stb-tester/events{/privacy}","received_events_url":"https://api.github.com/users/stb-tester/received_events","type":"Organization","site_admin":false},"repo":{"id":63652229,"node_id":"MDEwOlJlcG9zaXRvcnk2MzY1MjIyOQ==","name":"ostree","full_name":"stb-tester/ostree","owner":{"login":"stb-tester","id":5528358,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU1MjgzNTg=","avatar_url":"https://avatars1.githubusercontent.com/u/5528358?v=4","gravatar_id":"","url":"https://api.github.com/users/stb-tester","html_url":"https://github.com/stb-tester","followers_url":"https://api.github.com/users/stb-tester/followers","following_url":"https://api.github.com/users/stb-tester/following{/other_user}","gists_url":"https://api.github.com/users/stb-tester/gists{/gist_id}","starred_url":"https://api.github.com/users/stb-tester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stb-tester/subscriptions","organizations_url":"https://api.github.com/users/stb-tester/orgs","repos_url":"https://api.github.com/users/stb-tester/repos","events_url":"https://api.github.com/users/stb-tester/events{/privacy}","received_events_url":"https://api.github.com/users/stb-tester/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/stb-tester/ostree","description":"Operating system and container binary deployment and upgrades","fork":true,"url":"https://api.github.com/repos/stb-tester/ostree","forks_url":"https://api.github.com/repos/stb-tester/ostree/forks","keys_url":"https://api.github.com/repos/stb-tester/ostree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stb-tester/ostree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stb-tester/ostree/teams","hooks_url":"https://api.github.com/repos/stb-tester/ostree/hooks","issue_events_url":"https://api.github.com/repos/stb-tester/ostree/issues/events{/number}","events_url":"https://api.github.com/repos/stb-tester/ostree/events","assignees_url":"https://api.github.com/repos/stb-tester/ostree/assignees{/user}","branches_url":"https://api.github.com/repos/stb-tester/ostree/branches{/branch}","tags_url":"https://api.github.com/repos/stb-tester/ostree/tags","blobs_url":"https://api.github.com/repos/stb-tester/ostree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stb-tester/ostree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stb-tester/ostree/git/refs{/sha}","trees_url":"https://api.github.com/repos/stb-tester/ostree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stb-tester/ostree/statuses/{sha}","languages_url":"https://api.github.com/repos/stb-tester/ostree/languages","stargazers_url":"https://api.github.com/repos/stb-tester/ostree/stargazers","contributors_url":"https://api.github.com/repos/stb-tester/ostree/contributors","subscribers_url":"https://api.github.com/repos/stb-tester/ostree/subscribers","subscription_url":"https://api.github.com/repos/stb-tester/ostree/subscription","commits_url":"https://api.github.com/repos/stb-tester/ostree/commits{/sha}","git_commits_url":"https://api.github.com/repos/stb-tester/ostree/git/commits{/sha}","comments_url":"https://api.github.com/repos/stb-tester/ostree/comments{/number}","issue_comment_url":"https://api.github.com/repos/stb-tester/ostree/issues/comments{/number}","contents_url":"https://api.github.com/repos/stb-tester/ostree/contents/{+path}","compare_url":"https://api.github.com/repos/stb-tester/ostree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stb-tester/ostree/merges","archive_url":"https://api.github.com/repos/stb-tester/ostree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stb-tester/ostree/downloads","issues_url":"https://api.github.com/repos/stb-tester/ostree/issues{/number}","pulls_url":"https://api.github.com/repos/stb-tester/ostree/pulls{/number}","milestones_url":"https://api.github.com/repos/stb-tester/ostree/milestones{/number}","notifications_url":"https://api.github.com/repos/stb-tester/ostree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stb-tester/ostree/labels{/name}","releases_url":"https://api.github.com/repos/stb-tester/ostree/releases{/id}","deployments_url":"https://api.github.com/repos/stb-tester/ostree/deployments","created_at":"2016-07-19T02:16:26Z","updated_at":"2018-01-09T22:03:56Z","pushed_at":"2018-07-13T14:25:29Z","git_url":"git://github.com/stb-tester/ostree.git","ssh_url":"git@github.com:stb-tester/ostree.git","clone_url":"https://github.com/stb-tester/ostree.git","svn_url":"https://github.com/stb-tester/ostree","homepage":"https://ostree.readthedocs.org/en/latest/","size":17122,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"ostreedev:master","ref":"master","sha":"c7b12a8730260c66bc96363a3a3c5805b325bac8","user":{"login":"ostreedev","id":17928213,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTI4MjEz","avatar_url":"https://avatars1.githubusercontent.com/u/17928213?v=4","gravatar_id":"","url":"https://api.github.com/users/ostreedev","html_url":"https://github.com/ostreedev","followers_url":"https://api.github.com/users/ostreedev/followers","following_url":"https://api.github.com/users/ostreedev/following{/other_user}","gists_url":"https://api.github.com/users/ostreedev/gists{/gist_id}","starred_url":"https://api.github.com/users/ostreedev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ostreedev/subscriptions","organizations_url":"https://api.github.com/users/ostreedev/orgs","repos_url":"https://api.github.com/users/ostreedev/repos","events_url":"https://api.github.com/users/ostreedev/events{/privacy}","received_events_url":"https://api.github.com/users/ostreedev/received_events","type":"Organization","site_admin":false},"repo":{"id":4614541,"node_id":"MDEwOlJlcG9zaXRvcnk0NjE0NTQx","name":"ostree","full_name":"ostreedev/ostree","owner":{"login":"ostreedev","id":17928213,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTI4MjEz","avatar_url":"https://avatars1.githubusercontent.com/u/17928213?v=4","gravatar_id":"","url":"https://api.github.com/users/ostreedev","html_url":"https://github.com/ostreedev","followers_url":"https://api.github.com/users/ostreedev/followers","following_url":"https://api.github.com/users/ostreedev/following{/other_user}","gists_url":"https://api.github.com/users/ostreedev/gists{/gist_id}","starred_url":"https://api.github.com/users/ostreedev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ostreedev/subscriptions","organizations_url":"https://api.github.com/users/ostreedev/orgs","repos_url":"https://api.github.com/users/ostreedev/repos","events_url":"https://api.github.com/users/ostreedev/events{/privacy}","received_events_url":"https://api.github.com/users/ostreedev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ostreedev/ostree","description":"Operating system and container binary deployment and upgrades","fork":false,"url":"https://api.github.com/repos/ostreedev/ostree","forks_url":"https://api.github.com/repos/ostreedev/ostree/forks","keys_url":"https://api.github.com/repos/ostreedev/ostree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ostreedev/ostree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ostreedev/ostree/teams","hooks_url":"https://api.github.com/repos/ostreedev/ostree/hooks","issue_events_url":"https://api.github.com/repos/ostreedev/ostree/issues/events{/number}","events_url":"https://api.github.com/repos/ostreedev/ostree/events","assignees_url":"https://api.github.com/repos/ostreedev/ostree/assignees{/user}","branches_url":"https://api.github.com/repos/ostreedev/ostree/branches{/branch}","tags_url":"https://api.github.com/repos/ostreedev/ostree/tags","blobs_url":"https://api.github.com/repos/ostreedev/ostree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ostreedev/ostree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ostreedev/ostree/git/refs{/sha}","trees_url":"https://api.github.com/repos/ostreedev/ostree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ostreedev/ostree/statuses/{sha}","languages_url":"https://api.github.com/repos/ostreedev/ostree/languages","stargazers_url":"https://api.github.com/repos/ostreedev/ostree/stargazers","contributors_url":"https://api.github.com/repos/ostreedev/ostree/contributors","subscribers_url":"https://api.github.com/repos/ostreedev/ostree/subscribers","subscription_url":"https://api.github.com/repos/ostreedev/ostree/subscription","commits_url":"https://api.github.com/repos/ostreedev/ostree/commits{/sha}","git_commits_url":"https://api.github.com/repos/ostreedev/ostree/git/commits{/sha}","comments_url":"https://api.github.com/repos/ostreedev/ostree/comments{/number}","issue_comment_url":"https://api.github.com/repos/ostreedev/ostree/issues/comments{/number}","contents_url":"https://api.github.com/repos/ostreedev/ostree/contents/{+path}","compare_url":"https://api.github.com/repos/ostreedev/ostree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ostreedev/ostree/merges","archive_url":"https://api.github.com/repos/ostreedev/ostree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ostreedev/ostree/downloads","issues_url":"https://api.github.com/repos/ostreedev/ostree/issues{/number}","pulls_url":"https://api.github.com/repos/ostreedev/ostree/pulls{/number}","milestones_url":"https://api.github.com/repos/ostreedev/ostree/milestones{/number}","notifications_url":"https://api.github.com/repos/ostreedev/ostree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ostreedev/ostree/labels{/name}","releases_url":"https://api.github.com/repos/ostreedev/ostree/releases{/id}","deployments_url":"https://api.github.com/repos/ostreedev/ostree/deployments","created_at":"2012-06-10T11:22:40Z","updated_at":"2018-07-09T20:35:08Z","pushed_at":"2018-07-13T14:25:31Z","git_url":"git://github.com/ostreedev/ostree.git","ssh_url":"git@github.com:ostreedev/ostree.git","clone_url":"https://github.com/ostreedev/ostree.git","svn_url":"https://github.com/ostreedev/ostree","homepage":"https://ostree.readthedocs.org/en/latest/","size":16997,"stargazers_count":245,"watchers_count":245,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":104,"mirror_url":null,"archived":false,"open_issues_count":173,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":104,"open_issues":173,"watchers":245,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ostreedev/ostree/pulls/1658"},"html":{"href":"https://github.com/ostreedev/ostree/pull/1658"},"issue":{"href":"https://api.github.com/repos/ostreedev/ostree/issues/1658"},"comments":{"href":"https://api.github.com/repos/ostreedev/ostree/issues/1658/comments"},"review_comments":{"href":"https://api.github.com/repos/ostreedev/ostree/pulls/1658/comments"},"review_comment":{"href":"https://api.github.com/repos/ostreedev/ostree/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ostreedev/ostree/pulls/1658/commits"},"statuses":{"href":"https://api.github.com/repos/ostreedev/ostree/statuses/cdfb9e8643eedf4ff8ce958c55a80e4583ad4b3a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"wmanley"}}