From 4ac27caefd30aa10f2a82cc38bf9e8df095619e0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 11 Jun 2014 16:40:50 -0400 Subject: [PATCH] log: Print a friendly error if we haven't downloaded the complete history For the local repository on the system, it's not the usual case to have the complete compose history. Rather than erroring out, provide a bit more friendly message. https://bugzilla.gnome.org/show_bug.cgi?id=731538 --- src/ostree/ot-builtin-log.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ostree/ot-builtin-log.c b/src/ostree/ot-builtin-log.c index 0ab134c3..89445cd9 100644 --- a/src/ostree/ot-builtin-log.c +++ b/src/ostree/ot-builtin-log.c @@ -37,21 +37,36 @@ static GOptionEntry options[] = { static gboolean log_commit (OstreeRepo *repo, const gchar *checksum, + gboolean is_recurse, OstreeDumpFlags flags, GError **error) { gs_unref_variant GVariant *variant = NULL; gs_free gchar *parent = NULL; gboolean ret = FALSE; + GError *local_error = NULL; - if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, &variant, error)) - goto out; + if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, checksum, + &variant, &local_error)) + { + if (is_recurse && g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) + { + g_print ("<< History beyond this commit not fetched >>\n"); + g_clear_error (&local_error); + ret = TRUE; + } + else + { + g_propagate_error (error, local_error); + } + goto out; + } ot_dump_object (OSTREE_OBJECT_TYPE_COMMIT, checksum, variant, flags); /* Get the parent of this commit */ parent = ostree_commit_get_parent (variant); - if (parent && !log_commit (repo, parent, flags, error)) + if (parent && !log_commit (repo, parent, TRUE, flags, error)) goto out; ret = TRUE; @@ -91,7 +106,7 @@ ostree_builtin_log (int argc, if (!ostree_repo_resolve_rev (repo, rev, FALSE, &checksum, error)) goto out; - if (!log_commit (repo, checksum, flags, error)) + if (!log_commit (repo, checksum, FALSE, flags, error)) goto out; ret = TRUE;