bin/refs: Disallow aliases to remote refs
authorColin Walters <walters@verbum.org>
Thu, 14 Dec 2017 18:13:42 +0000 (13:13 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 14 Dec 2017 22:22:39 +0000 (22:22 +0000)
It can't really work in general; the client and server would
have to agree on the name of the remote.

Closes: https://github.com/ostreedev/ostree/issues/1342
Closes: #1381
Approved by: jlebon

src/ostree/ot-builtin-refs.c
tests/test-refs.sh

index 3508a5291f6bd435bf2e0b97f3fc8d2b62502c5a..be5cf9d45d7ac3f8b9bb76992f3ff598ae36e00d 100644 (file)
@@ -223,6 +223,8 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
 
       if (opt_alias)
         {
+          if (remote)
+            return glnx_throw (error, "Cannot create alias to remote ref: %s", remote);
           if (!ostree_repo_set_alias_ref_immediate (repo, remote, ref, refspec_prefix,
                                                     cancellable, error))
             goto out;
index 1f0dbdbd7088c72f10f84a0e42729df7a889f7c7..316e3e10c5667d291cad086cbf5ac3ad142f3261 100755 (executable)
@@ -23,7 +23,7 @@ set -euo pipefail
 
 setup_fake_remote_repo1 "archive"
 
-echo '1..5'
+echo '1..6'
 
 cd ${test_tmpdir}
 mkdir repo
@@ -186,3 +186,10 @@ assert_file_has_content_literal refs.txt 'exampleos/x86_64/stable/server -> exam
 ${CMD_PREFIX} ostree --repo=repo summary -u
 
 echo "ok ref symlink"
+
+# https://github.com/ostreedev/ostree/issues/1342
+if ${CMD_PREFIX} ostree --repo=repo refs -A exampleos/x86_64/27/server --create=exampleos:exampleos/x86_64/stable/server 2>err.txt; then
+    fatal "Created alias ref to remote?"
+fi
+assert_file_has_content_literal err.txt 'Cannot create alias to remote ref'
+echo "ok ref no alias remote"