ostree export: Add --subpath support

This lets you export a subset of a commit.

Closes: #265
Approved by: cgwalters
This commit is contained in:
Alexander Larsson authored and Colin Walters (automation) committed 2016-04-19 12:28:06 +00:00
1 parent 9db2f43b14
commit 5079f70ec0
3 files changed
+22 -4

No files matched your search

+1 -1
View File
@@ -480,7 +480,7 @@ file_to_archive_entry_common (GFile *root,
g_autoptr(GVariant) xattrs = NULL;
time_t ts = (time_t) opts->timestamp_secs;
if (pathstr && !pathstr[0])
if (pathstr == NULL || !pathstr[0])
{
g_free (pathstr);
pathstr = g_strdup (".");
+9 -1
View File
@@ -32,10 +32,12 @@
#endif
static char *opt_output_path;
static char *opt_subpath;
static gboolean opt_no_xattrs;
static GOptionEntry options[] = {
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Skip output of extended attributes", NULL },
{ "subpath", 0, 0, G_OPTION_ARG_STRING, &opt_subpath, "Checkout sub-directory PATH", "PATH" },
{ "output", 'o', 0, G_OPTION_ARG_STRING, &opt_output_path, "Output to PATH ", "PATH" },
{ NULL }
};
@@ -60,6 +62,7 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
gboolean ret = FALSE;
const char *rev;
g_autoptr(GFile) root = NULL;
g_autoptr(GFile) subtree = NULL;
g_autofree char *commit = NULL;
g_autoptr(GVariant) commit_data = NULL;
struct archive *a;
@@ -124,7 +127,12 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
opts.timestamp_secs = ostree_commit_get_timestamp (commit_data);
if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)root, a,
if (opt_subpath)
subtree = g_file_resolve_relative_path (root, opt_subpath);
else
subtree = g_object_ref (root);
if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)subtree, a,
cancellable, error))
goto out;