mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-09 01:18:35 +03:00
admin switch: Allow switching just remote names
This is a followup to the previous commit; for the installation media case we want to keep the current origin ref, and only switch remotes.
This commit is contained in:
parent
24e1bf2552
commit
a864190a04
@ -78,8 +78,6 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_provided_refspec = argv[1];
|
new_provided_refspec = argv[1];
|
||||||
if (!ostree_parse_refspec (new_provided_refspec, &new_remote, &new_ref, error))
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
if (!ostree_sysroot_load (sysroot, cancellable, error))
|
||||||
goto out;
|
goto out;
|
||||||
@ -95,11 +93,24 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
|
|||||||
if (!ostree_parse_refspec (origin_refspec, &origin_remote, &origin_ref, error))
|
if (!ostree_parse_refspec (origin_refspec, &origin_remote, &origin_ref, error))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!new_remote)
|
/* Allow just switching remotes */
|
||||||
new_refspec = g_strconcat (origin_remote, ":", new_provided_refspec, NULL);
|
if (g_str_has_suffix (new_provided_refspec, ":"))
|
||||||
|
{
|
||||||
|
new_remote = g_strdup (new_provided_refspec);
|
||||||
|
new_remote[strlen(new_remote)-1] = '\0';
|
||||||
|
new_ref = g_strdup (origin_ref);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
new_refspec = g_strdup (new_provided_refspec);
|
{
|
||||||
|
if (!ostree_parse_refspec (new_provided_refspec, &new_remote, &new_ref, error))
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!new_remote)
|
||||||
|
new_refspec = g_strconcat (origin_remote, ":", new_ref, NULL);
|
||||||
|
else
|
||||||
|
new_refspec = g_strconcat (new_remote, ":", new_ref, NULL);
|
||||||
|
|
||||||
if (strcmp (origin_refspec, new_refspec) == 0)
|
if (strcmp (origin_refspec, new_refspec) == 0)
|
||||||
{
|
{
|
||||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||||
|
@ -50,3 +50,7 @@ ostree admin --sysroot=sysroot status > status.txt
|
|||||||
assert_file_has_content status.txt anothertestos
|
assert_file_has_content status.txt anothertestos
|
||||||
|
|
||||||
echo "ok switch remotes"
|
echo "ok switch remotes"
|
||||||
|
|
||||||
|
ostree admin --sysroot=sysroot switch --os=testos testos:
|
||||||
|
|
||||||
|
echo "ok switch remote only"
|
||||||
|
Loading…
Reference in New Issue
Block a user