libostree: Improve commit filter API
Make the structure private, and document the flags. https://bugzilla.gnome.org/show_bug.cgi?id=706214
This commit is contained in:
parent
94ce562905
commit
6c61b19107
|
|
@ -1534,6 +1534,14 @@ create_tree_variant_from_hashes (GHashTable *file_checksums,
|
||||||
return serialized_tree;
|
return serialized_tree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct OstreeRepoCommitModifier {
|
||||||
|
volatile gint refcount;
|
||||||
|
|
||||||
|
OstreeRepoCommitModifierFlags flags;
|
||||||
|
OstreeRepoCommitFilter filter;
|
||||||
|
gpointer user_data;
|
||||||
|
};
|
||||||
|
|
||||||
static OstreeRepoCommitFilterResult
|
static OstreeRepoCommitFilterResult
|
||||||
apply_commit_filter (OstreeRepo *self,
|
apply_commit_filter (OstreeRepo *self,
|
||||||
OstreeRepoCommitModifier *modifier,
|
OstreeRepoCommitModifier *modifier,
|
||||||
|
|
@ -1627,7 +1635,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self,
|
||||||
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
|
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
|
||||||
{
|
{
|
||||||
g_debug ("Adding: %s", gs_file_get_path_cached (dir));
|
g_debug ("Adding: %s", gs_file_get_path_cached (dir));
|
||||||
if (!(modifier && modifier->skip_xattrs))
|
if (!(modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS) > 0))
|
||||||
{
|
{
|
||||||
if (!ostree_get_xattrs_for_file (dir, &xattrs, cancellable, error))
|
if (!ostree_get_xattrs_for_file (dir, &xattrs, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -1722,7 +1730,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(modifier && modifier->skip_xattrs))
|
if (!(modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS) > 0))
|
||||||
{
|
{
|
||||||
g_clear_pointer (&xattrs, (GDestroyNotify) g_variant_unref);
|
g_clear_pointer (&xattrs, (GDestroyNotify) g_variant_unref);
|
||||||
if (!ostree_get_xattrs_for_file (child, &xattrs, cancellable, error))
|
if (!ostree_get_xattrs_for_file (child, &xattrs, cancellable, error))
|
||||||
|
|
@ -1875,15 +1883,23 @@ ostree_repo_stage_mtree (OstreeRepo *self,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ostree_repo_commit_modifier_new:
|
* ostree_repo_commit_modifier_new:
|
||||||
|
* @flags: Control options for filter
|
||||||
|
* @commit_filter: (allow-none): Function that can inspect individual files
|
||||||
|
* @user_data: (allow-none): User data
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): A new commit modifier.
|
* Returns: (transfer full): A new commit modifier.
|
||||||
*/
|
*/
|
||||||
OstreeRepoCommitModifier *
|
OstreeRepoCommitModifier *
|
||||||
ostree_repo_commit_modifier_new (void)
|
ostree_repo_commit_modifier_new (OstreeRepoCommitModifierFlags flags,
|
||||||
|
OstreeRepoCommitFilter commit_filter,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
OstreeRepoCommitModifier *modifier = g_new0 (OstreeRepoCommitModifier, 1);
|
OstreeRepoCommitModifier *modifier = g_new0 (OstreeRepoCommitModifier, 1);
|
||||||
|
|
||||||
modifier->refcount = 1;
|
modifier->refcount = 1;
|
||||||
|
modifier->flags = flags;
|
||||||
|
modifier->filter = commit_filter;
|
||||||
|
modifier->user_data = user_data;
|
||||||
|
|
||||||
return modifier;
|
return modifier;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -250,24 +250,26 @@ typedef OstreeRepoCommitFilterResult (*OstreeRepoCommitFilter) (OstreeRepo *r
|
||||||
GFileInfo *file_info,
|
GFileInfo *file_info,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OstreeRepoCommitModifierFlags:
|
||||||
|
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE: No special flags
|
||||||
|
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS: Do not process extended attributes
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE = 0,
|
||||||
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS = (1 << 0)
|
||||||
|
} OstreeRepoCommitModifierFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OstreeRepoCommitModifier:
|
* OstreeRepoCommitModifier:
|
||||||
*
|
*
|
||||||
* A structure allowing control over commits.
|
* A structure allowing control over commits.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct OstreeRepoCommitModifier OstreeRepoCommitModifier;
|
||||||
volatile gint refcount;
|
|
||||||
|
|
||||||
guint reserved_flags : 31;
|
OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (OstreeRepoCommitModifierFlags flags,
|
||||||
guint skip_xattrs : 1;
|
OstreeRepoCommitFilter commit_filter,
|
||||||
|
gpointer user_data);
|
||||||
OstreeRepoCommitFilter filter;
|
|
||||||
gpointer user_data;
|
|
||||||
|
|
||||||
gpointer reserved[3];
|
|
||||||
} OstreeRepoCommitModifier;
|
|
||||||
|
|
||||||
OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (void);
|
|
||||||
|
|
||||||
GType ostree_repo_commit_modifier_get_type (void);
|
GType ostree_repo_commit_modifier_get_type (void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,10 +194,10 @@ ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GCancellable *ca
|
||||||
if (opt_owner_uid >= 0 || opt_owner_gid >= 0 || opt_statoverride_file != NULL
|
if (opt_owner_uid >= 0 || opt_owner_gid >= 0 || opt_statoverride_file != NULL
|
||||||
|| opt_no_xattrs)
|
|| opt_no_xattrs)
|
||||||
{
|
{
|
||||||
modifier = ostree_repo_commit_modifier_new ();
|
OstreeRepoCommitModifierFlags flags = 0;
|
||||||
modifier->skip_xattrs = opt_no_xattrs;
|
if (opt_no_xattrs)
|
||||||
modifier->filter = commit_filter;
|
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
|
||||||
modifier->user_data = mode_adds;
|
modifier = ostree_repo_commit_modifier_new (flags, commit_filter, mode_adds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue