Re: speed of git reset -- file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]