mirror of
https://github.com/ostreedev/ostree.git
synced 2025-08-25 13:49:24 +03:00
init: Add branches, tags, refs directories like git
This commit is contained in:
@ -41,12 +41,9 @@ ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
{
|
{
|
||||||
GOptionContext *context = NULL;
|
GOptionContext *context = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *otdir_path = NULL;
|
GFile *repodir = NULL;
|
||||||
char *objects_path = NULL;
|
GFile *child = NULL;
|
||||||
char *config_path = NULL;
|
GFile *grandchild = NULL;
|
||||||
GFile *otdir = NULL;
|
|
||||||
GFile *objects_dir = NULL;
|
|
||||||
GFile *configf = NULL;
|
|
||||||
|
|
||||||
context = g_option_context_new ("- Initialize a new empty repository");
|
context = g_option_context_new ("- Initialize a new empty repository");
|
||||||
g_option_context_add_main_entries (context, options, NULL);
|
g_option_context_add_main_entries (context, options, NULL);
|
||||||
@ -57,30 +54,47 @@ ostree_builtin_init (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
if (repo_path == NULL)
|
if (repo_path == NULL)
|
||||||
repo_path = ".";
|
repo_path = ".";
|
||||||
|
|
||||||
objects_path = g_build_filename (repo_path, "objects", NULL);
|
repodir = g_file_new_for_path (repo_path);
|
||||||
objects_dir = g_file_new_for_path (objects_path);
|
|
||||||
if (!g_file_make_directory (objects_dir, NULL, error))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
config_path = g_build_filename (repo_path, "config", NULL);
|
child = g_file_get_child (repodir, "config");
|
||||||
configf = g_file_new_for_path (config_path);
|
if (!g_file_replace_contents (child,
|
||||||
|
|
||||||
if (!g_file_replace_contents (configf,
|
|
||||||
DEFAULT_CONFIG_CONTENTS,
|
DEFAULT_CONFIG_CONTENTS,
|
||||||
strlen (DEFAULT_CONFIG_CONTENTS),
|
strlen (DEFAULT_CONFIG_CONTENTS),
|
||||||
NULL, FALSE, 0, NULL,
|
NULL, FALSE, 0, NULL,
|
||||||
NULL, error))
|
NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
g_clear_object (&child);
|
||||||
|
|
||||||
|
child = g_file_get_child (repodir, "objects");
|
||||||
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
|
goto out;
|
||||||
|
g_clear_object (&child);
|
||||||
|
|
||||||
|
child = g_file_get_child (repodir, "refs");
|
||||||
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
|
goto out;
|
||||||
|
grandchild = g_file_get_child (child, "heads");
|
||||||
|
if (!g_file_make_directory (grandchild, NULL, error))
|
||||||
|
goto out;
|
||||||
|
g_clear_object (&child);
|
||||||
|
g_clear_object (&grandchild);
|
||||||
|
|
||||||
|
child = g_file_get_child (repodir, "tags");
|
||||||
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
|
goto out;
|
||||||
|
g_clear_object (&child);
|
||||||
|
|
||||||
|
child = g_file_get_child (repodir, "remotes");
|
||||||
|
if (!g_file_make_directory (child, NULL, error))
|
||||||
|
goto out;
|
||||||
|
g_clear_object (&child);
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
if (context)
|
if (context)
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
g_free (otdir_path);
|
g_clear_object (&repodir);
|
||||||
g_free (objects_path);
|
g_clear_object (&child);
|
||||||
g_free (config_path);
|
g_clear_object (&grandchild);
|
||||||
g_clear_object (&otdir);
|
|
||||||
g_clear_object (&objects_dir);
|
|
||||||
g_clear_object (&configf);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user