Skip to content

Commit 9ac8125

Browse files
benpeartgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c4df23f commit 9ac8125

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

builtin/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
376376
int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
377377
if (read_from_tree(&pathspec, &oid, intent_to_add))
378378
return 1;
379-
if (get_git_work_tree())
379+
if (!quiet && get_git_work_tree())
380380
refresh_index(&the_index, flags, NULL, NULL,
381381
_("Unstaged changes after reset:"));
382382
} else {

0 commit comments

Comments
 (0)