diff --git a/src/fu-tool.c b/src/fu-tool.c index eaa751808..c6a3ea10d 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -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; } diff --git a/src/fu-util-common.c b/src/fu-util-common.c index 2270429d6..7d9463afb 100644 --- a/src/fu-util-common.c +++ b/src/fu-util-common.c @@ -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 * diff --git a/src/fu-util-common.h b/src/fu-util-common.h index f5232f418..ec107c34e 100644 --- a/src/fu-util-common.h +++ b/src/fu-util-common.h @@ -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); diff --git a/src/fu-util.c b/src/fu-util.c index d0fa87c18..21495a3f7 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -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; }