bin/refs: Disallow creating broken aliases

This is the alias version of #1749. I.e. we want to make sure that one
can't even create an alias which would end up dangling.

See also: https://pagure.io/releng/issue/7891

Closes: #1768
Approved by: sinnykumari
This commit is contained in:
Jonathan Lebon authored and Atomic Bot committed 2018-10-31 12:32:30 +00:00
1 parent 51752baf0e
commit 34a8867749
2 files changed
+10 -1

No files matched your search

+3
View File
@@ -221,6 +221,9 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
{
if (remote)
return glnx_throw (error, "Cannot create alias to remote ref: %s", remote);
if (!g_hash_table_contains (refs, refspec_prefix))
return glnx_throw (error, "Cannot create alias to non-existent ref: %s",
refspec_prefix);
if (!ostree_repo_set_alias_ref_immediate (repo, remote, ref, refspec_prefix,
cancellable, error))
goto out;