From 77acf62274f589aafb0308defb941078404d1ae4 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Thu, 30 Jun 2016 12:41:20 -0400 Subject: [PATCH] daemon: make deploy work for local branches We would unconditionally call ostree's pull() regardless of whether the branch we were tracking was remote or not. We need this to work to make it easier to write tests, though it's a worthy addition on its own. Closes: #371 Approved by: cgwalters --- src/daemon/rpmostreed-utils.c | 51 ++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/daemon/rpmostreed-utils.c b/src/daemon/rpmostreed-utils.c index e2a4af71..5654e350 100644 --- a/src/daemon/rpmostreed-utils.c +++ b/src/daemon/rpmostreed-utils.c @@ -284,18 +284,22 @@ rpmostreed_repo_pull_ancestry (OstreeRepo *repo, while (TRUE) { - /* Floating reference, transferred to dictionary. */ - refs_value = g_variant_new_strv ((const char * const *) refs_array, -1); + if (remote != NULL) + { + /* Floating reference, transferred to dictionary. */ + refs_value = + g_variant_new_strv ((const char * const *) refs_array, -1); - g_variant_dict_init (&options, NULL); - g_variant_dict_insert (&options, "depth", "i", depth); - g_variant_dict_insert (&options, "flags", "i", flags); - g_variant_dict_insert_value (&options, "refs", refs_value); + g_variant_dict_init (&options, NULL); + g_variant_dict_insert (&options, "depth", "i", depth); + g_variant_dict_insert (&options, "flags", "i", flags); + g_variant_dict_insert_value (&options, "refs", refs_value); - if (!ostree_repo_pull_with_options (repo, remote, - g_variant_dict_end (&options), - progress, cancellable, error)) - goto out; + if (!ostree_repo_pull_with_options (repo, remote, + g_variant_dict_end (&options), + progress, cancellable, error)) + goto out; + } /* First pass only. Now we can resolve the ref to a checksum. */ if (checksum == NULL) @@ -304,26 +308,29 @@ rpmostreed_repo_pull_ancestry (OstreeRepo *repo, goto out; } - /* If depth is negative (no visitor), this loop is skipped. */ - for (ii = 0; ii < depth && checksum != NULL; ii++) + if (visitor != NULL) { - g_autoptr(GVariant) commit = NULL; - gboolean stop = FALSE; + for (ii = 0; ii < depth && checksum != NULL; ii++) + { + g_autoptr(GVariant) commit = NULL; + gboolean stop = FALSE; - if (!ostree_repo_load_commit (repo, checksum, &commit, NULL, error)) - goto out; + if (!ostree_repo_load_commit (repo, checksum, &commit, + NULL, error)) + goto out; - if (!visitor (repo, checksum, commit, visitor_data, &stop, error)) - goto out; + if (!visitor (repo, checksum, commit, visitor_data, &stop, error)) + goto out; - g_clear_pointer (&checksum, g_free); + g_clear_pointer (&checksum, g_free); - if (!stop) - checksum = ostree_commit_get_parent (commit); + if (!stop) + checksum = ostree_commit_get_parent (commit); + } } /* Break if no visitor, or visitor told us to stop. */ - if (depth < 0 || checksum == NULL) + if (visitor == NULL || checksum == NULL) break; /* Pull the next batch of commits, twice as many. */