core: Make local-clone handle nested refs/heads directories

This commit is contained in:
Colin Walters 2012-01-07 11:26:12 -05:00
parent 788dfe89e1
commit 8d935f46c4
1 changed files with 20 additions and 9 deletions

View File

@ -39,10 +39,10 @@ typedef struct {
} OtLocalCloneData; } OtLocalCloneData;
static gboolean static gboolean
copy_dir_contents (GFile *src, copy_dir_contents_recurse (GFile *src,
GFile *dest, GFile *dest,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
GFile *child_src = NULL; GFile *child_src = NULL;
@ -65,9 +65,20 @@ copy_dir_contents (GFile *src,
g_clear_object (&child_dest); g_clear_object (&child_dest);
child_dest = g_file_get_child (dest, name); child_dest = g_file_get_child (dest, name);
if (!g_file_copy (child_src, child_dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS, if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
cancellable, NULL, NULL, error)) {
goto out; if (!ot_gfile_ensure_directory (child_dest, FALSE, error))
goto out;
if (!copy_dir_contents_recurse (child_src, child_dest, cancellable, error))
goto out;
}
else
{
if (!g_file_copy (child_src, child_dest, G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS,
cancellable, NULL, NULL, error))
goto out;
}
g_clear_object (&file_info); g_clear_object (&file_info);
} }
@ -230,14 +241,14 @@ ostree_builtin_local_clone (int argc, char **argv, GFile *repo_path, GError **er
src_dir = g_file_resolve_relative_path (src_repo_dir, "refs/heads"); src_dir = g_file_resolve_relative_path (src_repo_dir, "refs/heads");
dest_dir = g_file_resolve_relative_path (dest_repo_dir, "refs/heads"); dest_dir = g_file_resolve_relative_path (dest_repo_dir, "refs/heads");
if (!copy_dir_contents (src_dir, dest_dir, NULL, error)) if (!copy_dir_contents_recurse (src_dir, dest_dir, NULL, error))
goto out; goto out;
g_clear_object (&src_dir); g_clear_object (&src_dir);
g_clear_object (&dest_dir); g_clear_object (&dest_dir);
src_dir = g_file_resolve_relative_path (src_repo_dir, "tags"); src_dir = g_file_resolve_relative_path (src_repo_dir, "tags");
dest_dir = g_file_resolve_relative_path (dest_repo_dir, "tags"); dest_dir = g_file_resolve_relative_path (dest_repo_dir, "tags");
if (!copy_dir_contents (src_dir, dest_dir, NULL, error)) if (!copy_dir_contents_recurse (src_dir, dest_dir, NULL, error))
goto out; goto out;
ret = TRUE; ret = TRUE;