From 3c5883b3c96e0435cca2e952754d76c4e45f72e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 6 Feb 2019 09:51:14 +0700 Subject: [PATCH 1/2] checkout: update count-checkouts messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 0f086e6dca [1] counts the number of files updated by "git checkout -- " command and prints it. Later on 536ec1839d [2] adds the ability to remove files in "git checkout -- ". This is still an update on worktree and should be reported to the user. To prepare for such an update since that commit is on track to 'master' now, the messages are rephrased to avoid "checked out" which does not imply file deletion. [1] 0f086e6dca (checkout: print something when checking out paths - 2018-11-13) [2] 536ec1839d (entry: support CE_WT_REMOVE flag in checkout_entry - 2018-12-20) Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- builtin/checkout.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 3a0b86ec1c..41aac55223 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -392,15 +392,15 @@ static int checkout_paths(const struct checkout_opts *opts, if (opts->count_checkout_paths) { if (opts->source_tree) - fprintf_ln(stderr, Q_("Checked out %d path out of %s", - "Checked out %d paths out of %s", + fprintf_ln(stderr, Q_("Updated %d path from %s", + "Updated %d paths from %s", nr_checkouts), nr_checkouts, find_unique_abbrev(&opts->source_tree->object.oid, DEFAULT_ABBREV)); else - fprintf_ln(stderr, Q_("Checked out %d path out of the index", - "Checked out %d paths out of the index", + fprintf_ln(stderr, Q_("Updated %d path from the index", + "Updated %d paths from the index", nr_checkouts), nr_checkouts); } From 1d1f689bef77b1bd0cb0f0bc0e0bd766283c5df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 6 Feb 2019 09:51:15 +0700 Subject: [PATCH 2/2] checkout: count and print -m paths separately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 0f086e6dca (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 Signed-off-by: Junio C Hamano --- builtin/checkout.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 41aac55223..12e9d7d1e4 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -259,7 +259,7 @@ static int checkout_paths(const struct checkout_opts *opts, struct commit *head; int errs = 0; struct lock_file lock_file = LOCK_INIT; - int nr_checkouts = 0; + int nr_checkouts = 0, nr_unmerged = 0; if (opts->track != BRANCH_TRACK_UNSPECIFIED) die(_("'%s' cannot be used with updating paths"), "--track"); @@ -384,13 +384,18 @@ static int checkout_paths(const struct checkout_opts *opts, &state, &nr_checkouts); else if (opts->merge) errs |= checkout_merged(pos, &state, - &nr_checkouts); + &nr_unmerged); pos = skip_same_name(ce, pos) - 1; } } errs |= finish_delayed_checkout(&state, &nr_checkouts); if (opts->count_checkout_paths) { + if (nr_unmerged) + fprintf_ln(stderr, Q_("Recreated %d merge conflict", + "Recreated %d merge conflicts", + nr_unmerged), + nr_unmerged); if (opts->source_tree) fprintf_ln(stderr, Q_("Updated %d path from %s", "Updated %d paths from %s", @@ -398,7 +403,7 @@ static int checkout_paths(const struct checkout_opts *opts, nr_checkouts, find_unique_abbrev(&opts->source_tree->object.oid, DEFAULT_ABBREV)); - else + else if (!nr_unmerged || nr_checkouts) fprintf_ln(stderr, Q_("Updated %d path from the index", "Updated %d paths from the index", nr_checkouts),