summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2014-11-25 08:02:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-11-25 18:10:52 (GMT)
commit8552943f41373583b5185a9686102251c544c07e (patch)
tree55ef304929b279055257106ff2cb906b97bbf8bb /builtin
parentfcce0da9750345d3f327ef4767cf2e166e40ce12 (diff)
downloadgit-8552943f41373583b5185a9686102251c544c07e.zip
git-8552943f41373583b5185a9686102251c544c07e.tar.gz
git-8552943f41373583b5185a9686102251c544c07e.tar.bz2
prune_remote(): iterate using for_each_string_list_item()
Iterate over refs_to_prune using for_each_string_list_item() rather than writing out the loop in longhand. 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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/remote.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index efbf5fb..7fec170 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1309,9 +1309,10 @@ static int set_head(int argc, const char **argv)
static int prune_remote(const char *remote, int dry_run)
{
- int result = 0, i;
+ int result = 0;
struct ref_states states;
struct string_list refs_to_prune = STRING_LIST_INIT_NODUP;
+ struct string_list_item *item;
const char *dangling_msg = dry_run
? _(" %s will become dangling!")
: _(" %s has become dangling!");
@@ -1330,11 +1331,8 @@ static int prune_remote(const char *remote, int dry_run)
? states.remote->url[0]
: _("(no URL)"));
- for (i = 0; i < states.stale.nr; i++) {
- const char *refname = states.stale.items[i].util;
-
- string_list_append(&refs_to_prune, refname);
- }
+ for_each_string_list_item(item, &states.stale)
+ string_list_append(&refs_to_prune, item->util);
sort_string_list(&refs_to_prune);
if (!dry_run) {
@@ -1344,8 +1342,8 @@ static int prune_remote(const char *remote, int dry_run)
strbuf_release(&err);
}
- for (i = 0; i < states.stale.nr; i++) {
- const char *refname = states.stale.items[i].util;
+ for_each_string_list_item(item, &states.stale) {
+ const char *refname = item->util;
if (!dry_run)
result |= delete_ref(refname, NULL, 0);