prune_remote(): exit early if there are no stale references

Aside from making the logic clearer, this avoids a call to
warn_dangling_symrefs(), which always does a for_each_rawref()
iteration.

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:
Michael Haggerty 2014-11-25 09:02:29 +01:00 committed by Junio C Hamano
parent e69b1ce000
commit 16d4fa3d96

View File

@ -1325,7 +1325,11 @@ static int prune_remote(const char *remote, int dry_run)
memset(&states, 0, sizeof(states));
get_remote_ref_states(remote, &states, GET_REF_STATES);
if (states.stale.nr) {
if (!states.stale.nr) {
free_remote_ref_states(&states);
return 0;
}
printf_ln(_("Pruning %s"), remote);
printf_ln(_("URL: %s"),
states.remote->url_nr
@ -1343,7 +1347,6 @@ static int prune_remote(const char *remote, int dry_run)
strbuf_release(&err);
}
free(delete_refs);
}
for (i = 0; i < states.stale.nr; i++) {
const char *refname = states.stale.items[i].util;