fsck: De-indent loop
Could have done this in the previous change, but wanted to avoid excessive diff noise.
This commit is contained in:
parent
e6ad897850
commit
2fe0ea7395
|
|
@ -314,112 +314,102 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
|
||||||
|
|
||||||
g_assert (objtype == OSTREE_OBJECT_TYPE_COMMIT);
|
g_assert (objtype == OSTREE_OBJECT_TYPE_COMMIT);
|
||||||
|
|
||||||
if (TRUE) // Temporarily avoiding the noise of de-indenting this whole thing
|
if (!ostree_repo_load_commit (repo, checksum, &commit, &commitstate, error))
|
||||||
|
return FALSE;
|
||||||
|
/* If requested, check that all the refs listed in the ref-bindings
|
||||||
|
* for this commit resolve back to this commit. */
|
||||||
|
if (opt_verify_back_refs)
|
||||||
{
|
{
|
||||||
if (!ostree_repo_load_commit (repo, checksum, &commit, &commitstate, error))
|
g_autoptr(GVariant) metadata = g_variant_get_child_value (commit, 0);
|
||||||
return FALSE;
|
const char *collection_id = NULL;
|
||||||
|
if (!g_variant_lookup (metadata,
|
||||||
/* If requested, check that all the refs listed in the ref-bindings
|
OSTREE_COMMIT_META_KEY_COLLECTION_BINDING,
|
||||||
* for this commit resolve back to this commit. */
|
"&s",
|
||||||
if (opt_verify_back_refs)
|
&collection_id))
|
||||||
|
collection_id = NULL;
|
||||||
|
g_autofree const char **refs = NULL;
|
||||||
|
if (g_variant_lookup (metadata,
|
||||||
|
OSTREE_COMMIT_META_KEY_REF_BINDING,
|
||||||
|
"^a&s",
|
||||||
|
&refs))
|
||||||
{
|
{
|
||||||
g_autoptr(GVariant) metadata = g_variant_get_child_value (commit, 0);
|
for (const char **iter = refs; *iter != NULL; ++iter)
|
||||||
|
|
||||||
const char *collection_id = NULL;
|
|
||||||
if (!g_variant_lookup (metadata,
|
|
||||||
OSTREE_COMMIT_META_KEY_COLLECTION_BINDING,
|
|
||||||
"&s",
|
|
||||||
&collection_id))
|
|
||||||
collection_id = NULL;
|
|
||||||
|
|
||||||
g_autofree const char **refs = NULL;
|
|
||||||
if (g_variant_lookup (metadata,
|
|
||||||
OSTREE_COMMIT_META_KEY_REF_BINDING,
|
|
||||||
"^a&s",
|
|
||||||
&refs))
|
|
||||||
{
|
{
|
||||||
for (const char **iter = refs; *iter != NULL; ++iter)
|
g_autofree char *checksum_for_ref = NULL;
|
||||||
|
if (collection_id != NULL)
|
||||||
|
{
|
||||||
|
const OstreeCollectionRef collection_ref = { (char *) collection_id, (char *) *iter };
|
||||||
|
if (!ostree_repo_resolve_collection_ref (repo, &collection_ref,
|
||||||
|
TRUE,
|
||||||
|
OSTREE_REPO_RESOLVE_REV_EXT_NONE,
|
||||||
|
&checksum_for_ref,
|
||||||
|
cancellable,
|
||||||
|
error))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!ostree_repo_resolve_rev (repo, *iter, TRUE,
|
||||||
|
&checksum_for_ref, error))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (checksum_for_ref == NULL)
|
||||||
{
|
{
|
||||||
g_autofree char *checksum_for_ref = NULL;
|
|
||||||
|
|
||||||
if (collection_id != NULL)
|
if (collection_id != NULL)
|
||||||
{
|
return glnx_throw (error,
|
||||||
const OstreeCollectionRef collection_ref = { (char *) collection_id, (char *) *iter };
|
"Collection–ref (%s, %s) in bindings for commit %s does not exist",
|
||||||
if (!ostree_repo_resolve_collection_ref (repo, &collection_ref,
|
collection_id, *iter, checksum);
|
||||||
TRUE,
|
|
||||||
OSTREE_REPO_RESOLVE_REV_EXT_NONE,
|
|
||||||
&checksum_for_ref,
|
|
||||||
cancellable,
|
|
||||||
error))
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
return glnx_throw (error,
|
||||||
if (!ostree_repo_resolve_rev (repo, *iter, TRUE,
|
"Ref ‘%s’ in bindings for commit %s does not exist",
|
||||||
&checksum_for_ref, error))
|
*iter, checksum);
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checksum_for_ref == NULL)
|
|
||||||
{
|
|
||||||
if (collection_id != NULL)
|
|
||||||
return glnx_throw (error,
|
|
||||||
"Collection–ref (%s, %s) in bindings for commit %s does not exist",
|
|
||||||
collection_id, *iter, checksum);
|
|
||||||
else
|
|
||||||
return glnx_throw (error,
|
|
||||||
"Ref ‘%s’ in bindings for commit %s does not exist",
|
|
||||||
*iter, checksum);
|
|
||||||
}
|
|
||||||
else if (g_strcmp0 (checksum_for_ref, checksum) != 0)
|
|
||||||
{
|
|
||||||
if (collection_id != NULL)
|
|
||||||
return glnx_throw (error,
|
|
||||||
"Collection–ref (%s, %s) in bindings for commit %s does not resolve to that commit",
|
|
||||||
collection_id, *iter, checksum);
|
|
||||||
else
|
|
||||||
return glnx_throw (error,
|
|
||||||
"Ref ‘%s’ in bindings for commit %s does not resolve to that commit",
|
|
||||||
*iter, checksum);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else if (g_strcmp0 (checksum_for_ref, checksum) != 0)
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_add_tombstones)
|
|
||||||
{
|
|
||||||
GError *local_error = NULL;
|
|
||||||
g_autofree char *parent = ostree_commit_get_parent (commit);
|
|
||||||
if (parent)
|
|
||||||
{
|
|
||||||
g_autoptr(GVariant) parent_commit = NULL;
|
|
||||||
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, parent,
|
|
||||||
&parent_commit, &local_error))
|
|
||||||
{
|
{
|
||||||
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
if (collection_id != NULL)
|
||||||
{
|
return glnx_throw (error,
|
||||||
g_ptr_array_add (tombstones, g_strdup (checksum));
|
"Collection–ref (%s, %s) in bindings for commit %s does not resolve to that commit",
|
||||||
g_clear_error (&local_error);
|
collection_id, *iter, checksum);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
return glnx_throw (error,
|
||||||
g_propagate_error (error, local_error);
|
"Ref ‘%s’ in bindings for commit %s does not resolve to that commit",
|
||||||
return FALSE;
|
*iter, checksum);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL)
|
|
||||||
{
|
|
||||||
n_partial++;
|
|
||||||
if (commitstate & OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL)
|
|
||||||
n_fsck_partial++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
g_hash_table_add (commits, g_variant_ref (serialized_key));
|
|
||||||
}
|
}
|
||||||
}
|
if (opt_add_tombstones)
|
||||||
|
{
|
||||||
|
GError *local_error = NULL;
|
||||||
|
g_autofree char *parent = ostree_commit_get_parent (commit);
|
||||||
|
if (parent)
|
||||||
|
{
|
||||||
|
g_autoptr(GVariant) parent_commit = NULL;
|
||||||
|
if (!ostree_repo_load_variant (repo, OSTREE_OBJECT_TYPE_COMMIT, parent,
|
||||||
|
&parent_commit, &local_error))
|
||||||
|
{
|
||||||
|
if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
|
||||||
|
{
|
||||||
|
g_ptr_array_add (tombstones, g_strdup (checksum));
|
||||||
|
g_clear_error (&local_error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_propagate_error (error, local_error);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (commitstate & OSTREE_REPO_COMMIT_STATE_PARTIAL)
|
||||||
|
{
|
||||||
|
n_partial++;
|
||||||
|
if (commitstate & OSTREE_REPO_COMMIT_STATE_FSCK_PARTIAL)
|
||||||
|
n_fsck_partial++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_hash_table_add (commits, g_variant_ref (serialized_key));
|
||||||
|
}
|
||||||
|
|
||||||
g_clear_pointer (&all_commits, g_hash_table_unref);
|
g_clear_pointer (&all_commits, g_hash_table_unref);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue