--add-tombstones
--delete
--quiet -q
+ --verify-bindings
--verify-back-refs
"
</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--verify-bindings</option></term>
+ <listitem><para>
+ Verify that the commits pointed to by each ref have that
+ ref in the binding set. You should usually add this
+ option; it only defaults to off for backwards compatibility.
+ </para></listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--verify-back-refs</option></term>
<listitem><para>
- Verify that all the refs listed in a commit’s ref-bindings
- point to that commit. This cannot be used in repositories
- where the target of refs is changed over time as new commits
- are added, but can be used in repositories which are
- regenerated from scratch for each commit.
+ Verify that all the refs listed in a commit’s ref-bindings
+ point to that commit. This cannot be used in repositories
+ where the target of refs is changed over time as new commits
+ are added, but can be used in repositories which are
+ regenerated from scratch for each commit.
+ Implies <literal>--verify-bindings</literal> as well.
</para></listitem>
</varlistentry>
</variablelist>
static gboolean opt_quiet;
static gboolean opt_delete;
static gboolean opt_add_tombstones;
+static gboolean opt_verify_bindings;
static gboolean opt_verify_back_refs;
/* ATTENTION:
{ "add-tombstones", 0, 0, G_OPTION_ARG_NONE, &opt_add_tombstones, "Add tombstones for missing commits", NULL },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opt_quiet, "Only print error messages", NULL },
{ "delete", 0, 0, G_OPTION_ARG_NONE, &opt_delete, "Remove corrupted objects", NULL },
- { "verify-back-refs", 0, 0, G_OPTION_ARG_NONE, &opt_verify_back_refs, "Verify back-references", NULL },
+ { "verify-bindings", 0, 0, G_OPTION_ARG_NONE, &opt_verify_bindings, "Verify ref bindings", NULL },
+ { "verify-back-refs", 0, 0, G_OPTION_ARG_NONE, &opt_verify_back_refs, "Verify back-references (implies --verify-bindings)", NULL },
{ NULL }
};
}
/* Check its bindings. */
- if (!ostree_cmd__private__ ()->ostree_repo_verify_bindings (collection_id, ref_name, commit, error))
- return glnx_prefix_error (error, "Commit %s", checksum);
+ if (opt_verify_bindings)
+ {
+ if (!ostree_cmd__private__ ()->ostree_repo_verify_bindings (collection_id, ref_name, commit, error))
+ return glnx_prefix_error (error, "Commit %s", checksum);
+ }
return TRUE;
}
if (opt_add_tombstones)
tombstones = g_ptr_array_new_with_free_func (g_free);
+ if (opt_verify_back_refs)
+ opt_verify_bindings = TRUE;
+
guint n_partial = 0;
g_hash_table_iter_init (&hash_iter, objects);
while (g_hash_table_iter_next (&hash_iter, &key, &value))
set_up_repo_with_collection_id
${CMD_PREFIX} ostree --repo=repo refs --create=new-ref $(cat ref1-checksum)
+# For compatibility we don't check for this by default
+${CMD_PREFIX} ostree fsck --repo=repo
# fsck should now fail
-if ${CMD_PREFIX} ostree fsck --repo=repo > fsck 2> fsck-error; then
+if ${CMD_PREFIX} ostree fsck --repo=repo --verify-bindings > fsck 2> fsck-error; then
assert_not_reached "fsck unexpectedly succeeded after adding unbound ref!"
fi
assert_file_has_content fsck-error "Commit has no requested ref ‘new-ref’ in ref binding metadata (‘ref1’)"
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.Collection2:new-ref $(cat ref1-checksum)
# fsck should now fail
-if ${CMD_PREFIX} ostree fsck --repo=repo > fsck 2> fsck-error; then
+if ${CMD_PREFIX} ostree fsck --repo=repo --verify-bindings > fsck 2> fsck-error; then
assert_not_reached "fsck unexpectedly succeeded after adding unbound ref!"
fi
assert_file_has_content fsck-error "Commit has no requested ref ‘new-ref’ in ref binding metadata (‘ref1’)"
${CMD_PREFIX} ostree --repo=repo refs --collections --create=org.example.Collection2:ref1 $(cat ref1-checksum)
# fsck should now fail
-if ${CMD_PREFIX} ostree fsck --repo=repo > fsck 2> fsck-error; then
+if ${CMD_PREFIX} ostree fsck --repo=repo --verify-bindings > fsck 2> fsck-error; then
assert_not_reached "fsck unexpectedly succeeded after adding unbound ref!"
fi
assert_file_has_content fsck-error "Commit has collection ID ‘org.example.Collection’ in collection binding metadata, while the remote it came from has collection ID ‘org.example.Collection2’"
set_up_repo_without_collection_id
# fsck at this point should succeed
-${CMD_PREFIX} ostree fsck --repo=repo > fsck
+${CMD_PREFIX} ostree fsck --repo=repo --verify-bindings > fsck
assert_file_has_content fsck "^Validating refs in collections...$"
# Drop the commit the ref points to, and drop the original ref so that fsck doesn’t prematurely fail on that.
rm repo/refs/heads/ref3
# fsck should now fail
-if ${CMD_PREFIX} ostree fsck --repo=repo > fsck; then
+if ${CMD_PREFIX} ostree fsck --repo=repo --verify-bindings > fsck; then
assert_not_reached "fsck unexpectedly succeeded after deleting commit!"
fi
assert_file_has_content fsck "^Validating refs...$"
${CMD_PREFIX} ostree --repo=repo refs --create=new-ref $(cat ref3-checksum)
# fsck should now fail
-if ${CMD_PREFIX} ostree fsck --repo=repo > fsck 2> fsck-error; then
+if ${CMD_PREFIX} ostree fsck --repo=repo --verify-bindings > fsck 2> fsck-error; then
assert_not_reached "fsck unexpectedly succeeded after adding unbound ref!"
fi
assert_file_has_content fsck-error "Commit has no requested ref ‘new-ref’ in ref binding metadata (‘ref3’, ‘ref4’)"