From: Jeff King <peff@peff.net>
To: Joey Hess <joey@kitenet.net>
Cc: GIT Mailing-list <git@vger.kernel.org>
Subject: Re: speed of git reset -- file
Date: Tue, 31 May 2011 17:26:39 -0400 [thread overview]
Message-ID: <20110531212639.GA13234@sigill.intra.peff.net> (raw)
In-Reply-To: <20110531190015.GA12113@gnu.kitenet.net>
On Tue, May 31, 2011 at 03:00:15PM -0400, Joey Hess wrote:
> I'd expect that resetting a single file would need to update the index,
> reading some objects from .git to do it.
>
> But according to strace, it also stats every file in the working tree.
> I have lots of files, and so that is very slow. Is it really necessary?
Conceptually, no, I don't think so. But remember that your "file" is not
really a file at all, but a pathspec that may match many entries. Also,
we try not to overwrite things that would not be changed. So that
complicates it a little bit.
You can see the implementation in builtin/reset.c:read_from_tree. We
actually diff the tree (e.g., HEAD) against the index, and update only
the differences. Unfortunately this seems to trash the index (see the
comment there), and we end up having to refresh it. I'm not sure how
avoidable that trashing is. I think we're getting deep into how
unpack_trees works, and it handles a lot more cases than just "unpack a
few entries". So I don't know how easy it would be to separate this
relatively simple case from more complex ones.
-Peff
next prev parent reply other threads:[~2011-05-31 21:26 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-31 19:00 speed of git reset -- file Joey Hess
2011-05-31 21:26 ` Jeff King [this message]
2011-05-31 21:54 ` Junio C Hamano
2011-05-31 22:13 ` Jeff King
2011-05-31 22:13 ` Matthieu Moy
2011-06-01 1:14 ` Nguyen Thai Ngoc Duy
2011-05-31 23:39 ` Junio C Hamano
2011-06-01 19:58 ` Jeff King
2011-06-01 20:16 ` Joey Hess
2011-06-01 21:18 ` Jeff King
2011-06-01 22:05 ` Joey Hess
2011-06-01 22:56 ` Jeff King
2011-06-01 23:31 ` Joey Hess
2011-06-02 3:18 ` Jeff King
2011-06-02 4:36 ` Joey Hess
2011-06-02 4:46 ` Joey Hess
2011-06-01 20:51 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110531212639.GA13234@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=joey@kitenet.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).