[PATCH 02/22] use cache iterator in checkout-index.c
Signed-off-by: Chuck Lever <cel@netapp.com>
---
checkout-index.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/checkout-index.c b/checkout-index.c
--- a/checkout-index.c
+++ b/checkout-index.c
@@ -61,17 +61,12 @@ static int checkout_file(const char *nam
return checkout_entry(active_cache[pos], &state);
}
-static int checkout_all(void)
+static int checkout_one(struct cache_cursor *cc, struct cache_entry *ce)
{
- int i;
-
- for (i = 0; i < active_nr ; i++) {
- struct cache_entry *ce = active_cache[i];
- if (ce_stage(ce))
- continue;
+ if (!ce_stage(ce))
if (checkout_entry(ce, &state) < 0)
return -1;
- }
+ next_cc(cc);
return 0;
}
@@ -85,15 +80,14 @@ int main(int argc, char **argv)
int i, force_filename = 0;
int newfd = -1;
- if (read_cache() < 0) {
+ if (read_cache() < 0)
die("invalid cache");
- }
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!force_filename) {
if (!strcmp(arg, "-a")) {
- checkout_all();
+ walk_cache(checkout_one);
continue;
}
if (!strcmp(arg, "--")) {