mirror of
https://github.com/git/git.git
synced 2024-11-15 15:03:47 +01:00
prune_remote(): initialize both delete_refs lists in a single loop
Also free them together at the end of the function. In a moment, the array version will become redundant. Managing them together makes later steps more obvious. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
16d4fa3d96
commit
28d3f214d1
@ -1337,8 +1337,13 @@ static int prune_remote(const char *remote, int dry_run)
|
||||
: _("(no URL)"));
|
||||
|
||||
delete_refs = xmalloc(states.stale.nr * sizeof(*delete_refs));
|
||||
for (i = 0; i < states.stale.nr; i++)
|
||||
delete_refs[i] = states.stale.items[i].util;
|
||||
for (i = 0; i < states.stale.nr; i++) {
|
||||
const char *refname = states.stale.items[i].util;
|
||||
|
||||
delete_refs[i] = refname;
|
||||
string_list_insert(&delete_refs_list, refname);
|
||||
}
|
||||
|
||||
if (!dry_run) {
|
||||
struct strbuf err = STRBUF_INIT;
|
||||
if (repack_without_refs(delete_refs, states.stale.nr,
|
||||
@ -1346,13 +1351,10 @@ static int prune_remote(const char *remote, int dry_run)
|
||||
result |= error("%s", err.buf);
|
||||
strbuf_release(&err);
|
||||
}
|
||||
free(delete_refs);
|
||||
|
||||
for (i = 0; i < states.stale.nr; i++) {
|
||||
const char *refname = states.stale.items[i].util;
|
||||
|
||||
string_list_insert(&delete_refs_list, refname);
|
||||
|
||||
if (!dry_run)
|
||||
result |= delete_ref(refname, NULL, 0);
|
||||
|
||||
@ -1365,8 +1367,9 @@ static int prune_remote(const char *remote, int dry_run)
|
||||
}
|
||||
|
||||
warn_dangling_symrefs(stdout, dangling_msg, &delete_refs_list);
|
||||
string_list_clear(&delete_refs_list, 0);
|
||||
|
||||
free(delete_refs);
|
||||
string_list_clear(&delete_refs_list, 0);
|
||||
free_remote_ref_states(&states);
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user