mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-11 09:18:20 +03:00
core: remove HEAD file, use branches instead
HEAD in git describes a working copy, and we don't have those. Instead, default to a "master" branch. This also lets us support multiple branches.
This commit is contained in:
parent
6924e79e60
commit
7ca1c3d2e7
@ -56,12 +56,11 @@ typedef struct _OstreeRepoPrivate OstreeRepoPrivate;
|
|||||||
struct _OstreeRepoPrivate {
|
struct _OstreeRepoPrivate {
|
||||||
char *path;
|
char *path;
|
||||||
GFile *repo_file;
|
GFile *repo_file;
|
||||||
char *head_ref_path;
|
GFile *local_heads_dir;
|
||||||
char *objects_path;
|
char *objects_path;
|
||||||
char *config_path;
|
char *config_path;
|
||||||
|
|
||||||
gboolean inited;
|
gboolean inited;
|
||||||
char *current_head;
|
|
||||||
|
|
||||||
GKeyFile *config;
|
GKeyFile *config;
|
||||||
};
|
};
|
||||||
@ -74,10 +73,9 @@ ostree_repo_finalize (GObject *object)
|
|||||||
|
|
||||||
g_free (priv->path);
|
g_free (priv->path);
|
||||||
g_clear_object (&priv->repo_file);
|
g_clear_object (&priv->repo_file);
|
||||||
g_free (priv->head_ref_path);
|
g_clear_object (&priv->local_heads_dir);
|
||||||
g_free (priv->objects_path);
|
g_free (priv->objects_path);
|
||||||
g_free (priv->config_path);
|
g_free (priv->config_path);
|
||||||
g_free (priv->current_head);
|
|
||||||
if (priv->config)
|
if (priv->config)
|
||||||
g_key_file_free (priv->config);
|
g_key_file_free (priv->config);
|
||||||
|
|
||||||
@ -141,8 +139,8 @@ ostree_repo_constructor (GType gtype,
|
|||||||
g_assert (priv->path != NULL);
|
g_assert (priv->path != NULL);
|
||||||
|
|
||||||
priv->repo_file = ot_util_new_file_for_path (priv->path);
|
priv->repo_file = ot_util_new_file_for_path (priv->path);
|
||||||
|
priv->local_heads_dir = g_file_resolve_relative_path (priv->repo_file, "refs/heads");
|
||||||
|
|
||||||
priv->head_ref_path = g_build_filename (priv->path, "HEAD", NULL);
|
|
||||||
priv->objects_path = g_build_filename (priv->path, "objects", NULL);
|
priv->objects_path = g_build_filename (priv->path, "objects", NULL);
|
||||||
priv->config_path = g_build_filename (priv->path, "config", NULL);
|
priv->config_path = g_build_filename (priv->path, "config", NULL);
|
||||||
|
|
||||||
@ -182,17 +180,37 @@ ostree_repo_new (const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
parse_checksum_file (OstreeRepo *self,
|
validate_checksum_string (const char *sha256,
|
||||||
const char *path,
|
GError **error)
|
||||||
char **sha256,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
|
if (strlen (sha256) != 64)
|
||||||
|
{
|
||||||
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
"Invalid rev '%s'", sha256);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_rev_file (OstreeRepo *self,
|
||||||
|
const char *path,
|
||||||
|
char **sha256,
|
||||||
|
GError **error) G_GNUC_UNUSED;
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_rev_file (OstreeRepo *self,
|
||||||
|
const char *path,
|
||||||
|
char **sha256,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
GError *temp_error = NULL;
|
GError *temp_error = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *ret_sha256 = NULL;
|
char *rev = NULL;
|
||||||
|
|
||||||
ret_sha256 = ot_util_get_file_contents_utf8 (path, &temp_error);
|
rev = ot_util_get_file_contents_utf8 (path, &temp_error);
|
||||||
if (ret_sha256 == NULL)
|
if (rev == NULL)
|
||||||
{
|
{
|
||||||
if (g_error_matches (temp_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
if (g_error_matches (temp_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
|
||||||
{
|
{
|
||||||
@ -206,31 +224,136 @@ parse_checksum_file (OstreeRepo *self,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_strchomp (ret_sha256);
|
g_strchomp (rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
*sha256 = ret_sha256;
|
if (g_str_has_prefix (rev, "ref: "))
|
||||||
|
{
|
||||||
|
GFile *ref;
|
||||||
|
char *ref_path;
|
||||||
|
char *ref_sha256;
|
||||||
|
gboolean subret;
|
||||||
|
|
||||||
|
ref = g_file_resolve_relative_path (priv->local_heads_dir, rev + 5);
|
||||||
|
ref_path = g_file_get_path (ref);
|
||||||
|
|
||||||
|
subret = parse_rev_file (self, ref_path, &ref_sha256, error);
|
||||||
|
g_clear_object (&ref);
|
||||||
|
g_free (ref_path);
|
||||||
|
|
||||||
|
if (!subret)
|
||||||
|
{
|
||||||
|
g_free (ref_sha256);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (rev);
|
||||||
|
rev = ref_sha256;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!validate_checksum_string (rev, error))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
*sha256 = rev;
|
||||||
|
rev = NULL;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
g_free (rev);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_checksum_file (const char *path,
|
resolve_rev (OstreeRepo *self,
|
||||||
|
const char *rev,
|
||||||
|
gboolean allow_noent,
|
||||||
|
char **sha256,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
char *ret_rev = NULL;
|
||||||
|
GFile *child = NULL;
|
||||||
|
char *child_path = NULL;
|
||||||
|
GError *temp_error = NULL;
|
||||||
|
|
||||||
|
if (strlen (rev) == 64)
|
||||||
|
{
|
||||||
|
ret_rev = g_strdup (rev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
child = g_file_get_child (priv->local_heads_dir, rev);
|
||||||
|
child_path = g_file_get_path (child);
|
||||||
|
if (!ot_util_gfile_load_contents_utf8 (child, NULL, &ret_rev, NULL, &temp_error))
|
||||||
|
{
|
||||||
|
if (allow_noent && g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||||
|
{
|
||||||
|
g_free (ret_rev);
|
||||||
|
ret_rev = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_propagate_error (error, temp_error);
|
||||||
|
g_prefix_error (error, "Couldn't open ref '%s': ", child_path);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_strchomp (ret_rev);
|
||||||
|
|
||||||
|
if (!validate_checksum_string (ret_rev, error))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*sha256 = ret_rev;
|
||||||
|
ret_rev = NULL;
|
||||||
|
ret = TRUE;
|
||||||
|
out:
|
||||||
|
g_clear_object (&child);
|
||||||
|
g_free (child_path);
|
||||||
|
g_free (ret_rev);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ostree_repo_resolve_rev (OstreeRepo *self,
|
||||||
|
const char *rev,
|
||||||
|
char **sha256,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return resolve_rev (self, rev, FALSE, sha256, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
write_checksum_file (GFile *parentdir,
|
||||||
|
const char *name,
|
||||||
const char *sha256,
|
const char *sha256,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
char *buf = NULL;
|
GFile *child = NULL;
|
||||||
|
GOutputStream *out = NULL;
|
||||||
|
gsize bytes_written;
|
||||||
|
|
||||||
buf = g_strconcat (sha256, "\n", NULL);
|
child = g_file_get_child (parentdir, name);
|
||||||
|
|
||||||
if (!g_file_set_contents (path, buf, -1, error))
|
if ((out = (GOutputStream*)g_file_replace (child, NULL, FALSE, 0, NULL, error)) == NULL)
|
||||||
|
goto out;
|
||||||
|
if (!g_output_stream_write_all (out, sha256, strlen (sha256), &bytes_written, NULL, error))
|
||||||
|
goto out;
|
||||||
|
if (!g_output_stream_write_all (out, "\n", 1, &bytes_written, NULL, error))
|
||||||
|
goto out;
|
||||||
|
if (!g_output_stream_close (out, NULL, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
g_free (buf);
|
g_clear_object (&child);
|
||||||
|
g_clear_object (&out);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +376,6 @@ ostree_repo_check (OstreeRepo *self, GError **error)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parse_checksum_file (self, priv->head_ref_path, &priv->current_head, error))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
priv->config = g_key_file_new ();
|
priv->config = g_key_file_new ();
|
||||||
if (!g_key_file_load_from_file (priv->config, priv->config_path, 0, error))
|
if (!g_key_file_load_from_file (priv->config, priv->config_path, 0, error))
|
||||||
{
|
{
|
||||||
@ -789,7 +909,6 @@ load_commit_and_trees (OstreeRepo *self,
|
|||||||
ParsedDirectoryData **out_root_data,
|
ParsedDirectoryData **out_root_data,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
|
||||||
GVariant *ret_commit = NULL;
|
GVariant *ret_commit = NULL;
|
||||||
ParsedDirectoryData *ret_root_data = NULL;
|
ParsedDirectoryData *ret_root_data = NULL;
|
||||||
ParsedTreeData *tree_data = NULL;
|
ParsedTreeData *tree_data = NULL;
|
||||||
@ -799,13 +918,6 @@ load_commit_and_trees (OstreeRepo *self,
|
|||||||
const char *tree_contents_checksum;
|
const char *tree_contents_checksum;
|
||||||
const char *tree_meta_checksum;
|
const char *tree_meta_checksum;
|
||||||
|
|
||||||
if (!priv->current_head)
|
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Can't load current commit; no HEAD reference");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!load_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT,
|
if (!load_gvariant_object (self, OSTREE_SERIALIZED_COMMIT_VARIANT,
|
||||||
commit_sha256, &ret_commit, error))
|
commit_sha256, &ret_commit, error))
|
||||||
goto out;
|
goto out;
|
||||||
@ -1256,6 +1368,8 @@ add_files_to_tree_and_import (OstreeRepo *self,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
commit_parsed_tree (OstreeRepo *self,
|
commit_parsed_tree (OstreeRepo *self,
|
||||||
|
const char *branch,
|
||||||
|
const char *parent,
|
||||||
const char *subject,
|
const char *subject,
|
||||||
const char *body,
|
const char *body,
|
||||||
GVariant *metadata,
|
GVariant *metadata,
|
||||||
@ -1270,6 +1384,9 @@ commit_parsed_tree (OstreeRepo *self,
|
|||||||
GVariant *commit = NULL;
|
GVariant *commit = NULL;
|
||||||
GDateTime *now = NULL;
|
GDateTime *now = NULL;
|
||||||
|
|
||||||
|
g_assert (branch != NULL);
|
||||||
|
g_assert (subject != NULL);
|
||||||
|
|
||||||
if (!import_parsed_tree (self, root->tree_data, &root_checksum, error))
|
if (!import_parsed_tree (self, root->tree_data, &root_checksum, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@ -1277,7 +1394,7 @@ commit_parsed_tree (OstreeRepo *self,
|
|||||||
commit = g_variant_new ("(u@a{sv}ssstss)",
|
commit = g_variant_new ("(u@a{sv}ssstss)",
|
||||||
OSTREE_COMMIT_VERSION,
|
OSTREE_COMMIT_VERSION,
|
||||||
create_empty_gvariant_dict (),
|
create_empty_gvariant_dict (),
|
||||||
priv->current_head ? priv->current_head : "",
|
parent ? parent : "",
|
||||||
subject, body ? body : "",
|
subject, body ? body : "",
|
||||||
g_date_time_to_unix (now) / G_TIME_SPAN_SECOND,
|
g_date_time_to_unix (now) / G_TIME_SPAN_SECOND,
|
||||||
g_checksum_get_string (root_checksum),
|
g_checksum_get_string (root_checksum),
|
||||||
@ -1286,12 +1403,9 @@ commit_parsed_tree (OstreeRepo *self,
|
|||||||
commit, &ret_commit, error))
|
commit, &ret_commit, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!write_checksum_file (priv->head_ref_path, g_checksum_get_string (ret_commit), error))
|
if (!write_checksum_file (priv->local_heads_dir, branch, g_checksum_get_string (ret_commit), error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
g_free (priv->current_head);
|
|
||||||
priv->current_head = g_strdup (g_checksum_get_string (ret_commit));
|
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
*out_commit = ret_commit;
|
*out_commit = ret_commit;
|
||||||
out:
|
out:
|
||||||
@ -1305,8 +1419,8 @@ commit_parsed_tree (OstreeRepo *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
import_root (OstreeRepo *self,
|
import_root (OstreeRepo *self,
|
||||||
const char *base,
|
const char *base,
|
||||||
ParsedDirectoryData **out_root,
|
ParsedDirectoryData **out_root,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
@ -1338,6 +1452,7 @@ import_root (OstreeRepo *self,
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_repo_commit (OstreeRepo *self,
|
ostree_repo_commit (OstreeRepo *self,
|
||||||
|
const char *branch,
|
||||||
const char *subject,
|
const char *subject,
|
||||||
const char *body,
|
const char *body,
|
||||||
GVariant *metadata,
|
GVariant *metadata,
|
||||||
@ -1354,13 +1469,20 @@ ostree_repo_commit (OstreeRepo *self,
|
|||||||
GChecksum *ret_commit_checksum = NULL;
|
GChecksum *ret_commit_checksum = NULL;
|
||||||
GVariant *root_metadata = NULL;
|
GVariant *root_metadata = NULL;
|
||||||
GChecksum *root_meta_checksum = NULL;
|
GChecksum *root_meta_checksum = NULL;
|
||||||
|
char *current_head = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
g_return_val_if_fail (priv->inited, FALSE);
|
g_return_val_if_fail (priv->inited, FALSE);
|
||||||
|
|
||||||
if (priv->current_head)
|
if (branch == NULL)
|
||||||
|
branch = "master";
|
||||||
|
|
||||||
|
if (!resolve_rev (self, branch, TRUE, ¤t_head, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (current_head)
|
||||||
{
|
{
|
||||||
if (!load_commit_and_trees (self, priv->current_head, &previous_commit, &root, error))
|
if (!load_commit_and_trees (self, current_head, &previous_commit, &root, error))
|
||||||
goto out;
|
goto out;
|
||||||
if (!import_directory_meta (self, base, &root_metadata, &root_meta_checksum, error))
|
if (!import_directory_meta (self, base, &root_metadata, &root_meta_checksum, error))
|
||||||
goto out;
|
goto out;
|
||||||
@ -1382,21 +1504,18 @@ ostree_repo_commit (OstreeRepo *self,
|
|||||||
if (!add_files_to_tree_and_import (self, base, modified_files, root->tree_data, error))
|
if (!add_files_to_tree_and_import (self, base, modified_files, root->tree_data, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!commit_parsed_tree (self, subject, body, metadata, root,
|
if (!commit_parsed_tree (self, branch, current_head,
|
||||||
|
subject, body, metadata, root,
|
||||||
&ret_commit_checksum, error))
|
&ret_commit_checksum, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
*out_commit = ret_commit_checksum;
|
||||||
|
ret_commit_checksum = NULL;
|
||||||
out:
|
out:
|
||||||
if (!ret)
|
if (ret_commit_checksum)
|
||||||
{
|
g_checksum_free (ret_commit_checksum);
|
||||||
if (ret_commit_checksum)
|
g_free (current_head);
|
||||||
g_checksum_free (ret_commit_checksum);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*out_commit = ret_commit_checksum;
|
|
||||||
}
|
|
||||||
if (previous_commit)
|
if (previous_commit)
|
||||||
g_variant_unref (previous_commit);
|
g_variant_unref (previous_commit);
|
||||||
parsed_directory_data_free (root);
|
parsed_directory_data_free (root);
|
||||||
@ -1409,14 +1528,15 @@ ostree_repo_commit (OstreeRepo *self,
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
||||||
const char *subject,
|
const char *branch,
|
||||||
const char *body,
|
const char *subject,
|
||||||
GVariant *metadata,
|
const char *body,
|
||||||
const char *base,
|
GVariant *metadata,
|
||||||
int fd,
|
const char *base,
|
||||||
char separator,
|
int fd,
|
||||||
GChecksum **out_commit,
|
char separator,
|
||||||
GError **error)
|
GChecksum **out_commit,
|
||||||
|
GError **error)
|
||||||
{
|
{
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
@ -1429,14 +1549,21 @@ ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
|||||||
GError *temp_error = NULL;
|
GError *temp_error = NULL;
|
||||||
GVariant *root_metadata = NULL;
|
GVariant *root_metadata = NULL;
|
||||||
GChecksum *root_meta_checksum = NULL;
|
GChecksum *root_meta_checksum = NULL;
|
||||||
|
char *current_head = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||||
g_return_val_if_fail (priv->inited, FALSE);
|
g_return_val_if_fail (priv->inited, FALSE);
|
||||||
|
|
||||||
|
if (branch == NULL)
|
||||||
|
branch = "master";
|
||||||
|
|
||||||
/* We're overwriting the tree */
|
/* We're overwriting the tree */
|
||||||
if (!import_root (self, base, &root, error))
|
if (!import_root (self, base, &root, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (!resolve_rev (self, branch, TRUE, ¤t_head, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
in = (GUnixInputStream*)g_unix_input_stream_new (fd, FALSE);
|
in = (GUnixInputStream*)g_unix_input_stream_new (fd, FALSE);
|
||||||
datain = g_data_input_stream_new ((GInputStream*)in);
|
datain = g_data_input_stream_new ((GInputStream*)in);
|
||||||
|
|
||||||
@ -1461,21 +1588,17 @@ ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
|||||||
g_propagate_prefixed_error (error, temp_error, "%s", "While reading filelist: ");
|
g_propagate_prefixed_error (error, temp_error, "%s", "While reading filelist: ");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!commit_parsed_tree (self, subject, body, metadata,
|
if (!commit_parsed_tree (self, branch, current_head, subject, body, metadata,
|
||||||
root, &ret_commit_checksum, error))
|
root, &ret_commit_checksum, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
|
*out_commit = ret_commit_checksum;
|
||||||
|
ret_commit_checksum = NULL;
|
||||||
out:
|
out:
|
||||||
if (!ret)
|
if (ret_commit_checksum)
|
||||||
{
|
g_checksum_free (ret_commit_checksum);
|
||||||
if (ret_commit_checksum)
|
g_free (current_head);
|
||||||
g_checksum_free (ret_commit_checksum);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*out_commit = ret_commit_checksum;
|
|
||||||
}
|
|
||||||
if (root_metadata)
|
if (root_metadata)
|
||||||
g_variant_unref (root_metadata);
|
g_variant_unref (root_metadata);
|
||||||
if (root_meta_checksum)
|
if (root_meta_checksum)
|
||||||
@ -1640,37 +1763,6 @@ ostree_repo_load_variant (OstreeRepo *repo,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
|
||||||
ostree_repo_get_head (OstreeRepo *self)
|
|
||||||
{
|
|
||||||
OstreeRepoPrivate *priv = GET_PRIVATE (self);
|
|
||||||
|
|
||||||
g_return_val_if_fail (priv->inited, NULL);
|
|
||||||
|
|
||||||
return priv->current_head;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
resolve_ref (OstreeRepo *self,
|
|
||||||
const char *ref,
|
|
||||||
char **resolved,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
if (strcmp (ref, "HEAD") == 0)
|
|
||||||
{
|
|
||||||
*resolved = g_strdup (ostree_repo_get_head (self));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if (strlen (ref) == 64)
|
|
||||||
{
|
|
||||||
*resolved = g_strdup (ref);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"Invalid ref '%s' (must be SHA256 or HEAD)", ref);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
checkout_tree (OstreeRepo *self,
|
checkout_tree (OstreeRepo *self,
|
||||||
ParsedTreeData *tree,
|
ParsedTreeData *tree,
|
||||||
@ -1762,9 +1854,9 @@ checkout_tree (OstreeRepo *self,
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ostree_repo_checkout (OstreeRepo *self,
|
ostree_repo_checkout (OstreeRepo *self,
|
||||||
const char *ref,
|
const char *rev,
|
||||||
const char *destination,
|
const char *destination,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
GVariant *commit = NULL;
|
GVariant *commit = NULL;
|
||||||
@ -1780,7 +1872,7 @@ ostree_repo_checkout (OstreeRepo *self,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resolve_ref (self, ref, &resolved, error))
|
if (!resolve_rev (self, rev, FALSE, &resolved, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!load_commit_and_trees (self, resolved, &commit, &root, error))
|
if (!load_commit_and_trees (self, resolved, &commit, &root, error))
|
||||||
|
@ -59,7 +59,10 @@ gboolean ostree_repo_link_file (OstreeRepo *self,
|
|||||||
gboolean force,
|
gboolean force,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
const char * ostree_repo_get_head (OstreeRepo *self);
|
gboolean ostree_repo_resolve_rev (OstreeRepo *self,
|
||||||
|
const char *rev,
|
||||||
|
char **out_resolved,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_repo_load_variant (OstreeRepo *self,
|
gboolean ostree_repo_load_variant (OstreeRepo *self,
|
||||||
const char *sha256,
|
const char *sha256,
|
||||||
@ -68,24 +71,26 @@ gboolean ostree_repo_load_variant (OstreeRepo *self,
|
|||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_repo_commit (OstreeRepo *self,
|
gboolean ostree_repo_commit (OstreeRepo *self,
|
||||||
const char *subject,
|
const char *branch,
|
||||||
const char *body,
|
const char *subject,
|
||||||
GVariant *metadata,
|
const char *body,
|
||||||
const char *base,
|
GVariant *metadata,
|
||||||
GPtrArray *modified_files,
|
const char *base,
|
||||||
GPtrArray *removed_files,
|
GPtrArray *modified_files,
|
||||||
GChecksum **out_commit,
|
GPtrArray *removed_files,
|
||||||
GError **error);
|
GChecksum **out_commit,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
gboolean ostree_repo_commit_from_filelist_fd (OstreeRepo *self,
|
||||||
const char *subject,
|
const char *branch,
|
||||||
const char *body,
|
const char *subject,
|
||||||
GVariant *metadata,
|
const char *body,
|
||||||
const char *base,
|
GVariant *metadata,
|
||||||
int fd,
|
const char *base,
|
||||||
char separator,
|
int fd,
|
||||||
GChecksum **out_commit,
|
char separator,
|
||||||
GError **error);
|
GChecksum **out_commit,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
gboolean ostree_repo_checkout (OstreeRepo *self,
|
gboolean ostree_repo_checkout (OstreeRepo *self,
|
||||||
const char *ref,
|
const char *ref,
|
||||||
|
@ -62,21 +62,56 @@ char *
|
|||||||
ot_util_get_file_contents_utf8 (const char *path,
|
ot_util_get_file_contents_utf8 (const char *path,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
char *contents;
|
GFile *file = NULL;
|
||||||
|
char *ret = NULL;
|
||||||
|
|
||||||
|
file = ot_util_new_file_for_path (path);
|
||||||
|
if (!ot_util_gfile_load_contents_utf8 (file, NULL, &ret, NULL, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_clear_object (&file);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ot_util_gfile_load_contents_utf8 (GFile *file,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
char **contents_out,
|
||||||
|
char **etag_out,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
char *ret_contents = NULL;
|
||||||
|
char *ret_etag = NULL;
|
||||||
gsize len;
|
gsize len;
|
||||||
if (!g_file_get_contents (path, &contents, &len, error))
|
gboolean ret = FALSE;
|
||||||
return NULL;
|
|
||||||
if (!g_utf8_validate (contents, len, NULL))
|
if (!g_file_load_contents (file, cancellable, &ret_contents, &len, &ret_etag, error))
|
||||||
|
goto out;
|
||||||
|
if (!g_utf8_validate (ret_contents, len, NULL))
|
||||||
{
|
{
|
||||||
g_free (contents);
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
G_IO_ERROR,
|
G_IO_ERROR,
|
||||||
G_IO_ERROR_FAILED,
|
G_IO_ERROR_INVALID_DATA,
|
||||||
"File %s contains invalid UTF-8",
|
"Invalid UTF-8");
|
||||||
path);
|
goto out;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
return contents;
|
|
||||||
|
if (contents_out)
|
||||||
|
*contents_out = ret_contents;
|
||||||
|
else
|
||||||
|
g_free (ret_contents);
|
||||||
|
ret_contents = NULL;
|
||||||
|
if (etag_out)
|
||||||
|
*etag_out = ret_etag;
|
||||||
|
else
|
||||||
|
g_free (ret_etag);
|
||||||
|
ret_etag = NULL;
|
||||||
|
ret = TRUE;
|
||||||
|
out:
|
||||||
|
g_free (ret_contents);
|
||||||
|
g_free (ret_etag);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
GInputStream *
|
GInputStream *
|
||||||
|
@ -32,6 +32,12 @@ gboolean ot_util_ensure_directory (const char *path, gboolean with_parents, GErr
|
|||||||
|
|
||||||
char * ot_util_get_file_contents_utf8 (const char *path, GError **error);
|
char * ot_util_get_file_contents_utf8 (const char *path, GError **error);
|
||||||
|
|
||||||
|
gboolean ot_util_gfile_load_contents_utf8 (GFile *file,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
char **contents_out,
|
||||||
|
char **etag_out,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
GInputStream *ot_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **error);
|
GInputStream *ot_util_read_file_noatime (GFile *file, GCancellable *cancellable, GError **error);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -33,13 +33,15 @@ static gboolean from_stdin;
|
|||||||
static char *from_file;
|
static char *from_file;
|
||||||
static char *subject;
|
static char *subject;
|
||||||
static char *body;
|
static char *body;
|
||||||
|
static char *branch;
|
||||||
static char **additions;
|
static char **additions;
|
||||||
static char **removals;
|
static char **removals;
|
||||||
|
|
||||||
static GOptionEntry options[] = {
|
static GOptionEntry options[] = {
|
||||||
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
|
{ "repo", 0, 0, G_OPTION_ARG_FILENAME, &repo_path, "Repository path", "repo" },
|
||||||
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
|
{ "subject", 's', 0, G_OPTION_ARG_STRING, &subject, "One line subject", "subject" },
|
||||||
{ "body", 'b', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
|
{ "body", 'm', 0, G_OPTION_ARG_STRING, &body, "Full description", "body" },
|
||||||
|
{ "branch", 'b', 0, G_OPTION_ARG_STRING, &branch, "Branch", "branch" },
|
||||||
{ "from-fd", 0, 0, G_OPTION_ARG_INT, &from_fd, "Read new tree files from fd", "file descriptor" },
|
{ "from-fd", 0, 0, G_OPTION_ARG_INT, &from_fd, "Read new tree files from fd", "file descriptor" },
|
||||||
{ "from-stdin", 0, 0, G_OPTION_ARG_NONE, &from_stdin, "Read new tree files from stdin", "file descriptor" },
|
{ "from-stdin", 0, 0, G_OPTION_ARG_NONE, &from_stdin, "Read new tree files from stdin", "file descriptor" },
|
||||||
{ "from-file", 0, 0, G_OPTION_ARG_FILENAME, &from_file, "Read new tree files from another file", "path" },
|
{ "from-file", 0, 0, G_OPTION_ARG_FILENAME, &from_file, "Read new tree files from another file", "path" },
|
||||||
@ -113,11 +115,11 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
|
|||||||
for (iter = removals; *iter; iter++)
|
for (iter = removals; *iter; iter++)
|
||||||
g_ptr_array_add (removals_array, *iter);
|
g_ptr_array_add (removals_array, *iter);
|
||||||
|
|
||||||
if (!ostree_repo_commit (repo, subject, body, NULL,
|
if (!ostree_repo_commit (repo, branch, subject, body, NULL,
|
||||||
prefix, additions_array,
|
prefix, additions_array,
|
||||||
removals_array,
|
removals_array,
|
||||||
&commit_checksum,
|
&commit_checksum,
|
||||||
error))
|
error))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
else if (using_filedescriptors)
|
else if (using_filedescriptors)
|
||||||
@ -137,9 +139,9 @@ ostree_builtin_commit (int argc, char **argv, const char *prefix, GError **error
|
|||||||
}
|
}
|
||||||
from_fd = temp_fd;
|
from_fd = temp_fd;
|
||||||
}
|
}
|
||||||
if (!ostree_repo_commit_from_filelist_fd (repo, subject, body, NULL,
|
if (!ostree_repo_commit_from_filelist_fd (repo, branch, subject, body, NULL,
|
||||||
prefix, from_fd, separator,
|
prefix, from_fd, separator,
|
||||||
&commit_checksum, error))
|
&commit_checksum, error))
|
||||||
{
|
{
|
||||||
if (temp_fd >= 0)
|
if (temp_fd >= 0)
|
||||||
close (temp_fd);
|
close (temp_fd);
|
||||||
|
@ -121,13 +121,6 @@ ostree_builtin_fsck (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
if (!ostree_repo_iter_objects (repo, object_iter_callback, &data, error))
|
if (!ostree_repo_iter_objects (repo, object_iter_callback, &data, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
head = ostree_repo_get_head (repo);
|
|
||||||
if (!head)
|
|
||||||
{
|
|
||||||
if (!quiet)
|
|
||||||
g_printerr ("No HEAD file\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
g_printerr ("Total Objects: %u\n", data.n_objects);
|
g_printerr ("Total Objects: %u\n", data.n_objects);
|
||||||
|
|
||||||
|
@ -41,7 +41,8 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
OstreeRepo *repo = NULL;
|
OstreeRepo *repo = NULL;
|
||||||
GOutputStream *pager = NULL;
|
GOutputStream *pager = NULL;
|
||||||
GVariant *commit = NULL;
|
GVariant *commit = NULL;
|
||||||
char *head;
|
const char *rev = "master";
|
||||||
|
char *resolved_rev;
|
||||||
|
|
||||||
context = g_option_context_new ("- Show revision log");
|
context = g_option_context_new ("- Show revision log");
|
||||||
g_option_context_add_main_entries (context, options, NULL);
|
g_option_context_add_main_entries (context, options, NULL);
|
||||||
@ -54,20 +55,19 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
if (prefix == NULL)
|
if (prefix == NULL)
|
||||||
prefix = ".";
|
prefix = ".";
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
rev = argv[1];
|
||||||
|
|
||||||
repo = ostree_repo_new (repo_path);
|
repo = ostree_repo_new (repo_path);
|
||||||
if (!ostree_repo_check (repo, error))
|
if (!ostree_repo_check (repo, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
head = g_strdup (ostree_repo_get_head (repo));
|
|
||||||
if (!head)
|
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "No HEAD exists");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ot_util_spawn_pager (&pager, error))
|
if (!ot_util_spawn_pager (&pager, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
if (!ostree_repo_resolve_rev (repo, rev, &resolved_rev, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
OstreeSerializedVariantType type;
|
OstreeSerializedVariantType type;
|
||||||
@ -88,7 +88,7 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
|
|
||||||
if (commit)
|
if (commit)
|
||||||
g_variant_unref (commit);
|
g_variant_unref (commit);
|
||||||
if (!ostree_repo_load_variant (repo, head, &type, &commit, error))
|
if (!ostree_repo_load_variant (repo, resolved_rev, &type, &commit, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Ignore commit metadata for now */
|
/* Ignore commit metadata for now */
|
||||||
@ -103,7 +103,7 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
formatted_metadata = g_variant_print (commit_metadata, TRUE);
|
formatted_metadata = g_variant_print (commit_metadata, TRUE);
|
||||||
g_variant_unref (commit_metadata);
|
g_variant_unref (commit_metadata);
|
||||||
formatted = g_strdup_printf ("commit %s\nSubject: %s\nDate: %s\nMetadata: %s\n\n",
|
formatted = g_strdup_printf ("commit %s\nSubject: %s\nDate: %s\nMetadata: %s\n\n",
|
||||||
head, subject, formatted_date, formatted_metadata);
|
resolved_rev, subject, formatted_date, formatted_metadata);
|
||||||
g_free (formatted_metadata);
|
g_free (formatted_metadata);
|
||||||
g_free (formatted_date);
|
g_free (formatted_date);
|
||||||
formatted_date = NULL;
|
formatted_date = NULL;
|
||||||
@ -134,8 +134,8 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
|
|
||||||
if (strcmp (parent, "") == 0)
|
if (strcmp (parent, "") == 0)
|
||||||
break;
|
break;
|
||||||
g_free (head);
|
g_free (resolved_rev);
|
||||||
head = g_strdup (parent);
|
resolved_rev = g_strdup (parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_output_stream_close (pager, NULL, error))
|
if (!g_output_stream_close (pager, NULL, error))
|
||||||
@ -143,6 +143,7 @@ ostree_builtin_log (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
g_free (resolved_rev);
|
||||||
if (context)
|
if (context)
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
if (commit)
|
if (commit)
|
||||||
|
@ -39,7 +39,8 @@ ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
OstreeRepo *repo = NULL;
|
OstreeRepo *repo = NULL;
|
||||||
const char *target;
|
const char *rev = "master";
|
||||||
|
char *resolved_rev = NULL;
|
||||||
OstreeSerializedVariantType type;
|
OstreeSerializedVariantType type;
|
||||||
GVariant *variant = NULL;
|
GVariant *variant = NULL;
|
||||||
char *formatted_variant = NULL;
|
char *formatted_variant = NULL;
|
||||||
@ -57,28 +58,22 @@ ostree_builtin_show (int argc, char **argv, const char *prefix, GError **error)
|
|||||||
if (!ostree_repo_check (repo, error))
|
if (!ostree_repo_check (repo, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc > 1)
|
||||||
{
|
rev = argv[1];
|
||||||
target = ostree_repo_get_head (repo);
|
|
||||||
if (!target)
|
|
||||||
{
|
|
||||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
|
||||||
"No arguments specified and no HEAD exists");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
target = argv[1];
|
|
||||||
|
|
||||||
if (!ostree_repo_load_variant (repo, target, &type, &variant, error))
|
if (!ostree_repo_resolve_rev (repo, rev, &resolved_rev, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
g_print ("Object: %s\nType: %d\n", target, type);
|
if (!ostree_repo_load_variant (repo, resolved_rev, &type, &variant, error))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
g_print ("Object: %s\nType: %d\n", resolved_rev, type);
|
||||||
formatted_variant = g_variant_print (variant, TRUE);
|
formatted_variant = g_variant_print (variant, TRUE);
|
||||||
g_print ("%s\n", formatted_variant);
|
g_print ("%s\n", formatted_variant);
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
out:
|
out:
|
||||||
|
g_free (resolved_rev);
|
||||||
if (context)
|
if (context)
|
||||||
g_option_context_free (context);
|
g_option_context_free (context);
|
||||||
g_clear_object (&repo);
|
g_clear_object (&repo);
|
||||||
|
@ -25,7 +25,7 @@ cd "$test_tmpdir"
|
|||||||
touch "$test_tmpdir/.test$$"
|
touch "$test_tmpdir/.test$$"
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
if test -z "$HT_TESTS_SAVE_TEMPS"; then
|
if test -z "$OT_TESTS_SAVE_TEMPS"; then
|
||||||
test -f "$test_tmpdir/.test$$" && rm -rf "$test_tmpdir"
|
test -f "$test_tmpdir/.test$$" && rm -rf "$test_tmpdir"
|
||||||
else
|
else
|
||||||
echo "Temporary files saved in $test_tmpdir"
|
echo "Temporary files saved in $test_tmpdir"
|
||||||
@ -60,8 +60,8 @@ setup_test_repository1 () {
|
|||||||
ot_repo="--repo=../repo"
|
ot_repo="--repo=../repo"
|
||||||
export ot_repo
|
export ot_repo
|
||||||
ostree init $ot_repo
|
ostree init $ot_repo
|
||||||
ostree commit $ot_repo -s "Test Commit 1" -b "Commit body first" --add=firstfile
|
ostree commit $ot_repo -s "Test Commit 1" -m "Commit body first" --add=firstfile
|
||||||
ostree commit $ot_repo -s "Test Commit 2" -b "Commit body second" --add=secondfile
|
ostree commit $ot_repo -s "Test Commit 2" -m "Commit body second" --add=secondfile
|
||||||
ostree fsck -q $ot_repo
|
ostree fsck -q $ot_repo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +86,8 @@ setup_test_repository2 () {
|
|||||||
cd ../files
|
cd ../files
|
||||||
export ot_repo
|
export ot_repo
|
||||||
ostree init $ot_repo
|
ostree init $ot_repo
|
||||||
ostree commit $ot_repo -s "Test Commit 1" -b "Commit body first" --add=firstfile
|
ostree commit $ot_repo -s "Test Commit 1" -m "Commit body first" --add=firstfile
|
||||||
ostree commit $ot_repo -s "Test Commit 2" -b "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y
|
ostree commit $ot_repo -s "Test Commit 2" -m "Commit body second" --add=baz/cow --add=baz/saucer --add=baz/deeper/ohyeah --add=baz/another/y
|
||||||
ostree fsck -q $ot_repo
|
ostree fsck -q $ot_repo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ mkdir ../repo
|
|||||||
repo="--repo=../repo"
|
repo="--repo=../repo"
|
||||||
ostree init $repo
|
ostree init $repo
|
||||||
echo 'ok init'
|
echo 'ok init'
|
||||||
ostree commit $repo -s "Test Commit" -b "Commit body" --add=yy
|
ostree commit $repo -s "Test Commit" -m "Commit body" --add=yy
|
||||||
echo 'ok commit'
|
echo 'ok commit'
|
||||||
ostree fsck -q $repo
|
ostree fsck -q $repo
|
||||||
echo 'ok fsck'
|
echo 'ok fsck'
|
||||||
|
@ -33,9 +33,9 @@ mkdir ../repo
|
|||||||
repo="--repo=../repo"
|
repo="--repo=../repo"
|
||||||
ostree init $repo
|
ostree init $repo
|
||||||
echo 'ok init'
|
echo 'ok init'
|
||||||
ostree commit $repo -s "Test Commit 1" -b "Commit body first" --add=firstfile
|
ostree commit $repo -s "Test Commit 1" -m "Commit body first" --add=firstfile
|
||||||
echo 'ok commit 1'
|
echo 'ok commit 1'
|
||||||
ostree commit $repo -s "Test Commit 2" -b "Commit body first" --add=secondfile
|
ostree commit $repo -s "Test Commit 2" -m "Commit body first" --add=secondfile
|
||||||
echo 'ok commit 2'
|
echo 'ok commit 2'
|
||||||
ostree fsck -q $repo
|
ostree fsck -q $repo
|
||||||
echo 'ok fsck'
|
echo 'ok fsck'
|
||||||
|
@ -26,7 +26,7 @@ echo '1..3'
|
|||||||
|
|
||||||
setup_test_repository1
|
setup_test_repository1
|
||||||
echo 'ok setup'
|
echo 'ok setup'
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout1-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout1-head
|
||||||
echo 'ok checkout cmd'
|
echo 'ok checkout cmd'
|
||||||
cd $test_tmpdir/checkout1-head
|
cd $test_tmpdir/checkout1-head
|
||||||
assert_has_file firstfile
|
assert_has_file firstfile
|
||||||
|
@ -26,7 +26,7 @@ echo '1..5'
|
|||||||
|
|
||||||
setup_test_repository2
|
setup_test_repository2
|
||||||
echo 'ok setup'
|
echo 'ok setup'
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout2-head
|
||||||
echo 'ok checkout cmd'
|
echo 'ok checkout cmd'
|
||||||
cd $test_tmpdir/checkout2-head
|
cd $test_tmpdir/checkout2-head
|
||||||
assert_has_file firstfile
|
assert_has_file firstfile
|
||||||
|
@ -25,14 +25,14 @@ set -e
|
|||||||
echo '1..4'
|
echo '1..4'
|
||||||
|
|
||||||
setup_test_repository2
|
setup_test_repository2
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout2-head
|
||||||
echo 'ok setup'
|
echo 'ok setup'
|
||||||
cd $test_tmpdir/checkout2-head
|
cd $test_tmpdir/checkout2-head
|
||||||
ostree commit -s delete $ot_repo -r firstfile
|
ostree commit -s delete $ot_repo -r firstfile
|
||||||
echo 'ok rm firstfile'
|
echo 'ok rm firstfile'
|
||||||
assert_has_file firstfile # It should still exist in this checkout
|
assert_has_file firstfile # It should still exist in this checkout
|
||||||
cd $test_tmpdir
|
cd $test_tmpdir
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout3-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout3-head
|
||||||
echo 'ok checkout 3'
|
echo 'ok checkout 3'
|
||||||
cd $test_tmpdir/checkout3-head
|
cd $test_tmpdir/checkout3-head
|
||||||
assert_not_has_file firstfile
|
assert_not_has_file firstfile
|
||||||
|
@ -25,7 +25,7 @@ set -e
|
|||||||
echo "1..2"
|
echo "1..2"
|
||||||
|
|
||||||
setup_test_repository2
|
setup_test_repository2
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout2-head
|
||||||
cd $test_tmpdir/checkout2-head
|
cd $test_tmpdir/checkout2-head
|
||||||
mkdir -p a/nested/tree
|
mkdir -p a/nested/tree
|
||||||
echo one > a/nested/tree/1
|
echo one > a/nested/tree/1
|
||||||
@ -41,7 +41,7 @@ echo whee2 > another/whee
|
|||||||
# FIXME - remove grep for .
|
# FIXME - remove grep for .
|
||||||
find | grep -v '^\.$' | ostree commit $ot_repo --from-stdin -s "From find"
|
find | grep -v '^\.$' | ostree commit $ot_repo --from-stdin -s "From find"
|
||||||
echo "ok commit stdin"
|
echo "ok commit stdin"
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout3-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout3-head
|
||||||
cd $test_tmpdir/checkout3-head
|
cd $test_tmpdir/checkout3-head
|
||||||
assert_has_file a/nested/2
|
assert_has_file a/nested/2
|
||||||
assert_file_has_content a/nested/2 'two2'
|
assert_file_has_content a/nested/2 'two2'
|
||||||
|
@ -26,10 +26,10 @@ echo "1..2"
|
|||||||
|
|
||||||
setup_test_repository2
|
setup_test_repository2
|
||||||
|
|
||||||
ostree checkout $ot_repo HEAD $test_tmpdir/checkout2-head
|
ostree checkout $ot_repo master $test_tmpdir/checkout2-head
|
||||||
cd $ht_files
|
cd $ht_files
|
||||||
ln -s foo bar
|
ln -s foo bar
|
||||||
ostree commit $ot_repo -s "Add a symlink" -b "To test it" --add=bar
|
ostree commit $ot_repo -s "Add a symlink" -m "To test it" --add=bar
|
||||||
echo "ok commit symlink"
|
echo "ok commit symlink"
|
||||||
ostree fsck $ot_repo
|
ostree fsck $ot_repo
|
||||||
echo "ok fsck"
|
echo "ok fsck"
|
||||||
|
Loading…
Reference in New Issue
Block a user