Noam Postavsky <[email protected]> writes:

> On Wed, Mar 5, 2014 at 1:10 PM, Jonas Bernoulli <[email protected]> wrote:
>> I do agree that having some functionality turned on by just loading
>> a library isn't good.  But it is also how Magit has always done it,
>> I just made it do so by using a built-in mode instead of the broken
>> code Magit used before.
>
> This is in some sense correct from an implementation perspective: in
> both cases the revert function is added to the hook at load time. But
> previously it was Magit's magit-refresh-file-buffer-hook which only
> gets called by Magit functions, whereas now it's find-file-hook which
> works without any intervention from Magit. So from the user's
> perspective the functionality used to only occur when using Magit, but
> now starts working as soon as it's loaded.

This is absolutely correct.

It was a mistake that I assumed that just because nobody has ever
complained about `revert-buffer' being called whenever magit did run
git, that this would stay the same way when also calling `revert-buffer'
after git was run in a shell.

I didn't realize that users would expect such a refresh to happen when
running e.g. `magit-checkout' (or at least not say that doing so was
wrong) but then be taken by surprise when the same thing happens when
running `git checkout'.  In hindsight it was a bit silly to assume that.

Also I have since come to the conclusion that this was a wrong move and
that we should again take control of when a refresh happens.  I have
come to that conclusion independent from this conversation, which just
makes this issue more urgent.

I have now set `magit-turn-on-auto-revert-mode' to nil.  This will
inconventient many users, but I prefer that to being accused of putting
users data at risk.

At the same time I would like to point out that this risk always
existed.  Automatically running `revert-buffer' always comes with that
risk.  It does not matter whether that function gets called due to
the local minor mode `auto-revert-mode' being enabled or magit
explicitly calling it.

It would also be noted that both `auto-revert-handler' (which
`auto-revert-mode' arranges to be called) as well as
`magit-revert-buffer' (which is what magit previously called after
running git) take the same precausions to lessen that risk: they check
whether the buffer is modified and if so they don't call
`revert-buffer'.  The old magit code did not have any additional safety
measures.  E.g. it did not limit the refresh to tracked files.



Recent changes would be lost if a user edits a file and saves it, and
then e.g. checks out another branch.  I have always been aware of that
risk and actually found it to be very surprising that nobody ever
complained about it.  This issue has existed for years now.



  I was aware of the risk
of dataloss but came to the conclusion that it

-- 
You received this message because you are subscribed to the Google Groups 
"magit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to