rpmostreed-utils.c: switch to new style
Since we're going to do some work there. Also fix not always translating the error from ostree_parse_refspec. Closes: #764 Approved by: cgwalters
This commit is contained in:
parent
3f5f749f82
commit
a54efdff8a
@ -137,36 +137,38 @@ rpmostreed_refspec_parse_partial (const gchar *new_provided_refspec,
|
|||||||
|
|
||||||
g_autofree gchar *ref = NULL;
|
g_autofree gchar *ref = NULL;
|
||||||
g_autofree gchar *remote = NULL;
|
g_autofree gchar *remote = NULL;
|
||||||
g_autofree gchar *origin_ref = NULL;
|
|
||||||
g_autofree gchar *origin_remote = NULL;
|
|
||||||
GError *parse_error = NULL;
|
|
||||||
|
|
||||||
gboolean ret = FALSE;
|
|
||||||
|
|
||||||
/* Allow just switching remotes */
|
/* Allow just switching remotes */
|
||||||
if (g_str_has_suffix (new_provided_refspec, ":"))
|
if (g_str_has_suffix (new_provided_refspec, ":"))
|
||||||
{
|
{
|
||||||
remote = g_strdup (new_provided_refspec);
|
remote = g_strndup (new_provided_refspec, strlen(new_provided_refspec)-1);
|
||||||
remote[strlen (remote) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
g_autoptr(GError) parse_error = NULL;
|
||||||
if (!ostree_parse_refspec (new_provided_refspec, &remote,
|
if (!ostree_parse_refspec (new_provided_refspec, &remote,
|
||||||
&ref, &parse_error))
|
&ref, &parse_error))
|
||||||
{
|
{
|
||||||
g_set_error_literal (error, RPM_OSTREED_ERROR,
|
g_set_error_literal (error, RPM_OSTREED_ERROR,
|
||||||
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
||||||
parse_error->message);
|
parse_error->message);
|
||||||
g_clear_error (&parse_error);
|
return FALSE;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_autofree gchar *origin_ref = NULL;
|
||||||
|
g_autofree gchar *origin_remote = NULL;
|
||||||
if (base_refspec != NULL)
|
if (base_refspec != NULL)
|
||||||
{
|
{
|
||||||
|
g_autoptr(GError) parse_error = NULL;
|
||||||
if (!ostree_parse_refspec (base_refspec, &origin_remote,
|
if (!ostree_parse_refspec (base_refspec, &origin_remote,
|
||||||
&origin_ref, &parse_error))
|
&origin_ref, &parse_error))
|
||||||
goto out;
|
{
|
||||||
|
g_set_error_literal (error, RPM_OSTREED_ERROR,
|
||||||
|
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
||||||
|
parse_error->message);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref == NULL)
|
if (ref == NULL)
|
||||||
@ -175,13 +177,12 @@ rpmostreed_refspec_parse_partial (const gchar *new_provided_refspec,
|
|||||||
{
|
{
|
||||||
ref = g_strdup (origin_ref);
|
ref = g_strdup (origin_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_set_error (error, RPM_OSTREED_ERROR,
|
g_set_error (error, RPM_OSTREED_ERROR,
|
||||||
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
||||||
"Could not determine default ref to pull.");
|
"Could not determine default ref to pull.");
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -200,7 +201,7 @@ rpmostreed_refspec_parse_partial (const gchar *new_provided_refspec,
|
|||||||
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
RPM_OSTREED_ERROR_INVALID_REFSPEC,
|
||||||
"Old and new refs are equal: %s:%s",
|
"Old and new refs are equal: %s:%s",
|
||||||
remote, ref);
|
remote, ref);
|
||||||
goto out;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remote == NULL)
|
if (remote == NULL)
|
||||||
@ -208,10 +209,7 @@ rpmostreed_refspec_parse_partial (const gchar *new_provided_refspec,
|
|||||||
else
|
else
|
||||||
*out_refspec = g_strconcat (remote, ":", ref, NULL);
|
*out_refspec = g_strconcat (remote, ":", ref, NULL);
|
||||||
|
|
||||||
ret = TRUE;
|
return TRUE;
|
||||||
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user