[ostree] checkout: Add --allow-noent option
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] checkout: Add --allow-noent option
- Date: Wed, 1 May 2013 16:17:45 +0000 (UTC)
commit c60c70e9a9d82cef81081b574b1e4ce4e91387df
Author: Colin Walters <walters verbum org>
Date: Wed May 1 12:15:02 2013 -0400
checkout: Add --allow-noent option
This is useful for the gnome-ostree build system where each build is
one commit, but it's split up into /runtime /devel /debug etc. trees.
Ideally we wouldn't have a /debug subdirectory for "noarch"
components for example.
So add an option to not error out if the given path doesn't exist in
the commit.
src/ostree/ot-builtin-checkout.c | 19 +++++++++++++++++--
tests/t0000-basic.sh | 13 ++++++++++++-
2 files changed, 29 insertions(+), 3 deletions(-)
---
diff --git a/src/ostree/ot-builtin-checkout.c b/src/ostree/ot-builtin-checkout.c
index 2b63851..a90795c 100644
--- a/src/ostree/ot-builtin-checkout.c
+++ b/src/ostree/ot-builtin-checkout.c
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
static gboolean opt_user_mode;
+static gboolean opt_allow_noent;
static gboolean opt_no_triggers;
static char *opt_subpath;
static gboolean opt_union;
@@ -40,6 +41,7 @@ static GOptionEntry options[] = {
{ "user-mode", 'U', 0, G_OPTION_ARG_NONE, &opt_user_mode, "Do not change file ownership or initialize
extended attributes", NULL },
{ "subpath", 0, 0, G_OPTION_ARG_STRING, &opt_subpath, "Checkout sub-directory PATH", "PATH" },
{ "union", 0, 0, G_OPTION_ARG_NONE, &opt_union, "Keep existing directories, overwrite existing files",
NULL },
+ { "allow-noent", 0, 0, G_OPTION_ARG_NONE, &opt_allow_noent, "Do nothing if specified path does not exist",
NULL },
{ "no-triggers", 0, 0, G_OPTION_ARG_NONE, &opt_no_triggers, "Don't run triggers", NULL },
{ "from-stdin", 0, 0, G_OPTION_ARG_NONE, &opt_from_stdin, "Process many checkouts from standard input",
NULL },
{ "from-file", 0, 0, G_OPTION_ARG_STRING, &opt_from_file, "Process many checkouts from input file", NULL },
@@ -89,6 +91,7 @@ process_one_checkout (OstreeRepo *repo,
{
gboolean ret = FALSE;
ProcessOneCheckoutData data;
+ GError *tmp_error = NULL;
ot_lobj OstreeRepoFile *root = NULL;
ot_lobj OstreeRepoFile *subtree = NULL;
ot_lobj GFileInfo *file_info = NULL;
@@ -106,9 +109,21 @@ process_one_checkout (OstreeRepo *repo,
file_info = g_file_query_info ((GFile*)subtree, OSTREE_GIO_FAST_QUERYINFO,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
- cancellable, error);
+ cancellable, &tmp_error);
if (!file_info)
- goto out;
+ {
+ if (opt_allow_noent
+ && g_error_matches (tmp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ g_clear_error (&tmp_error);
+ ret = TRUE;
+ }
+ else
+ {
+ g_propagate_error (error, tmp_error);
+ }
+ goto out;
+ }
data.loop = g_main_loop_new (NULL, TRUE);
data.error = error;
diff --git a/tests/t0000-basic.sh b/tests/t0000-basic.sh
index bed1107..60c20a6 100755
--- a/tests/t0000-basic.sh
+++ b/tests/t0000-basic.sh
@@ -19,7 +19,7 @@
set -e
-echo "1..28"
+echo "1..30"
. libtest.sh
@@ -208,3 +208,14 @@ rm -rf test2-checkout
parent_rev_test2=$(ostree --repo=repo rev-parse test2)
${CMD_PREFIX} ostree --repo=shadow-repo checkout "${parent_rev_test2}" test2-checkout
echo "ok checkout from shadow repo"
+
+cd ${test_tmpdir}
+rm -f expected-fail
+$OSTREE checkout test2 --subpath /enoent 2>/dev/null || touch expected-fail
+assert_has_file expected-fail
+echo "ok subdir enoent"
+
+cd ${test_tmpdir}
+$OSTREE checkout test2 --allow-noent --subpath /enoent 2>/dev/null
+echo "ok subdir noent"
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]