Skip to content

Commit 1d1f689

Browse files
pcloudsgitster
authored andcommitted
checkout: count and print -m paths separately
Since 0f086e6 (checkout: print something when checking out paths - 2018-11-13), this command reports how many paths have been updated from what source (either from a tree, or from the index). I forget that there's a third source: when -m is used, the merge conflict is re-created (granted, also from the index, but it's not a straight copy from the index). Count and report unmerged paths separately. There's a bit more update to avoid reporting: Recreated X merge conflicts Updated 0 paths from the index The second line is unnecessary. Though if there's no conflict recreation, we still report Updated 0 paths from the index to make it clear we're not really doing anything. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c5883b commit 1d1f689

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

builtin/checkout.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int checkout_paths(const struct checkout_opts *opts,
259259
struct commit *head;
260260
int errs = 0;
261261
struct lock_file lock_file = LOCK_INIT;
262-
int nr_checkouts = 0;
262+
int nr_checkouts = 0, nr_unmerged = 0;
263263

264264
if (opts->track != BRANCH_TRACK_UNSPECIFIED)
265265
die(_("'%s' cannot be used with updating paths"), "--track");
@@ -384,21 +384,26 @@ static int checkout_paths(const struct checkout_opts *opts,
384384
&state, &nr_checkouts);
385385
else if (opts->merge)
386386
errs |= checkout_merged(pos, &state,
387-
&nr_checkouts);
387+
&nr_unmerged);
388388
pos = skip_same_name(ce, pos) - 1;
389389
}
390390
}
391391
errs |= finish_delayed_checkout(&state, &nr_checkouts);
392392

393393
if (opts->count_checkout_paths) {
394+
if (nr_unmerged)
395+
fprintf_ln(stderr, Q_("Recreated %d merge conflict",
396+
"Recreated %d merge conflicts",
397+
nr_unmerged),
398+
nr_unmerged);
394399
if (opts->source_tree)
395400
fprintf_ln(stderr, Q_("Updated %d path from %s",
396401
"Updated %d paths from %s",
397402
nr_checkouts),
398403
nr_checkouts,
399404
find_unique_abbrev(&opts->source_tree->object.oid,
400405
DEFAULT_ABBREV));
401-
else
406+
else if (!nr_unmerged || nr_checkouts)
402407
fprintf_ln(stderr, Q_("Updated %d path from the index",
403408
"Updated %d paths from the index",
404409
nr_checkouts),

0 commit comments

Comments
 (0)