Add _ostree_repo_mode_is_bare helper

This cleans up some existing code, but it also allows us to later
add new bare modes.

Closes: #750
Approved by: cgwalters
This commit is contained in:
Alexander Larsson authored and Atomic Bot committed 2017-03-27 13:48:41 +00:00
1 parent 455cc5e892
commit 612150f143
4 files changed
+13 -7

No files matched your search

+8
View File
@@ -139,6 +139,14 @@ _ostree_loose_path (char *buf,
#define _OSTREE_METADATA_GPGSIGS_NAME "ostree.gpgsigs"
#define _OSTREE_METADATA_GPGSIGS_TYPE G_VARIANT_TYPE ("aay")
static inline gboolean
_ostree_repo_mode_is_bare (OstreeRepoMode mode)
{
return
mode == OSTREE_REPO_MODE_BARE ||
mode == OSTREE_REPO_MODE_BARE_USER;
}
GVariant *
_ostree_detached_metadata_append_gpg_sig (GVariant *existing_metadata,
GBytes *signature_bytes);
+1 -1
View File
@@ -363,7 +363,7 @@ checkout_file_hardlink (OstreeRepo *self,
GError **error)
{
HardlinkResult ret_result = HARDLINK_RESULT_NOT_SUPPORTED;
int srcfd = (self->mode == OSTREE_REPO_MODE_BARE || self->mode == OSTREE_REPO_MODE_BARE_USER) ?
int srcfd = _ostree_repo_mode_is_bare (self->mode) ?
self->objects_dir_fd : self->uncompressed_objects_dir_fd;
again:
+2 -3
View File
@@ -306,8 +306,7 @@ commit_loose_object_trusted (OstreeRepo *self,
goto out;
}
if (objtype == OSTREE_OBJECT_TYPE_FILE && (self->mode == OSTREE_REPO_MODE_BARE ||
self->mode == OSTREE_REPO_MODE_BARE_USER))
if (objtype == OSTREE_OBJECT_TYPE_FILE && _ostree_repo_mode_is_bare (self->mode))
{
/* To satisfy tools such as guile which compare mtimes
* to determine whether or not source files need to be compiled,
@@ -700,7 +699,7 @@ write_object (OstreeRepo *self,
* binary with trailing garbage, creating a window on the local
* system where a malicious setuid binary exists.
*/
if ((repo_mode == OSTREE_REPO_MODE_BARE || repo_mode == OSTREE_REPO_MODE_BARE_USER) && temp_file_is_regular)
if ((_ostree_repo_mode_is_bare (repo_mode)) && temp_file_is_regular)
{
guint64 size = g_file_info_get_size (file_info);
+2 -3
View File
@@ -2472,7 +2472,7 @@ list_loose_objects_at (OstreeRepo *self,
if ((self->mode == OSTREE_REPO_MODE_ARCHIVE_Z2
&& strcmp (dot, ".filez") == 0) ||
((self->mode == OSTREE_REPO_MODE_BARE || self->mode == OSTREE_REPO_MODE_BARE_USER)
((_ostree_repo_mode_is_bare (self->mode))
&& strcmp (dot, ".file") == 0))
objtype = OSTREE_OBJECT_TYPE_FILE;
else if (strcmp (dot, ".dirtree") == 0)
@@ -2743,8 +2743,7 @@ _ostree_repo_read_bare_fd (OstreeRepo *self,
{
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
g_assert (self->mode == OSTREE_REPO_MODE_BARE ||
self->mode == OSTREE_REPO_MODE_BARE_USER);
g_assert (_ostree_repo_mode_is_bare (self->mode));
_ostree_loose_path (loose_path_buf, checksum, OSTREE_OBJECT_TYPE_FILE, self->mode);