summaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorLibravatar Michael Haggerty <mhagger@alum.mit.edu>2014-11-25 09:02:32 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-11-25 10:09:58 -0800
commit4a45b2f347245d321bf5c07fbe3f8091d122732f (patch)
tree31d312133a1e3477343face2db8bf865e9f379f3 /builtin/remote.c
parentprune_remote(): sort delete_refs_list references en masse (diff)
downloadtgif-4a45b2f347245d321bf5c07fbe3f8091d122732f.tar.xz
repack_without_refs(): make the refnames argument a string_list
Most of the callers have string_lists available already, whereas two of them had to read data out of a string_list into an array of strings just to call this function. So change repack_without_refs() to take the list of refnames to omit as a string_list, and change the callers accordingly. Suggested-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/remote.c')
-rw-r--r--builtin/remote.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index 7d5c8d2074..63a67098a0 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -750,16 +750,11 @@ static int mv(int argc, const char **argv)
static int remove_branches(struct string_list *branches)
{
struct strbuf err = STRBUF_INIT;
- const char **branch_names;
int i, result = 0;
- branch_names = xmalloc(branches->nr * sizeof(*branch_names));
- for (i = 0; i < branches->nr; i++)
- branch_names[i] = branches->items[i].string;
- if (repack_without_refs(branch_names, branches->nr, &err))
+ if (repack_without_refs(branches, &err))
result |= error("%s", err.buf);
strbuf_release(&err);
- free(branch_names);
for (i = 0; i < branches->nr; i++) {
struct string_list_item *item = branches->items + i;
@@ -1317,7 +1312,6 @@ static int prune_remote(const char *remote, int dry_run)
int result = 0, i;
struct ref_states states;
struct string_list delete_refs_list = STRING_LIST_INIT_NODUP;
- const char **delete_refs;
const char *dangling_msg = dry_run
? _(" %s will become dangling!")
: _(" %s has become dangling!");
@@ -1336,19 +1330,16 @@ static int prune_remote(const char *remote, int dry_run)
? states.remote->url[0]
: _("(no URL)"));
- delete_refs = xmalloc(states.stale.nr * sizeof(*delete_refs));
for (i = 0; i < states.stale.nr; i++) {
const char *refname = states.stale.items[i].util;
- delete_refs[i] = refname;
string_list_append(&delete_refs_list, refname);
}
sort_string_list(&delete_refs_list);
if (!dry_run) {
struct strbuf err = STRBUF_INIT;
- if (repack_without_refs(delete_refs, states.stale.nr,
- &err))
+ if (repack_without_refs(&delete_refs_list, &err))
result |= error("%s", err.buf);
strbuf_release(&err);
}
@@ -1369,7 +1360,6 @@ static int prune_remote(const char *remote, int dry_run)
warn_dangling_symrefs(stdout, dangling_msg, &delete_refs_list);
- free(delete_refs);
string_list_clear(&delete_refs_list, 0);
free_remote_ref_states(&states);
return result;