From: Ben Peart Date: Tue, 23 Oct 2018 19:04:21 +0000 (-0400) Subject: reset: don't compute unstaged changes after reset when --quiet X-Git-Tag: v2.20.0-rc0~59^2~78^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9ac8125d1ab83f1a0c48f6f30bb8fea92d9770d7;p=thirdparty%2Fgit.git reset: don't compute unstaged changes after reset when --quiet When git reset is run with the --quiet flag, don't bother finding any additional unstaged changes as they won't be output anyway. This speeds up the git reset command by avoiding having to lstat() every file looking for changes that aren't going to be reported anyway. The savings can be significant. In a repo on Windows with 200K files "git reset" drops from 7.16 seconds to 0.32 seconds for a savings of 96%. Signed-off-by: Ben Peart Signed-off-by: Junio C Hamano --- diff --git a/builtin/reset.c b/builtin/reset.c index 6d37a35e2e..c2f8e72cb3 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -376,7 +376,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN; if (read_from_tree(&pathspec, &oid, intent_to_add)) return 1; - if (get_git_work_tree()) + if (!quiet && get_git_work_tree()) refresh_index(&the_index, flags, NULL, NULL, _("Unstaged changes after reset:")); } else {