From 2aa0251b1b3dfc1bf06840c8e1fa35e59534c9e2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 9 Jul 2013 19:59:39 -0400 Subject: [PATCH] libostree: Rename ostree-traverse.h into OstreeRepo namespace This operates on the repo, it might as well be methods on it. --- Makefile-libostree.am | 3 +- ...tree-traverse.c => ostree-repo-traverse.c} | 26 +++++------ src/libostree/ostree-repo.h | 16 +++++++ src/libostree/ostree-traverse.h | 46 ------------------- src/libostree/ostree.h | 1 - src/ostree/ostree-prune.c | 10 ++-- src/ostree/ot-builtin-fsck.c | 6 +-- src/ostree/ot-builtin-pull-local.c | 8 ++-- 8 files changed, 43 insertions(+), 73 deletions(-) rename src/libostree/{ostree-traverse.c => ostree-repo-traverse.c} (90%) delete mode 100644 src/libostree/ostree-traverse.h diff --git a/Makefile-libostree.am b/Makefile-libostree.am index 1ad3b634..3de3469b 100644 --- a/Makefile-libostree.am +++ b/Makefile-libostree.am @@ -34,6 +34,7 @@ libostree_la_SOURCES = src/libostree/ostree.h \ src/libostree/ostree-repo-checkout.c \ src/libostree/ostree-repo-libarchive.c \ src/libostree/ostree-repo-refs.c \ + src/libostree/ostree-repo-traverse.c \ src/libostree/ostree-repo.h \ src/libostree/ostree-repo-private.h \ src/libostree/ostree-repo-file.c \ @@ -41,8 +42,6 @@ libostree_la_SOURCES = src/libostree/ostree.h \ src/libostree/ostree-repo-file-enumerator.c \ src/libostree/ostree-repo-file-enumerator.h \ src/libostree/ostree-types.h \ - src/libostree/ostree-traverse.c \ - src/libostree/ostree-traverse.h \ $(NULL) if USE_LIBARCHIVE libostree_la_SOURCES += src/libostree/ostree-libarchive-input-stream.h \ diff --git a/src/libostree/ostree-traverse.c b/src/libostree/ostree-repo-traverse.c similarity index 90% rename from src/libostree/ostree-traverse.c rename to src/libostree/ostree-repo-traverse.c index 88691710..70b22d7a 100644 --- a/src/libostree/ostree-traverse.c +++ b/src/libostree/ostree-repo-traverse.c @@ -28,7 +28,7 @@ #include "otutil.h" GHashTable * -ostree_traverse_new_reachable (void) +ostree_repo_traverse_new_reachable (void) { return g_hash_table_new_full (ostree_hash_object_name, g_variant_equal, (GDestroyNotify)g_variant_unref, NULL); @@ -119,11 +119,11 @@ traverse_dirtree_internal (OstreeRepo *repo, } gboolean -ostree_traverse_dirtree (OstreeRepo *repo, - const char *dirtree_checksum, - GHashTable *inout_reachable, - GCancellable *cancellable, - GError **error) +ostree_repo_traverse_dirtree (OstreeRepo *repo, + const char *dirtree_checksum, + GHashTable *inout_reachable, + GCancellable *cancellable, + GError **error) { return traverse_dirtree_internal (repo, dirtree_checksum, 0, inout_reachable, cancellable, error); @@ -136,12 +136,12 @@ ostree_traverse_dirtree (OstreeRepo *repo, * @commit_checksum, traversing @maxdepth parent commits. */ gboolean -ostree_traverse_commit (OstreeRepo *repo, - const char *commit_checksum, - int maxdepth, - GHashTable *inout_reachable, - GCancellable *cancellable, - GError **error) +ostree_repo_traverse_commit (OstreeRepo *repo, + const char *commit_checksum, + int maxdepth, + GHashTable *inout_reachable, + GCancellable *cancellable, + GError **error) { gboolean ret = FALSE; gs_free char*tmp_checksum = NULL; @@ -199,7 +199,7 @@ ostree_traverse_commit (OstreeRepo *repo, } tmp_checksum = ostree_checksum_from_bytes_v (content_csum_bytes); - if (!ostree_traverse_dirtree (repo, tmp_checksum, inout_reachable, cancellable, error)) + if (!ostree_repo_traverse_dirtree (repo, tmp_checksum, inout_reachable, cancellable, error)) goto out; if (maxdepth == -1 || maxdepth > 0) diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h index 6a694ee5..8b5b55b0 100644 --- a/src/libostree/ostree-repo.h +++ b/src/libostree/ostree-repo.h @@ -317,5 +317,21 @@ gboolean ostree_repo_list_objects (OstreeRepo *self, GCancellable *cancellable, GError **error); +GHashTable *ostree_repo_traverse_new_reachable (void); + +gboolean ostree_repo_traverse_dirtree (OstreeRepo *repo, + const char *commit_checksum, + GHashTable *inout_reachable, + GCancellable *cancellable, + GError **error); + +gboolean ostree_repo_traverse_commit (OstreeRepo *repo, + const char *commit_checksum, + int maxdepth, + GHashTable *inout_reachable, + GCancellable *cancellable, + GError **error); + + G_END_DECLS diff --git a/src/libostree/ostree-traverse.h b/src/libostree/ostree-traverse.h deleted file mode 100644 index 59a9adea..00000000 --- a/src/libostree/ostree-traverse.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2011 Colin Walters - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Colin Walters - */ - -#pragma once - -#include "ostree-core.h" -#include "ostree-types.h" - -G_BEGIN_DECLS - -GHashTable *ostree_traverse_new_reachable (void); - -gboolean ostree_traverse_dirtree (OstreeRepo *repo, - const char *commit_checksum, - GHashTable *inout_reachable, - GCancellable *cancellable, - GError **error); - -gboolean ostree_traverse_commit (OstreeRepo *repo, - const char *commit_checksum, - int maxdepth, - GHashTable *inout_reachable, - GCancellable *cancellable, - GError **error); - -G_END_DECLS - diff --git a/src/libostree/ostree.h b/src/libostree/ostree.h index ea75f6f7..758e45a4 100644 --- a/src/libostree/ostree.h +++ b/src/libostree/ostree.h @@ -28,5 +28,4 @@ #include #include #include -#include #include diff --git a/src/ostree/ostree-prune.c b/src/ostree/ostree-prune.c index beaf2069..741e6b88 100644 --- a/src/ostree/ostree-prune.c +++ b/src/ostree/ostree-prune.c @@ -106,7 +106,7 @@ ostree_prune (OstreeRepo *repo, memset (&data, 0, sizeof (data)); data.repo = repo; - data.reachable = ostree_traverse_new_reachable (); + data.reachable = ostree_repo_traverse_new_reachable (); if (refs_only) { @@ -120,8 +120,8 @@ ostree_prune (OstreeRepo *repo, { const char *checksum = value; - if (!ostree_traverse_commit (repo, checksum, depth, data.reachable, - cancellable, error)) + if (!ostree_repo_traverse_commit (repo, checksum, depth, data.reachable, + cancellable, error)) goto out; } } @@ -144,8 +144,8 @@ ostree_prune (OstreeRepo *repo, if (objtype != OSTREE_OBJECT_TYPE_COMMIT) continue; - if (!ostree_traverse_commit (repo, checksum, depth, data.reachable, - cancellable, error)) + if (!ostree_repo_traverse_commit (repo, checksum, depth, data.reachable, + cancellable, error)) goto out; } } diff --git a/src/ostree/ot-builtin-fsck.c b/src/ostree/ot-builtin-fsck.c index 822c22b5..65dd70b3 100644 --- a/src/ostree/ot-builtin-fsck.c +++ b/src/ostree/ot-builtin-fsck.c @@ -58,7 +58,7 @@ fsck_reachable_objects_from_commits (OtFsckData *data, gs_free guchar *computed_csum = NULL; gs_free char *tmp_checksum = NULL; - reachable_objects = ostree_traverse_new_reachable (); + reachable_objects = ostree_repo_traverse_new_reachable (); g_hash_table_iter_init (&hash_iter, commits); while (g_hash_table_iter_next (&hash_iter, &key, &value)) @@ -71,8 +71,8 @@ fsck_reachable_objects_from_commits (OtFsckData *data, g_assert (objtype == OSTREE_OBJECT_TYPE_COMMIT); - if (!ostree_traverse_commit (data->repo, checksum, 0, reachable_objects, - cancellable, error)) + if (!ostree_repo_traverse_commit (data->repo, checksum, 0, reachable_objects, + cancellable, error)) goto out; } diff --git a/src/ostree/ot-builtin-pull-local.c b/src/ostree/ot-builtin-pull-local.c index 471306fb..9a8cdfa3 100644 --- a/src/ostree/ot-builtin-pull-local.c +++ b/src/ostree/ot-builtin-pull-local.c @@ -254,7 +254,7 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err g_print ("Enumerating objects...\n"); - source_objects = ostree_traverse_new_reachable (); + source_objects = ostree_repo_traverse_new_reachable (); if (refs_to_clone) { @@ -263,7 +263,8 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err { const char *checksum = value; - if (!ostree_traverse_commit (data->src_repo, checksum, 0, source_objects, cancellable, error)) + if (!ostree_repo_traverse_commit (data->src_repo, checksum, 0, source_objects, + cancellable, error)) goto out; } } @@ -275,7 +276,8 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err { const char *checksum = key; - if (!ostree_traverse_commit (data->src_repo, checksum, 0, source_objects, cancellable, error)) + if (!ostree_repo_traverse_commit (data->src_repo, checksum, 0, source_objects, + cancellable, error)) goto out; } }