[ostree] admin switch: Allow switching just remote names
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] admin switch: Allow switching just remote names
- Date: Thu, 15 May 2014 13:00:07 +0000 (UTC)
commit a864190a04da91ddb75812be7e0fe6d9de18eb15
Author: Colin Walters <walters verbum org>
Date: Thu May 15 08:58:44 2014 -0400
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.
src/ostree/ot-admin-builtin-switch.c | 21 ++++++++++++++++-----
tests/test-admin-deploy-switch.sh | 4 ++++
2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/ostree/ot-admin-builtin-switch.c b/src/ostree/ot-admin-builtin-switch.c
index ad02b90..44861e5 100644
--- a/src/ostree/ot-admin-builtin-switch.c
+++ b/src/ostree/ot-admin-builtin-switch.c
@@ -78,8 +78,6 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
}
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))
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))
goto out;
+ /* Allow just switching remotes */
+ 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
+ {
+ if (!ostree_parse_refspec (new_provided_refspec, &new_remote, &new_ref, error))
+ goto out;
+ }
+
if (!new_remote)
- new_refspec = g_strconcat (origin_remote, ":", new_provided_refspec, NULL);
+ new_refspec = g_strconcat (origin_remote, ":", new_ref, NULL);
else
- new_refspec = g_strdup (new_provided_refspec);
-
+ new_refspec = g_strconcat (new_remote, ":", new_ref, NULL);
+
if (strcmp (origin_refspec, new_refspec) == 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
diff --git a/tests/test-admin-deploy-switch.sh b/tests/test-admin-deploy-switch.sh
index f791348..0516e5c 100644
--- a/tests/test-admin-deploy-switch.sh
+++ b/tests/test-admin-deploy-switch.sh
@@ -50,3 +50,7 @@ ostree admin --sysroot=sysroot status > status.txt
assert_file_has_content status.txt anothertestos
echo "ok switch remotes"
+
+ostree admin --sysroot=sysroot switch --os=testos testos:
+
+echo "ok switch remote only"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]