repo: Make read_commit spit out a resolved commit ref as well

read_commit resolves the ref to a commit, and a lot of consumers want
the resolved commit for their own purposes; this prevents them from
calling resolve_rev themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
This commit is contained in:
Jasper St. Pierre 2013-09-07 14:21:24 -04:00
parent 6b4ef97c18
commit 223bccf2f6
8 changed files with 23 additions and 19 deletions

View File

@ -1398,8 +1398,9 @@ ostree_repo_list_objects (OstreeRepo *self,
/**
* ostree_repo_read_commit:
* @self: Repo
* @rev: Revision (ref or ASCII checksum)
* @ref: Ref or ASCII checksum
* @out_root: (out): An #OstreeRepoFile corresponding to the root
* @out_commit: (out): The resolved commit checksum
* @cancellable: Cancellable
* @error: Error
*
@ -1407,19 +1408,20 @@ ostree_repo_list_objects (OstreeRepo *self,
*/
gboolean
ostree_repo_read_commit (OstreeRepo *self,
const char *rev,
const char *ref,
GFile **out_root,
char **out_commit,
GCancellable *cancellable,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object OstreeRepoFile *ret_root = NULL;
gs_free char *resolved_rev = NULL;
gs_free char *resolved_commit = NULL;
if (!ostree_repo_resolve_rev (self, rev, FALSE, &resolved_rev, error))
if (!ostree_repo_resolve_rev (self, ref, FALSE, &resolved_commit, error))
goto out;
ret_root = _ostree_repo_file_new_for_commit (self, resolved_rev, error);
ret_root = _ostree_repo_file_new_for_commit (self, resolved_commit, error);
if (!ret_root)
goto out;
@ -1428,6 +1430,7 @@ ostree_repo_read_commit (OstreeRepo *self,
ret = TRUE;
ot_transfer_out_value(out_root, (GFile **) &ret_root);
ot_transfer_out_value(out_commit, &resolved_commit);
out:
return ret;
}

View File

@ -371,8 +371,9 @@ gboolean ostree_repo_checkout_gc (OstreeRepo *self,
GError **error);
gboolean ostree_repo_read_commit (OstreeRepo *self,
const char *rev,
const char *ref,
GFile **out_root,
char **out_commit,
GCancellable *cancellable,
GError **error);

View File

@ -216,7 +216,7 @@ checkout_deployment_tree (GFile *sysroot,
gs_unref_object GFile *deploy_target_path = NULL;
gs_unref_object GFile *deploy_parent = NULL;
if (!ostree_repo_read_commit (repo, csum, &root, cancellable, error))
if (!ostree_repo_read_commit (repo, csum, &root, NULL, cancellable, error))
goto out;
file_info = g_file_query_info (root, OSTREE_GIO_FAST_QUERYINFO,
@ -1115,7 +1115,7 @@ ot_admin_deploy (GFile *sysroot,
goto out;
}
if (!ostree_repo_read_commit (repo, revision, &commit_root, cancellable, error))
if (!ostree_repo_read_commit (repo, revision, &commit_root, NULL, cancellable, error))
goto out;
if (!get_kernel_from_tree (commit_root, &tree_kernel_path, &tree_initramfs_path,

View File

@ -78,7 +78,7 @@ ostree_builtin_cat (int argc, char **argv, OstreeRepo *repo, GCancellable *cance
}
rev = argv[1];
if (!ostree_repo_read_commit (repo, rev, &root, NULL, error))
if (!ostree_repo_read_commit (repo, rev, &root, NULL, NULL, error))
goto out;
stdout_stream = g_unix_output_stream_new (1, FALSE);

View File

@ -60,7 +60,7 @@ process_one_checkout (OstreeRepo *repo,
gs_unref_object GFile *subtree = NULL;
gs_unref_object GFileInfo *file_info = NULL;
if (!ostree_repo_read_commit (repo, resolved_commit, &root, cancellable, error))
if (!ostree_repo_read_commit (repo, resolved_commit, &root, NULL, cancellable, error))
goto out;
if (subpath)

View File

@ -393,7 +393,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
}
else if (strcmp (tree_type, "ref") == 0)
{
if (!ostree_repo_read_commit (repo, tree, &arg, cancellable, error))
if (!ostree_repo_read_commit (repo, tree, &arg, NULL, cancellable, error))
goto out;
if (!ostree_repo_write_directory_to_mtree (repo, arg, mtree, modifier,
@ -440,7 +440,7 @@ ostree_builtin_commit (int argc, char **argv, OstreeRepo *repo, GCancellable *ca
{
gs_unref_object GFile *parent_root;
if (!ostree_repo_read_commit (repo, parent, &parent_root, cancellable, error))
if (!ostree_repo_read_commit (repo, parent, &parent_root, NULL, cancellable, error))
goto out;
if (g_file_equal (root, parent_root))

View File

@ -53,7 +53,7 @@ parse_file_or_commit (OstreeRepo *repo,
}
else
{
if (!ostree_repo_read_commit (repo, arg, &ret_file, cancellable, error))
if (!ostree_repo_read_commit (repo, arg, &ret_file, NULL, cancellable, error))
goto out;
}

View File

@ -260,7 +260,7 @@ ostree_builtin_ls (int argc, char **argv, OstreeRepo *repo, GCancellable *cancel
}
rev = argv[1];
if (!ostree_repo_read_commit (repo, rev, &root, cancellable, error))
if (!ostree_repo_read_commit (repo, rev, &root, NULL, cancellable, error))
goto out;
if (argc > 2)