ostree/fsck: Handle refspecs from ostree_repo_list_refs()

It seems ostree_repo_list_refs() can return refspecs as hash table keys,
as well as just ref names. Handle that by parsing them before trying to
use them as ref names.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1347
Approved by: cgwalters
This commit is contained in:
Philip Withnall 2017-12-13 12:51:59 +00:00 committed by Atomic Bot
parent 97bdb3b271
commit b0e7b26921
1 changed files with 10 additions and 3 deletions

View File

@ -189,9 +189,16 @@ ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation,
gpointer key, value; gpointer key, value;
g_hash_table_iter_init (&hash_iter, all_refs); g_hash_table_iter_init (&hash_iter, all_refs);
while (g_hash_table_iter_next (&hash_iter, &key, &value)) while (g_hash_table_iter_next (&hash_iter, &key, &value))
if (!fsck_commit_for_ref (repo, value, NULL, key, {
&found_corruption, cancellable, error)) const char *refspec = key;
return FALSE; const char *checksum = value;
g_autofree char *ref_name = NULL;
if (!ostree_parse_refspec (refspec, NULL, &ref_name, error))
return FALSE;
if (!fsck_commit_for_ref (repo, checksum, NULL, ref_name,
&found_corruption, cancellable, error))
return FALSE;
}
#ifdef OSTREE_ENABLE_EXPERIMENTAL_API #ifdef OSTREE_ENABLE_EXPERIMENTAL_API
if (!opt_quiet) if (!opt_quiet)