git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Detecting when bulk file-system operations complete
@ 2021-03-31  3:39 Drew Noakes
  2021-03-31 16:03 ` Philip Oakley
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Noakes @ 2021-03-31  3:39 UTC (permalink / raw)
  To: git

Hi,

I develop IDE tooling that watches a repo's workspace and reacts to changes.

Bulk file-system changes (i.e. branch switch, rebase, merge,
cherry-pick) trigger lots of file system events, and my tooling should
ignore intermediary updates. Currently I debounce events with a fixed
time span, but would like a more reliable and performant approach to
scheduling this reactive work.

Can this be done by monitoring the GITDIR in some way? For example, is
there a file that's present when these operations are in flight, and
which is removed when they complete?

If an operation is interrupted (i.e. merge or rebase that hits a
conflict) my tooling should consider the bulk operation as complete.
This means that detecting a git-rebase-todo file or
rebase-merge/rebase-apply folder is not adequate.

Any help appreciated. Thanks!

Drew.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Detecting when bulk file-system operations complete
  2021-03-31  3:39 Detecting when bulk file-system operations complete Drew Noakes
@ 2021-03-31 16:03 ` Philip Oakley
  2021-04-01 13:10   ` Derrick Stolee
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Oakley @ 2021-03-31 16:03 UTC (permalink / raw)
  To: Drew Noakes, git

Hi Drew,

On 31/03/2021 04:39, Drew Noakes wrote:
> Hi,
>
> I develop IDE tooling that watches a repo's workspace and reacts to changes.
>
> Bulk file-system changes (i.e. branch switch, rebase, merge,
> cherry-pick) trigger lots of file system events, and my tooling should
> ignore intermediary updates. Currently I debounce events with a fixed
> time span, but would like a more reliable and performant approach to
> scheduling this reactive work.
>
> Can this be done by monitoring the GITDIR in some way? For example, is
> there a file that's present when these operations are in flight, and
> which is removed when they complete?
>
> If an operation is interrupted (i.e. merge or rebase that hits a
> conflict) my tooling should consider the bulk operation as complete.
> This means that detecting a git-rebase-todo file or
> rebase-merge/rebase-apply folder is not adequate.
>
> Any help appreciated. Thanks!
>
> Drew.
You may want to look at the various bits of work on `fsmonitor` etc on
the mailing list archive

https://lore.kernel.org/git/?q=fsmonitor

to ensure that all the different approaches inter-operate with
reasonable efficiency..

-- 
Philip

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Detecting when bulk file-system operations complete
  2021-03-31 16:03 ` Philip Oakley
@ 2021-04-01 13:10   ` Derrick Stolee
  2021-04-02 15:02     ` Jeff Hostetler
  0 siblings, 1 reply; 4+ messages in thread
From: Derrick Stolee @ 2021-04-01 13:10 UTC (permalink / raw)
  To: Philip Oakley, Drew Noakes, git, Jeff Hostetler

On 3/31/2021 12:03 PM, Philip Oakley wrote:
> Hi Drew,
> 
> On 31/03/2021 04:39, Drew Noakes wrote:
>> Hi,
>>
>> I develop IDE tooling that watches a repo's workspace and reacts to changes.
>>
>> Bulk file-system changes (i.e. branch switch, rebase, merge,
>> cherry-pick) trigger lots of file system events, and my tooling should
>> ignore intermediary updates. Currently I debounce events with a fixed
>> time span, but would like a more reliable and performant approach to
>> scheduling this reactive work.
>>
>> Can this be done by monitoring the GITDIR in some way? For example, is
>> there a file that's present when these operations are in flight, and
>> which is removed when they complete?
>>
>> If an operation is interrupted (i.e. merge or rebase that hits a
>> conflict) my tooling should consider the bulk operation as complete.
>> This means that detecting a git-rebase-todo file or
>> rebase-merge/rebase-apply folder is not adequate.
>>
>> Any help appreciated. Thanks!
>>
>> Drew.
> You may want to look at the various bits of work on `fsmonitor` etc on
> the mailing list archive
> 
> https://lore.kernel.org/git/?q=fsmonitor
> 
> to ensure that all the different approaches inter-operate with
> reasonable efficiency..

This is an important suggestion. There is an issue with the current
approach of using FS Monitor with Watchman along with Visual Studio
Code and certain Git plugins:

1. When "git status" runs, the FS Monitor hook asks Watchman for
   changes. Watchman puts a "cookie file" in the working directory
   so it knows when the file system events are flushed.

2. VS Code notices this cookie file was written, so it interprets
   that a file was changed in the working directory. It calls
   "git status" to update its markers on the modified files.

This loops forever.

The new version of FS Monitor that Jeff Hostetler is working on
writes the cookie file into the .git directory, which VS Code (and
hopefully other IDEs) do not consider a trigger for running commands
like "git status".

This is just one example of the trickiness that ensues when using
filesystem events.

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Detecting when bulk file-system operations complete
  2021-04-01 13:10   ` Derrick Stolee
@ 2021-04-02 15:02     ` Jeff Hostetler
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Hostetler @ 2021-04-02 15:02 UTC (permalink / raw)
  To: Derrick Stolee, Philip Oakley, Drew Noakes, git, Jeff Hostetler



On 4/1/21 9:10 AM, Derrick Stolee wrote:
> On 3/31/2021 12:03 PM, Philip Oakley wrote:
>> Hi Drew,
>>
>> On 31/03/2021 04:39, Drew Noakes wrote:
>>> Hi,
>>>
>>> I develop IDE tooling that watches a repo's workspace and reacts to changes.
>>>
>>> Bulk file-system changes (i.e. branch switch, rebase, merge,
>>> cherry-pick) trigger lots of file system events, and my tooling should
>>> ignore intermediary updates. Currently I debounce events with a fixed
>>> time span, but would like a more reliable and performant approach to
>>> scheduling this reactive work.
>>>
>>> Can this be done by monitoring the GITDIR in some way? For example, is
>>> there a file that's present when these operations are in flight, and
>>> which is removed when they complete?
>>>
>>> If an operation is interrupted (i.e. merge or rebase that hits a
>>> conflict) my tooling should consider the bulk operation as complete.
>>> This means that detecting a git-rebase-todo file or
>>> rebase-merge/rebase-apply folder is not adequate.
>>>
>>> Any help appreciated. Thanks!
>>>
>>> Drew.
>> You may want to look at the various bits of work on `fsmonitor` etc on
>> the mailing list archive
>>
>> https://lore.kernel.org/git/?q=fsmonitor
>>
>> to ensure that all the different approaches inter-operate with
>> reasonable efficiency..
> 
> This is an important suggestion. There is an issue with the current
> approach of using FS Monitor with Watchman along with Visual Studio
> Code and certain Git plugins:
> 
> 1. When "git status" runs, the FS Monitor hook asks Watchman for
>     changes. Watchman puts a "cookie file" in the working directory
>     so it knows when the file system events are flushed.
> 
> 2. VS Code notices this cookie file was written, so it interprets
>     that a file was changed in the working directory. It calls
>     "git status" to update its markers on the modified files.
> 
> This loops forever.
> 
> The new version of FS Monitor that Jeff Hostetler is working on
> writes the cookie file into the .git directory, which VS Code (and
> hopefully other IDEs) do not consider a trigger for running commands
> like "git status".
> 
> This is just one example of the trickiness that ensues when using
> filesystem events.

It sounds like you want to watch the contents of the .git directory
for creation/deletion of various control files.  Something like a
begin- and end-transaction marker.  I'm not sure that Git has such
a clear marker.  Git commands often invoke child commands, rebase
might invoke checkout and then run some other commands for example,
so the marker would need to be recursive.  And some commands can be
paused, an interactive rebase can stop and let the user edit a command
and then continue with the next step in the rebase.

So you would have to decide what the boundaries are that you want
to bracket between your GUI refreshes -- do you freeze during the
whole rebase, or do you incrementally update the display after each
checkout or merge within the rebase?

Having said that, you might look at the `.git/index.lock`.  That file
is present when a particular command is running and modifying things.
It is a start, but probably not sufficient.  And it is possible for
commands to abort (crash) and fail to delete that file, so be careful.

You could have a FS watcher to keep track of the contents of the .git
directory.  But you'd have to do some research on which control files
are created and when and see what makes sense for your application.
I'm not saying it is impossible, but it probably won't be easy to
get right.

Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-02 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31  3:39 Detecting when bulk file-system operations complete Drew Noakes
2021-03-31 16:03 ` Philip Oakley
2021-04-01 13:10   ` Derrick Stolee
2021-04-02 15:02     ` Jeff Hostetler

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.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).