unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Michael Albinus <michael.albinus@gmx.de>, 55578@debbugs.gnu.org
Subject: bug#55578: 29.0.50; auto-revert-use-notify vs 'git checkout -- <file>'
Date: Tue, 24 May 2022 17:58:36 +0200	[thread overview]
Message-ID: <87leuqgbwz.fsf@miha-pc> (raw)
In-Reply-To: <87mtf7nnok.fsf@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 2561 bytes --]

Michael Albinus <michael.albinus@gmx.de> writes:

> Indeed, git deletes and (re-)creates the file. See the following file
> notify events, when monitoring the git repository (/tmp/xxx is the repo,
> /tmp/xxx/foo the file). This happens, after calling "git checkout -- foo":
>
> --8<---------------cut here---------------start------------->8---
> file-notify-handle-event (file-notify ((1 . 0) (delete) "foo" 0) file-notify--callback-inotify)
> file-notify-handle-event (file-notify ((1 . 0) (create) "foo" 0) file-notify--callback-inotify)
> file-notify-handle-event (file-notify ((1 . 0) (modify) "foo" 0) file-notify--callback-inotify)
> --8<---------------cut here---------------end--------------->8---
>
> The corresponding events for the file /tmp/xxx/foo are
>
> --8<---------------cut here---------------start------------->8---
> file-notify-handle-event (file-notify ((1 . 1) (delete) "foo" 0) file-notify--callback-inotify)
> file-notify-callback (1 . 1) deleted "/tmp/xxx/foo" nil #s(file-notify--watch "/tmp/xxx" "foo" auto-revert-notify-handler) "/tmp/xxx/foo" "/tmp/xxx"
> auto-revert-notify-handler ((1 . 1) deleted "/tmp/xxx/foo")
> file-notify-handle-event (file-notify ((1 . 1) stopped "/tmp/xxx/foo") auto-revert-notify-handler)
> auto-revert-notify-handler ((1 . 1) stopped "/tmp/xxx/foo")
> --8<---------------cut here---------------end--------------->8---
>
> As you can see, file notifications are stopped after receiving the
> 'delete' event. This is a feature of our file notifications implementation.
>
> Running "echo test >> foo" instead shows the events
>
> --8<---------------cut here---------------start------------->8---
> file-notify-handle-event (file-notify ((1 . 0) (modify) "foo" 0) file-notify--callback-inotify)
> file-notify-callback (1 . 0) changed "/tmp/xxx/foo" nil #s(file-notify--watch "/tmp/xxx" nil auto-revert-notify-handler) "/tmp/xxx" "/tmp/xxx"
> auto-revert-notify-handler ((1 . 0) changed "/tmp/xxx/foo")
> --8<---------------cut here---------------end--------------->8---
>
> This works as expected. So I fear there's nothing we can do.

I imagine that after receiving a 'delete' event, auto-revert-mode could
set up a file-notify watch handler on the directory containing the (now
deleted) file. This handler would respond to a 'create' event
corresponding to the filename by reverting the buffer, removing the
directory file-notify watch and (re-)adding an ordinary file-notify
handler on the file.

Are there any obvious flaws with this approach that I'm missing?

> Best regards, Michael.

Best regards.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 861 bytes --]

  reply	other threads:[~2022-05-24 15:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-22 17:18 bug#55578: 29.0.50; auto-revert-use-notify vs 'git checkout -- <file>' miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-24 12:02 ` Michael Albinus
2022-05-24 15:58   ` miha--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-05-24 17:52     ` Michael Albinus
2022-05-24 18:09       ` Michael Albinus
2022-06-29 13:38         ` Michael Albinus

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87leuqgbwz.fsf@miha-pc \
    --to=bug-gnu-emacs@gnu.org \
    --cc=55578@debbugs.gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=miha@kamnitnik.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).