Skip to content

Commit 3fde386

Browse files
martinvonzgitster
authored andcommitted
reset [--mixed]: use diff-based reset whether or not pathspec was given
Thanks to b65982b (Optimize "diff-index --cached" using cache-tree, 2009-05-20), resetting with paths is much faster than resetting without paths. Some timings for the linux-2.6 repo to illustrate this (best of five, warm cache): reset reset . real 0m0.219s 0m0.080s user 0m0.140s 0m0.040s sys 0m0.070s 0m0.030s These two commands should do the same thing, so instead of having the user type the trailing " ." to get the faster do_diff_cache()-based implementation, always use it when doing a mixed reset, with or without paths (so "git reset $rev" would also be faster). Timing "git reset" shows that it indeed becomes as fast as "git reset ." after this patch. Signed-off-by: Martin von Zweigbergk <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 166ec2e commit 3fde386

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
@@ -322,7 +322,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
322322
if (reset_type != SOFT) {
323323
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
324324
int newfd = hold_locked_index(lock, 1);
325-
if (pathspec) {
325+
if (reset_type == MIXED) {
326326
if (read_from_tree(pathspec, sha1))
327327
return 1;
328328
} else {

0 commit comments

Comments
 (0)