Subject: Re: bug#11757: Acknowledgement (24.1.50; vc-git calls `process-file' too many times)

From: Michael Albinus <[email-masked]>
Date: Fri, 29 Jun 2012 18:40:47 +0200

Dmitry Gutov <[email-masked]> writes:

> Looks like the win is the same here.

Yes. And when there are several operations for the same file, the cache
pays even more.

> I'm not sure about caching vc-git-root, since at least in local
> scenario it's a fast operation. Is it that slow with Tramp?

Yes. Every remote operation is slow, compared with whatever lisp code.

> Other backends don't cache it either.

They should do also. It is very unlikely, that the root changes while
the cache is active.

>> A stale cache is bad, of course. We must carefully check, where a cached
>> value has to be invalidated. But why should vc-working-revision being
>> invalidated after saving? It is still the same, I believe. Switching to
>> another branch shall be observed by Emacs, 'cause there is another
>> version of the file on the disk, and Emacs warns you before editing.
>
> This won't happen in following cases:
> 1) We switch to revision when the opened file is the same.
> 2) It doesn't exist there.
> 3) We just delete it from disk from outside of Emacs.
> So the file isn't changed, and you see no warning or update, even
> after you write it to disk from Emacs again.

I see. Maybe we find a hook, where we could invalidate the vc cache when
a file is written which does not exist on the disk?

> And the latter two cases (the last one - with a small modification)
> are the only situations I can think of when an open buffer in which
> (vc-git-registered) returned t some time ago (so it has vc-backend
> property set to Git) now should return nil.
> But the properties won't be reset, so the cached value will be outdated.
>
> Can you describe a scenario in which 'git-registered cached value will
> be invalidated, and the function will then return nil?

When the file is removed from git outside Emacs. In this case,
git-registered must be nil.

> P.S. I can't find a way to apply context diff with my current setup,
> so if it's not too hard, please send a unified one next time.

I try to remember. The Emacs maintainers prefer context diffs, that's
why ediff-custom-diff-options is set to "-c" by default.

> -- Dmitry

Best regards, Michael.