"git reset [--mixed]" without --quiet refreshes the index in order to
display the "Unstaged changes after reset". When --quiet is given,
that output is suppressed, removing the need to refresh the index.
Other porcelain commands that care about a refreshed index should
already be refreshing it, so running e.g. "git reset -q && git diff"
is still safe.

This commit together with 686b2de (oneway_merge(): only lstat() when
told to update worktree, 2012-12-20) removes all calls to lstat() the
worktree from the command.

This speeds up "git reset -q" a little on the linux-2.6 repo (best
of five, warm cache):

        Before      After
real    0m0.215s    0m0.176s
user    0m0.150s    0m0.130s
sys     0m0.060s    0m0.040s

And with cold cache (best of five):

        Before      After
real    0m11.351s   0m8.420s
user    0m0.230s    0m0.220s
sys     0m0.270s    0m0.060s
There is a test case in t7102 called '--mixed refreshes the index',
but it only checks that right output it printed. Is the test case not
testing right or not named right? As you can see, I suspect it's the
name/description that should change.

 builtin/reset.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/builtin/reset.c b/builtin/reset.c
index 9bcad29..a2e69eb 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -109,12 +109,6 @@ static void print_new_head_line(struct commit *commit)
-static void update_index_refresh(int flags)
-       refresh_index(&the_index, (flags), NULL, NULL,
-                     _("Unstaged changes after reset:"));
 static void update_index_from_diff(struct diff_queue_struct *q,
                struct diff_options *opt, void *data)
@@ -328,9 +322,9 @@ int cmd_reset(int argc, const char **argv, const char 
                                die(_("Could not reset index file to revision 
'%s'."), rev);
-               if (reset_type == MIXED) /* Report what has not been updated. */
-                       update_index_refresh(
-                               quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
+               if (reset_type == MIXED && !quiet) /* Report what has not been 
updated. */
+                       refresh_index(&the_index, REFRESH_IN_PORCELAIN, NULL, 
+                                     _("Unstaged changes after reset:"));
                if (write_cache(newfd, active_cache, active_nr) ||

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to