G_BEGIN_DECLS
+/* @refspec_name is set if this is a dynamic remote. It’s the name of the static
+ * remote which this one inherits from, and is what should be used in refspecs
+ * for pulls from this remote. If it’s %NULL, @name should be used instead. */
struct OstreeRemote {
volatile int ref_count;
char *name; /* (not nullable) */
+ char *refspec_name; /* (nullable) */
char *group; /* group name in options (not nullable) */
- char *keyring; /* keyring name (NAME.trustedkeys.gpg) (not nullable) */
+ char *keyring; /* keyring name ($refspec_name.trustedkeys.gpg) (not nullable) */
GFile *file; /* NULL if remote defined in repo/config */
GKeyFile *options;
};
G_GNUC_INTERNAL
OstreeRemote *ostree_remote_new (const gchar *name);
+G_GNUC_INTERNAL
+OstreeRemote *ostree_remote_new_dynamic (const gchar *name,
+ const gchar *refspec_name);
G_GNUC_INTERNAL
OstreeRemote *ostree_remote_new_from_keyfile (GKeyFile *keyfile,
OstreeRemote *
ostree_remote_new (const gchar *name)
+{
+ return ostree_remote_new_dynamic (name, NULL);
+}
+
+OstreeRemote *
+ostree_remote_new_dynamic (const gchar *name,
+ const gchar *refspec_name)
{
OstreeRemote *remote;
g_return_val_if_fail (name != NULL && *name != '\0', NULL);
+ g_return_val_if_fail (refspec_name == NULL || *refspec_name != '\0', NULL);
remote = g_slice_new0 (OstreeRemote);
remote->ref_count = 1;
remote->name = g_strdup (name);
- remote->group = g_strdup_printf ("remote \"%s\"", name);
- remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", name);
+ remote->refspec_name = g_strdup (refspec_name);
+ remote->group = g_strdup_printf ("remote \"%s\"", (refspec_name != NULL) ? refspec_name : name);
+ remote->keyring = g_strdup_printf ("%s.trustedkeys.gpg", (refspec_name != NULL) ? refspec_name : name);
remote->options = g_key_file_new ();
return remote;
/* Build an #OstreeRemote. Use the escaped URI, since remote->name
* is used in file paths, so needs to not contain special characters. */
g_autofree gchar *name = uri_and_keyring_to_name (repo);
- remote = ostree_remote_new (name);
+ remote = ostree_remote_new_dynamic (name, repo->keyring_remote->name);
g_clear_pointer (&remote->keyring, g_free);
remote->keyring = g_strdup (repo->keyring_remote->keyring);
/* Build an #OstreeRemote. Use the escaped URI, since remote->name
* is used in file paths, so needs to not contain special characters. */
g_autofree gchar *name = uri_and_keyring_to_name (repo);
- remote = ostree_remote_new (name);
+ remote = ostree_remote_new_dynamic (name, repo->keyring_remote->name);
g_clear_pointer (&remote->keyring, g_free);
remote->keyring = g_strdup (repo->keyring_remote->keyring);