forked from git/git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #3082 from dscho/fsmonitor-gfw
Add an experimental built-in FSMonitor
- Loading branch information
Showing
46 changed files
with
7,165 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
git-fsmonitor--daemon(1) | ||
======================== | ||
|
||
NAME | ||
---- | ||
git-fsmonitor--daemon - (EXPERIMENTAL) Builtin file system monitor daemon | ||
|
||
SYNOPSIS | ||
-------- | ||
[verse] | ||
'git fsmonitor--daemon' --start | ||
'git fsmonitor--daemon' --run | ||
'git fsmonitor--daemon' --stop | ||
'git fsmonitor--daemon' --is-running | ||
'git fsmonitor--daemon' --is-supported | ||
'git fsmonitor--daemon' --query <token> | ||
'git fsmonitor--daemon' --query-index | ||
'git fsmonitor--daemon' --flush | ||
|
||
DESCRIPTION | ||
----------- | ||
|
||
NOTE! This command is still only an experiment, subject to change dramatically | ||
(or even to be abandoned). | ||
|
||
Monitors files and directories in the working directory for changes using | ||
platform-specific file system notification facilities. | ||
|
||
It communicates directly with commands like `git status` using the | ||
link:technical/api-simple-ipc.html[simple IPC] interface instead of | ||
the slower linkgit:githooks[5] interface. | ||
|
||
OPTIONS | ||
------- | ||
|
||
--start:: | ||
Starts the fsmonitor daemon in the background. | ||
|
||
--run:: | ||
Runs the fsmonitor daemon in the foreground. | ||
|
||
--stop:: | ||
Stops the fsmonitor daemon running for the current working | ||
directory, if present. | ||
|
||
--is-running:: | ||
Exits with zero status if the fsmonitor daemon is watching the | ||
current working directory. | ||
|
||
--is-supported:: | ||
Exits with zero status if the fsmonitor daemon feature is supported | ||
on this platform. | ||
|
||
--query <token>:: | ||
Connects to the fsmonitor daemon (starting it if necessary) and | ||
requests the list of changed files and directories since the | ||
given token. | ||
This is intended for testing purposes. | ||
|
||
--query-index:: | ||
Read the current `<token>` from the File System Monitor index | ||
extension (if present) and use it to query the fsmonitor daemon. | ||
This is intended for testing purposes. | ||
|
||
--flush:: | ||
Force the fsmonitor daemon to flush its in-memory cache and | ||
re-sync with the file system. | ||
This is intended for testing purposes. | ||
|
||
REMARKS | ||
------- | ||
The fsmonitor daemon is a long running process that will watch a single | ||
working directory. Commands, such as `git status`, should automatically | ||
start it (if necessary) when `core.useBuiltinFSMonitor` is set to `true` | ||
(see linkgit:git-config[1]). | ||
|
||
Configure the built-in FSMonitor via `core.useBuiltinFSMonitor` in each | ||
working directory separately, or globally via `git config --global | ||
core.useBuiltinFSMonitor true`. | ||
|
||
Tokens are opaque strings. They are used by the fsmonitor daemon to | ||
mark a point in time and the associated internal state. Callers should | ||
make no assumptions about the content of the token. In particular, | ||
the should not assume that it is a timestamp. | ||
|
||
Query commands send a request-token to the daemon and it responds with | ||
a summary of the changes that have occurred since that token was | ||
created. The daemon also returns a response-token that the client can | ||
use in a future query. | ||
|
||
For more information see the "File System Monitor" section in | ||
linkgit:git-update-index[1]. | ||
|
||
CAVEATS | ||
------- | ||
|
||
The fsmonitor daemon does not currently know about submodules and does | ||
not know to filter out file system events that happen within a | ||
submodule. If fsmonitor daemon is watching a super repo and a file is | ||
modified within the working directory of a submodule, it will report | ||
the change (as happening against the super repo). However, the client | ||
should properly ignore these extra events, so performance may be affected | ||
but it should not cause an incorrect result. | ||
|
||
GIT | ||
--- | ||
Part of the linkgit:git[1] suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
Simple-IPC API | ||
============== | ||
|
||
The Simple-IPC API is a collection of `ipc_` prefixed library routines | ||
and a basic communication protocol that allow an IPC-client process to | ||
send an application-specific IPC-request message to an IPC-server | ||
process and receive an application-specific IPC-response message. | ||
|
||
Communication occurs over a named pipe on Windows and a Unix domain | ||
socket on other platforms. IPC-clients and IPC-servers rendezvous at | ||
a previously agreed-to application-specific pathname (which is outside | ||
the scope of this design) that is local to the computer system. | ||
|
||
The IPC-server routines within the server application process create a | ||
thread pool to listen for connections and receive request messages | ||
from multiple concurrent IPC-clients. When received, these messages | ||
are dispatched up to the server application callbacks for handling. | ||
IPC-server routines then incrementally relay responses back to the | ||
IPC-client. | ||
|
||
The IPC-client routines within a client application process connect | ||
to the IPC-server and send a request message and wait for a response. | ||
When received, the response is returned back the caller. | ||
|
||
For example, the `fsmonitor--daemon` feature will be built as a server | ||
application on top of the IPC-server library routines. It will have | ||
threads watching for file system events and a thread pool waiting for | ||
client connections. Clients, such as `git status` will request a list | ||
of file system events since a point in time and the server will | ||
respond with a list of changed files and directories. The formats of | ||
the request and response are application-specific; the IPC-client and | ||
IPC-server routines treat them as opaque byte streams. | ||
|
||
|
||
Comparison with sub-process model | ||
--------------------------------- | ||
|
||
The Simple-IPC mechanism differs from the existing `sub-process.c` | ||
model (Documentation/technical/long-running-process-protocol.txt) and | ||
used by applications like Git-LFS. In the LFS-style sub-process model | ||
the helper is started by the foreground process, communication happens | ||
via a pair of file descriptors bound to the stdin/stdout of the | ||
sub-process, the sub-process only serves the current foreground | ||
process, and the sub-process exits when the foreground process | ||
terminates. | ||
|
||
In the Simple-IPC model the server is a very long-running service. It | ||
can service many clients at the same time and has a private socket or | ||
named pipe connection to each active client. It might be started | ||
(on-demand) by the current client process or it might have been | ||
started by a previous client or by the OS at boot time. The server | ||
process is not associated with a terminal and it persists after | ||
clients terminate. Clients do not have access to the stdin/stdout of | ||
the server process and therefore must communicate over sockets or | ||
named pipes. | ||
|
||
|
||
Server startup and shutdown | ||
--------------------------- | ||
|
||
How an application server based upon IPC-server is started is also | ||
outside the scope of the Simple-IPC design and is a property of the | ||
application using it. For example, the server might be started or | ||
restarted during routine maintenance operations, or it might be | ||
started as a system service during the system boot-up sequence, or it | ||
might be started on-demand by a foreground Git command when needed. | ||
|
||
Similarly, server shutdown is a property of the application using | ||
the simple-ipc routines. For example, the server might decide to | ||
shutdown when idle or only upon explicit request. | ||
|
||
|
||
Simple-IPC protocol | ||
------------------- | ||
|
||
The Simple-IPC protocol consists of a single request message from the | ||
client and an optional response message from the server. Both the | ||
client and server messages are unlimited in length and are terminated | ||
with a flush packet. | ||
|
||
The pkt-line routines (Documentation/technical/protocol-common.txt) | ||
are used to simplify buffer management during message generation, | ||
transmission, and reception. A flush packet is used to mark the end | ||
of the message. This allows the sender to incrementally generate and | ||
transmit the message. It allows the receiver to incrementally receive | ||
the message in chunks and to know when they have received the entire | ||
message. | ||
|
||
The actual byte format of the client request and server response | ||
messages are application specific. The IPC layer transmits and | ||
receives them as opaque byte buffers without any concern for the | ||
content within. It is the job of the calling application layer to | ||
understand the contents of the request and response messages. | ||
|
||
|
||
Summary | ||
------- | ||
|
||
Conceptually, the Simple-IPC protocol is similar to an HTTP REST | ||
request. Clients connect, make an application-specific and | ||
stateless request, receive an application-specific | ||
response, and disconnect. It is a one round trip facility for | ||
querying the server. The Simple-IPC routines hide the socket, | ||
named pipe, and thread pool details and allow the application | ||
layer to focus on the application at hand. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.