44
int ignore_skipworktree;
45
int ignore_other_worktrees;
46
int show_progress;
47
+ int count_checkout_paths;
48
/*
49
* If new checkout options are added, skip_merge_working_tree
50
* should be updated accordingly.
166
}
167
168
static int checkout_stage(int stage, const struct cache_entry *ce, int pos,
168
- const struct checkout *state)
169
+ const struct checkout *state, int *nr_checkouts)
170
{
171
while (pos < active_nr &&
172
!strcmp(active_cache[pos]->name, ce->name)) {
173
if (ce_stage(active_cache[pos]) == stage)
173
- return checkout_entry(active_cache[pos], state, NULL);
174
+ return checkout_entry(active_cache[pos], state,
175
+ NULL, nr_checkouts);
176
pos++;
177
}
178
if (stage == 2)
181
return error(_("path '%s' does not have their version"), ce->name);
182
}
183
182
-static int checkout_merged(int pos, const struct checkout *state)
184
+static int checkout_merged(int pos, const struct checkout *state, int *nr_checkouts)
185
{
186
struct cache_entry *ce = active_cache[pos];
187
const char *path = ce->name;
244
ce = make_transient_cache_entry(mode, &oid, path, 2);
245
if (!ce)
246
die(_("make_cache_entry failed for path '%s'"), path);
245
- status = checkout_entry(ce, state, NULL);
247
+ status = checkout_entry(ce, state, NULL, nr_checkouts);
248
discard_cache_entry(ce);
249
return status;
250
}
259
struct commit *head;
260
int errs = 0;
261
struct lock_file lock_file = LOCK_INIT;
262
+ int nr_checkouts = 0;
263
264
if (opts->track != BRANCH_TRACK_UNSPECIFIED)
265
die(_("'%s' cannot be used with updating paths"), "--track");
374
struct cache_entry *ce = active_cache[pos];
375
if (ce->ce_flags & CE_MATCHED) {
376
if (!ce_stage(ce)) {
374
- errs |= checkout_entry(ce, &state, NULL);
377
+ errs |= checkout_entry(ce, &state,
378
+ NULL, &nr_checkouts);
379
continue;
380
}
381
if (opts->writeout_stage)
378
- errs |= checkout_stage(opts->writeout_stage, ce, pos, &state);
382
+ errs |= checkout_stage(opts->writeout_stage,
383
+ ce, pos,
384
+ &state, &nr_checkouts);
385
else if (opts->merge)
380
- errs |= checkout_merged(pos, &state);
386
+ errs |= checkout_merged(pos, &state,
387
+ &nr_checkouts);
388
pos = skip_same_name(ce, pos) - 1;
389
}
390
}
384
- errs |= finish_delayed_checkout(&state);
391
+ errs |= finish_delayed_checkout(&state, &nr_checkouts);
392
+
393
+ if (opts->count_checkout_paths) {
394
+ if (opts->source_tree)
395
+ fprintf_ln(stderr, Q_("Checked out %d path out of %s",
396
+ "Checked out %d paths out of %s",
397
+ nr_checkouts),
398
+ nr_checkouts,
399
+ find_unique_abbrev(&opts->source_tree->object.oid,
400
+ DEFAULT_ABBREV));
401
+ else
402
+ fprintf_ln(stderr, Q_("Checked out %d path out of the index",
403
+ "Checked out %d paths out of the index",
404
+ nr_checkouts),
405
+ nr_checkouts);
406
+ }
407
408
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
409
die(_("unable to write new index file"));
1086
has_dash_dash = 1; /* case (3) or (1) */
1087
else if (dash_dash_pos >= 2)
1088
die(_("only one reference expected, %d given."), dash_dash_pos);
1089
+ opts->count_checkout_paths = !opts->quiet && !has_dash_dash;
1090
1091
if (!strcmp(arg, "-"))
1092
arg = "@{-1}";