pull: new option --commit-metadata-only
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
1 parent
56f0ae6a4a
commit
11ba9056ea
7 files changed
+72
-2
No files matched your search
@@ -88,6 +88,7 @@ typedef struct {
|
||||
guint64 start_time;
|
||||
|
||||
gboolean is_mirror;
|
||||
gboolean is_commit_only;
|
||||
|
||||
char *dir;
|
||||
gboolean commitpartial_exists;
|
||||
@@ -1119,6 +1120,11 @@ scan_one_metadata_object_c (OtPullData *pull_data,
|
||||
do_fetch_detached = (objtype == OSTREE_OBJECT_TYPE_COMMIT);
|
||||
enqueue_one_object_request (pull_data, tmp_checksum, objtype, do_fetch_detached, FALSE);
|
||||
}
|
||||
else if (objtype == OSTREE_OBJECT_TYPE_COMMIT && pull_data->is_commit_only)
|
||||
{
|
||||
ret = TRUE;
|
||||
goto out;
|
||||
}
|
||||
else if (is_stored)
|
||||
{
|
||||
gboolean do_scan = pull_data->transaction_resuming || is_requested || pull_data->commitpartial_exists;
|
||||
@@ -1654,6 +1660,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
g_return_val_if_fail (dir_to_pull[0] == '/', FALSE);
|
||||
|
||||
pull_data->is_mirror = (flags & OSTREE_REPO_PULL_FLAGS_MIRROR) > 0;
|
||||
pull_data->is_commit_only = (flags & OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY) > 0;
|
||||
|
||||
pull_data->async_error = error;
|
||||
pull_data->main_context = g_main_context_ref_thread_default ();
|
||||
@@ -2160,7 +2167,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||
}
|
||||
|
||||
/* iterate over commits fetched and delete any commitpartial files */
|
||||
if (!dir_to_pull)
|
||||
if (!dir_to_pull && !pull_data->is_commit_only)
|
||||
{
|
||||
g_hash_table_iter_init (&hash_iter, requested_refs_to_fetch);
|
||||
while (g_hash_table_iter_next (&hash_iter, &key, &value))
|
||||
|
||||
@@ -3674,6 +3674,9 @@ ostree_repo_read_commit (OstreeRepo *self,
|
||||
* the @refs_to_fetch is %NULL, and the remote repository contains a
|
||||
* summary file, then all refs will be fetched.
|
||||
*
|
||||
* If @flags contains %OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY, then only the
|
||||
* metadata for the commits in @refs_to_fetch is pulled.
|
||||
*
|
||||
* Warning: This API will iterate the thread default main context,
|
||||
* which is a bug, but kept for compatibility reasons. If you want to
|
||||
* avoid this, use g_main_context_push_thread_default() to push a new
|
||||
|
||||
@@ -693,10 +693,12 @@ gboolean ostree_repo_prune (OstreeRepo *self,
|
||||
* OstreeRepoPullFlags:
|
||||
* @OSTREE_REPO_PULL_FLAGS_NONE: No special options for pull
|
||||
* @OSTREE_REPO_PULL_FLAGS_MIRROR: Write out refs suitable for mirrors
|
||||
* @OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY: Fetch only the commit metadata
|
||||
*/
|
||||
typedef enum {
|
||||
OSTREE_REPO_PULL_FLAGS_NONE,
|
||||
OSTREE_REPO_PULL_FLAGS_MIRROR
|
||||
OSTREE_REPO_PULL_FLAGS_MIRROR = (1 << 0),
|
||||
OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY = (1 << 1)
|
||||
} OstreeRepoPullFlags;
|
||||
|
||||
gboolean ostree_repo_pull (OstreeRepo *self,
|
||||
|
||||
@@ -29,11 +29,13 @@
|
||||
|
||||
static gboolean opt_disable_fsync;
|
||||
static gboolean opt_mirror;
|
||||
static gboolean opt_commit_only;
|
||||
static gboolean opt_disable_static_deltas;
|
||||
static char* opt_subpath;
|
||||
static int opt_depth = 0;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "commit-metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_commit_only, "Fetch only the commit metadata", NULL },
|
||||
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
|
||||
{ "disable-static-deltas", 0, 0, G_OPTION_ARG_NONE, &opt_disable_static_deltas, "Do not use static deltas", NULL },
|
||||
{ "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror, "Write refs suitable for a mirror", NULL },
|
||||
@@ -91,6 +93,9 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
|
||||
if (opt_mirror)
|
||||
pullflags |= OSTREE_REPO_PULL_FLAGS_MIRROR;
|
||||
|
||||
if (opt_commit_only)
|
||||
pullflags |= OSTREE_REPO_PULL_FLAGS_COMMIT_ONLY;
|
||||
|
||||
if (strchr (argv[1], ':') == NULL)
|
||||
{
|
||||
remote = g_strdup (argv[1]);
|
||||
|
||||
Reference in new issue
Block a user