core: pack: Add --metadata-only argument

Useful for bare repositories.
This commit is contained in:
Colin Walters 2012-04-28 07:54:40 -04:00
parent da3b17be1e
commit 9cb87ffc07
2 changed files with 23 additions and 10 deletions

View File

@ -35,6 +35,7 @@
#define OT_GZIP_COMPRESSION_LEVEL (8)
static gboolean opt_analyze_only;
static gboolean opt_metadata_only;
static gboolean opt_reindex_only;
static gboolean opt_keep_loose;
static char* opt_pack_size;
@ -51,6 +52,7 @@ static GOptionEntry options[] = {
{ "pack-size", 0, 0, G_OPTION_ARG_STRING, &opt_pack_size, "Maximum uncompressed size of packfiles in bytes; may be suffixed with k, m, or g", "BYTES" },
{ "internal-compression", 0, 0, G_OPTION_ARG_STRING, &opt_int_compression, "Compress objects using COMPRESSION", "COMPRESSION" },
{ "external-compression", 0, 0, G_OPTION_ARG_STRING, &opt_ext_compression, "Compress entire packfiles using COMPRESSION", "COMPRESSION" },
{ "metadata-only", 0, 0, G_OPTION_ARG_NONE, &opt_metadata_only, "Only pack metadata objects", NULL },
{ "analyze-only", 0, 0, G_OPTION_ARG_NONE, &opt_analyze_only, "Just analyze current state", NULL },
{ "reindex-only", 0, 0, G_OPTION_ARG_NONE, &opt_reindex_only, "Regenerate pack index", NULL },
{ "keep-loose", 0, 0, G_OPTION_ARG_NONE, &opt_keep_loose, "Don't delete loose objects", NULL },
@ -749,8 +751,12 @@ do_stats_gather_loose (OtRepackData *data,
}
else if (is_loose)
{
GVariant *copy = g_variant_ref (serialized_key);
g_hash_table_replace (ret_loose, copy, copy);
if (!(opt_metadata_only && !OSTREE_OBJECT_TYPE_IS_META(objtype))
|| OSTREE_OBJECT_TYPE_IS_META (objtype))
{
GVariant *copy = g_variant_ref (serialized_key);
g_hash_table_replace (ret_loose, copy, copy);
}
n_loose++;
}
else if (g_variant_n_children (pack_array) > 1)
@ -873,13 +879,6 @@ ostree_builtin_pack (int argc, char **argv, GFile *repo_path, GError **error)
if (!ostree_repo_check (repo, error))
goto out;
if (ostree_repo_get_mode (repo) != OSTREE_REPO_MODE_ARCHIVE)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Can't repack bare repositories yet");
goto out;
}
data.repo = repo;
data.error = error;

View File

@ -21,7 +21,7 @@ set -e
. libtest.sh
echo '1..19'
echo '1..23'
setup_test_repository "archive"
echo "ok setup"
@ -104,3 +104,17 @@ $OSTREE checkout --user-mode --link-cache=linkcache test2 test2
cd test2
assert_file_has_content baz/cow moo
echo "ok checkout link cache"
$OSTREE pack --metadata-only
echo "ok pack metadata"
$OSTREE fsck
echo "ok fsck"
cd ${test_tmpdir}
rm -rf checkout-test2
$OSTREE checkout test2 checkout-test2
echo "ok checkout metadata-packed"
$OSTREE unpack
echo "ok unpack"