mirror of
https://git.proxmox.com/git/fwupd
synced 2025-07-17 08:20:33 +00:00
Allow going back to the 'default' branch
We only want to translate a NULL branch into 'default' for display, and not actually store it in the GPtrArray.
This commit is contained in:
parent
814a5ee874
commit
89ee9edc0a
@ -2569,6 +2569,11 @@ fu_util_esp_list (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_g_str_equal0 (gconstpointer str1, gconstpointer str2)
|
||||
{
|
||||
return g_strcmp0 (str1, str2) == 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
@ -2615,10 +2620,10 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
/* get all the unique branches */
|
||||
for (guint i = 0; i < rels->len; i++) {
|
||||
FwupdRelease *rel_tmp = g_ptr_array_index (rels, i);
|
||||
const gchar *branch_tmp = fu_util_release_get_branch (rel_tmp);
|
||||
const gchar *branch_tmp = fwupd_release_get_branch (rel_tmp);
|
||||
#if GLIB_CHECK_VERSION(2,54,3)
|
||||
if (g_ptr_array_find_with_equal_func (branches, branch_tmp,
|
||||
g_str_equal, NULL))
|
||||
_g_str_equal0, NULL))
|
||||
continue;
|
||||
#endif
|
||||
g_ptr_array_add (branches, g_strdup (branch_tmp));
|
||||
@ -2639,7 +2644,7 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
g_print ("0.\t%s\n", _("Cancel"));
|
||||
for (guint i = 0; i < branches->len; i++) {
|
||||
const gchar *branch_tmp = g_ptr_array_index (branches, i);
|
||||
g_print ("%u.\t%s\n", i + 1, branch_tmp);
|
||||
g_print ("%u.\t%s\n", i + 1, fu_util_branch_for_display (branch_tmp));
|
||||
}
|
||||
idx = fu_util_prompt_for_number (branches->len);
|
||||
if (idx == 0) {
|
||||
@ -2659,7 +2664,7 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
"Device %s is already on branch %s",
|
||||
fu_device_get_name (dev),
|
||||
branch);
|
||||
fu_util_branch_for_display (branch));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -2676,7 +2681,7 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
"No releases for branch %s",
|
||||
branch);
|
||||
fu_util_branch_for_display (branch));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -601,14 +601,13 @@ fu_util_cmd_array_to_string (GPtrArray *array)
|
||||
}
|
||||
|
||||
const gchar *
|
||||
fu_util_release_get_branch (FwupdRelease *release)
|
||||
fu_util_branch_for_display (const gchar *branch)
|
||||
{
|
||||
const gchar *tmp = fwupd_release_get_branch (release);
|
||||
if (tmp == NULL) {
|
||||
if (branch == NULL) {
|
||||
/* TRANSLATORS: this is the default branch name when unset */
|
||||
return _("default");
|
||||
}
|
||||
return tmp;
|
||||
return branch;
|
||||
}
|
||||
|
||||
gchar *
|
||||
|
@ -78,7 +78,7 @@ gboolean fu_util_cmd_array_run (GPtrArray *array,
|
||||
gchar **values,
|
||||
GError **error);
|
||||
gchar *fu_util_release_get_name (FwupdRelease *release);
|
||||
const gchar *fu_util_release_get_branch (FwupdRelease *release);
|
||||
const gchar *fu_util_branch_for_display (const gchar *branch);
|
||||
|
||||
const gchar *fu_util_get_systemd_unit (void);
|
||||
gboolean fu_util_using_correct_daemon (GError **error);
|
||||
|
@ -1905,6 +1905,12 @@ fu_util_reinstall (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
return fu_util_prompt_complete (priv->completion_flags, TRUE, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_g_str_equal0 (gconstpointer str1, gconstpointer str2)
|
||||
{
|
||||
return g_strcmp0 (str1, str2) == 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
{
|
||||
@ -1931,10 +1937,10 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
/* get all the unique branches */
|
||||
for (guint i = 0; i < rels->len; i++) {
|
||||
FwupdRelease *rel_tmp = g_ptr_array_index (rels, i);
|
||||
const gchar *branch_tmp = fu_util_release_get_branch (rel_tmp);
|
||||
const gchar *branch_tmp = fwupd_release_get_branch (rel_tmp);
|
||||
#if GLIB_CHECK_VERSION(2,54,3)
|
||||
if (g_ptr_array_find_with_equal_func (branches, branch_tmp,
|
||||
g_str_equal, NULL))
|
||||
_g_str_equal0, NULL))
|
||||
continue;
|
||||
#endif
|
||||
g_ptr_array_add (branches, g_strdup (branch_tmp));
|
||||
@ -1955,7 +1961,7 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
g_print ("0.\t%s\n", _("Cancel"));
|
||||
for (guint i = 0; i < branches->len; i++) {
|
||||
const gchar *branch_tmp = g_ptr_array_index (branches, i);
|
||||
g_print ("%u.\t%s\n", i + 1, branch_tmp);
|
||||
g_print ("%u.\t%s\n", i + 1, fu_util_branch_for_display (branch_tmp));
|
||||
}
|
||||
idx = fu_util_prompt_for_number (branches->len);
|
||||
if (idx == 0) {
|
||||
@ -1975,7 +1981,7 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
"Device %s is already on branch %s",
|
||||
fu_device_get_name (dev),
|
||||
branch);
|
||||
fu_util_branch_for_display (branch));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -1992,7 +1998,7 @@ fu_util_switch_branch (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||
FWUPD_ERROR,
|
||||
FWUPD_ERROR_NOT_SUPPORTED,
|
||||
"No releases for branch %s",
|
||||
branch);
|
||||
fu_util_branch_for_display (branch));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user