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;
|
||||
}
|
||||
|
||||
struct OstreeRepoCommitModifier {
|
||||
volatile gint refcount;
|
||||
|
||||
OstreeRepoCommitModifierFlags flags;
|
||||
OstreeRepoCommitFilter filter;
|
||||
gpointer user_data;
|
||||
};
|
||||
|
||||
static OstreeRepoCommitFilterResult
|
||||
apply_commit_filter (OstreeRepo *self,
|
||||
OstreeRepoCommitModifier *modifier,
|
||||
|
|
@ -1627,7 +1635,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self,
|
|||
if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW)
|
||||
{
|
||||
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))
|
||||
goto out;
|
||||
|
|
@ -1722,7 +1730,7 @@ stage_directory_to_mtree_internal (OstreeRepo *self,
|
|||
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);
|
||||
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:
|
||||
* @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.
|
||||
*/
|
||||
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);
|
||||
|
||||
modifier->refcount = 1;
|
||||
modifier->flags = flags;
|
||||
modifier->filter = commit_filter;
|
||||
modifier->user_data = user_data;
|
||||
|
||||
return modifier;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,24 +250,26 @@ typedef OstreeRepoCommitFilterResult (*OstreeRepoCommitFilter) (OstreeRepo *r
|
|||
GFileInfo *file_info,
|
||||
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:
|
||||
*
|
||||
* A structure allowing control over commits.
|
||||
*/
|
||||
typedef struct {
|
||||
volatile gint refcount;
|
||||
typedef struct OstreeRepoCommitModifier OstreeRepoCommitModifier;
|
||||
|
||||
guint reserved_flags : 31;
|
||||
guint skip_xattrs : 1;
|
||||
|
||||
OstreeRepoCommitFilter filter;
|
||||
gpointer user_data;
|
||||
|
||||
gpointer reserved[3];
|
||||
} OstreeRepoCommitModifier;
|
||||
|
||||
OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (void);
|
||||
OstreeRepoCommitModifier *ostree_repo_commit_modifier_new (OstreeRepoCommitModifierFlags flags,
|
||||
OstreeRepoCommitFilter commit_filter,
|
||||
gpointer user_data);
|
||||
|
||||
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
|
||||
|| opt_no_xattrs)
|
||||
{
|
||||
modifier = ostree_repo_commit_modifier_new ();
|
||||
modifier->skip_xattrs = opt_no_xattrs;
|
||||
modifier->filter = commit_filter;
|
||||
modifier->user_data = mode_adds;
|
||||
OstreeRepoCommitModifierFlags flags = 0;
|
||||
if (opt_no_xattrs)
|
||||
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
|
||||
modifier = ostree_repo_commit_modifier_new (flags, commit_filter, mode_adds);
|
||||
}
|
||||
|
||||
if (!ostree_repo_resolve_rev (repo, opt_branch, TRUE, &parent, error))
|
||||
|
|
|
|||
Loading…
Reference in New Issue