Thread (46 messages) flat view 46 messages, 3 authors, 2016-06-15

Re: [PATCH 16/19] reset [--mixed] --quiet: don't refresh index

From: Martin von Zweigbergk <hidden>
Date: 2016-06-15 22:55:42

On Wed, Jan 9, 2013 at 9:01 AM, Jeff King [off-list ref] wrote:
On Wed, Jan 09, 2013 at 12:16:13AM -0800, Martin von Zweigbergk wrote:
quoted
"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.
Hmm. But "git reset -q && git diff-files" would not be?
Right. Actually, "git reset -q && git diff" was perhaps not a good
example, because its analogous plumbing command would be "git reset -q
&& git diff-files -p", which is also safe. But, as you say, "git reset
-q && git diff-files" (without -p) might list files for which only the
stat information has changed.
We have never been very clear about which commands refresh the index.
Yes, git-reset's documentation doesn't mention it.
Since "reset" is about manipulating the index, I'd expect it to be
refreshed afterwards. On the other hand, since we have never guaranteed
anything, perhaps a careful script should always use "git update-index
--refresh".
Since "git diff-files" is a plumbing command, users of it to a
hopefully a bit more careful than regular users, but you never know.
I would not be too surprised if some of our own scripts are
not that careful, though.
I didn't find any, but I might have missed something.

Regardless, this patch was tangential. The goal of this series can be
achieved independently of this patch, so if it's too risky, we can
drop easily drop it.

Also, even though it does make "git reset -q" faster, I'm not sure how
important that is in practice. Most use cases would probably refresh
the index afterwards anyway. In such cases, the improvement on warm
cache would still be there, but the relative improvement in the cold
cache case would be pretty much gone (since the entire tree would be
stat'ed by the following refresh anyway).


Martin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help