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:
parent
6b4ef97c18
commit
223bccf2f6
|
|
@ -1398,28 +1398,30 @@ 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
|
||||
*
|
||||
* Load the content for @rev into @out_root.
|
||||
*/
|
||||
gboolean
|
||||
ostree_repo_read_commit (OstreeRepo *self,
|
||||
const char *rev,
|
||||
ostree_repo_read_commit (OstreeRepo *self,
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -370,11 +370,12 @@ gboolean ostree_repo_checkout_gc (OstreeRepo *self,
|
|||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_repo_read_commit (OstreeRepo *self,
|
||||
const char *rev,
|
||||
GFile **out_root,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
gboolean ostree_repo_read_commit (OstreeRepo *self,
|
||||
const char *ref,
|
||||
GFile **out_root,
|
||||
char **out_commit,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
/**
|
||||
* OstreeRepoListObjectsFlags:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue