[gitg] rewrite gitg_ref_get_localname to return a const result
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] rewrite gitg_ref_get_localname to return a const result
- Date: Sat, 29 May 2010 16:52:00 +0000 (UTC)
commit ed64420703e49b273336f59b7dd14f7a77fb7dc3
Author: Edward Rudd <urkle outoforder cc>
Date: Sat Jan 16 01:54:03 2010 -0500
rewrite gitg_ref_get_localname to return a const result
https://bugzilla.gnome.org/show_bug.cgi?id=606792
gitg/gitg-branch-actions.c | 9 +++------
gitg/gitg-ref.c | 6 +++---
gitg/gitg-ref.h | 2 +-
gitg/gitg-window.c | 3 +--
4 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gitg/gitg-branch-actions.c b/gitg/gitg-branch-actions.c
index 4d207de..35a230b 100644
--- a/gitg/gitg-branch-actions.c
+++ b/gitg/gitg-branch-actions.c
@@ -343,9 +343,8 @@ remove_remote_branch (GitgWindow *window,
return NULL;
}
- gchar *local = gitg_ref_get_local_name (ref);
+ gchar const *local = gitg_ref_get_local_name (ref);
gchar *rm = g_strconcat (":", local, NULL);
- g_free (local);
GitgRunner *ret;
gchar *message = g_strdup_printf ("Removing remote branch `%s'", name);
@@ -983,7 +982,7 @@ checkout_remote_branch (GitgWindow *window,
GitgRepository *repository = gitg_window_get_repository (window);
gchar const *name = gitg_ref_get_shortname (ref);
- gchar *local = gitg_ref_get_local_name (ref);
+ gchar const *local = gitg_ref_get_local_name (ref);
gboolean ret;
if (!gitg_repository_commandv (repository,
@@ -1010,7 +1009,6 @@ checkout_remote_branch (GitgWindow *window,
ret = TRUE;
}
- g_free (local);
return ret;
}
@@ -1412,7 +1410,7 @@ gitg_branch_actions_push (GitgWindow *window,
g_free (message);
gchar const *prefix = gitg_ref_get_prefix (dest);
- gchar *local = gitg_ref_get_local_name (dest);
+ gchar const *local = gitg_ref_get_local_name (dest);
gchar const *name = gitg_ref_get_shortname (source);
gchar *spec = g_strconcat (name, ":", local, NULL);
@@ -1434,7 +1432,6 @@ gitg_branch_actions_push (GitgWindow *window,
NULL);
g_free (message);
- g_free (local);
g_free (spec);
return ret;
diff --git a/gitg/gitg-ref.c b/gitg/gitg-ref.c
index d78c457..42b8506 100644
--- a/gitg/gitg-ref.c
+++ b/gitg/gitg-ref.c
@@ -216,7 +216,7 @@ gitg_ref_set_state (GitgRef *ref,
ref->state = state;
}
-gchar *
+gchar const *
gitg_ref_get_local_name (GitgRef *ref)
{
gchar const *shortname = gitg_ref_get_shortname (ref);
@@ -224,11 +224,11 @@ gitg_ref_get_local_name (GitgRef *ref)
if (prefix && g_str_has_prefix (shortname, prefix))
{
- return g_strdup (shortname + strlen(prefix) + 1);
+ return shortname + strlen(prefix) + 1;
}
else
{
- return g_strdup (shortname);
+ return shortname;
}
}
diff --git a/gitg/gitg-ref.h b/gitg/gitg-ref.h
index 3744d5d..154c7a3 100644
--- a/gitg/gitg-ref.h
+++ b/gitg/gitg-ref.h
@@ -62,7 +62,7 @@ gchar const *gitg_ref_get_name (GitgRef *ref);
gchar const *gitg_ref_get_shortname (GitgRef *ref);
gchar const *gitg_ref_get_prefix (GitgRef *ref);
-gchar *gitg_ref_get_local_name (GitgRef *ref);
+gchar const *gitg_ref_get_local_name (GitgRef *ref);
GitgRefState gitg_ref_get_state (GitgRef *ref);
void gitg_ref_set_state (GitgRef *ref,
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 82f8688..2b9a963 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -2298,7 +2298,7 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_REMOTE)
{
- gchar *local = gitg_ref_get_local_name (ref);
+ gchar const *local = gitg_ref_get_local_name (ref);
if (!has_local_ref (window, local))
{
@@ -2313,7 +2313,6 @@ popup_ref (GitgWindow *window, GdkEventButton *event)
gtk_action_set_visible (checkout, FALSE);
}
- g_free (local);
g_object_set (remove, "label", _("Remove remote branch"), NULL);
gtk_action_set_visible (rename, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]