core: Add --no-xattrs option for commit

Will be used by ostbuild.
This commit is contained in:
Colin Walters 2012-01-05 18:56:21 -05:00
parent 5c3614d644
commit 5119cbdb7c
4 changed files with 24 additions and 8 deletions

View File

@ -1452,9 +1452,12 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
modified_info = create_modified_file_info (child_info, modifier); modified_info = create_modified_file_info (child_info, modifier);
xattrs = ostree_get_xattrs_for_file (dir, error); if (!(modifier && modifier->skip_xattrs))
if (!xattrs) {
goto out; xattrs = ostree_get_xattrs_for_file (dir, error);
if (!xattrs)
goto out;
}
if (!stage_directory_meta (self, modified_info, xattrs, &child_file_checksum, if (!stage_directory_meta (self, modified_info, xattrs, &child_file_checksum,
cancellable, error)) cancellable, error))
@ -1513,9 +1516,12 @@ ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
goto out; goto out;
} }
xattrs = ostree_get_xattrs_for_file (child, error); if (!(modifier && modifier->skip_xattrs))
if (!xattrs) {
goto out; xattrs = ostree_get_xattrs_for_file (child, error);
if (!xattrs)
goto out;
}
if (!stage_object_impl (self, OSTREE_OBJECT_TYPE_RAW_FILE, if (!stage_object_impl (self, OSTREE_OBJECT_TYPE_RAW_FILE,
modified_info, xattrs, file_input, NULL, modified_info, xattrs, file_input, NULL,

View File

@ -137,10 +137,14 @@ gboolean ostree_repo_load_variant (OstreeRepo *self,
typedef struct { typedef struct {
volatile gint refcount; volatile gint refcount;
gpointer reserved[3];
gint uid; gint uid;
gint gid; gint gid;
guint reserved_flags : 31;
guint skip_xattrs : 1;
gpointer reserved[3];
} OstreeRepoCommitModifier; } OstreeRepoCommitModifier;
OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (void); OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (void);

View File

@ -38,6 +38,7 @@ static char *branch;
static char **metadata_strings; static char **metadata_strings;
static gboolean skip_if_unchanged; static gboolean skip_if_unchanged;
static gboolean tar_autocreate_parents; static gboolean tar_autocreate_parents;
static gboolean no_xattrs;
static char **trees; static char **trees;
static gint owner_uid = -1; static gint owner_uid = -1;
static gint owner_gid = -1; static gint owner_gid = -1;
@ -53,6 +54,7 @@ static GOptionEntry options[] = {
{ "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &trees, "Overlay the given argument as a tree", "NAME" }, { "tree", 0, 0, G_OPTION_ARG_STRING_ARRAY, &trees, "Overlay the given argument as a tree", "NAME" },
{ "owner-uid", 0, 0, G_OPTION_ARG_INT, &owner_uid, "Set file ownership user id", "UID" }, { "owner-uid", 0, 0, G_OPTION_ARG_INT, &owner_uid, "Set file ownership user id", "UID" },
{ "owner-gid", 0, 0, G_OPTION_ARG_INT, &owner_gid, "Set file ownership group id", "GID" }, { "owner-gid", 0, 0, G_OPTION_ARG_INT, &owner_gid, "Set file ownership group id", "GID" },
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &no_xattrs, "Do not import extended attributes", NULL },
{ "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL }, { "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
{ "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &skip_if_unchanged, "If the contents are unchanged from previous commit, do nothing", NULL }, { "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &skip_if_unchanged, "If the contents are unchanged from previous commit, do nothing", NULL },
{ NULL } { NULL }

View File

@ -19,7 +19,7 @@
set -e set -e
echo "1..22" echo "1..23"
. libtest.sh . libtest.sh
@ -169,3 +169,7 @@ $OSTREE show test2 > test2-commit-text
assert_file_has_content test2-commit-text "'FOO'.*'BAR'" assert_file_has_content test2-commit-text "'FOO'.*'BAR'"
assert_file_has_content test2-commit-text "'KITTENS'.*'CUTE'" assert_file_has_content test2-commit-text "'KITTENS'.*'CUTE'"
echo "ok metadata commit with strings" echo "ok metadata commit with strings"
cd ${test_tmpdir}/checkout-test2-4
$OSTREE commit -b test2 -s "no xattrs" --no-xattrs
echo "ok commit with no xattrs"