Skip to content

Commit ff2be29

Browse files
committed
2 parents 58b90d9 + 665e1b4 commit ff2be29

20 files changed

+2275
-31
lines changed

Documentation/config/status.txt

+22
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,25 @@ status.submoduleSummary::
7777
the --ignore-submodules=dirty command-line option or the 'git
7878
submodule summary' command, which shows a similar output but does
7979
not honor these settings.
80+
81+
status.deserializePath::
82+
EXPERIMENTAL, Pathname to a file containing cached status results
83+
generated by `--serialize`. This will be overridden by
84+
`--deserialize=<path>` on the command line. If the cache file is
85+
invalid or stale, git will fall-back and compute status normally.
86+
87+
status.deserializeWait::
88+
EXPERIMENTAL, Specifies what `git status --deserialize` should do
89+
if the serialization cache file is stale and whether it should
90+
fall-back and compute status normally. This will be overridden by
91+
`--deserialize-wait=<value>` on the command line.
92+
+
93+
--
94+
* `fail` - cause git to exit with an error when the status cache file
95+
is stale; this is intended for testing and debugging.
96+
* `block` - cause git to spin and periodically retry the cache file
97+
every 100 ms; this is intended to help coordinate with another git
98+
instance concurrently computing the cache file.
99+
* `no` - to immediately fall-back if cache file is stale. This is the default.
100+
* `<timeout>` - time (in tenths of a second) to spin and retry.
101+
--

Documentation/git-status.txt

+35
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ ignored, then the directory is not shown, but all contents are shown.
151151
threshold.
152152
See also linkgit:git-diff[1] `--find-renames`.
153153

154+
--serialize[=<path>]::
155+
(EXPERIMENTAL) Serialize raw status results to a file or stdout
156+
in a format suitable for use by `--deserialize`. If a path is
157+
given, serialize data will be written to that path *and* normal
158+
status output will be written to stdout. If path is omitted,
159+
only binary serialization data will be written to stdout.
160+
161+
--deserialize[=<path>]::
162+
(EXPERIMENTAL) Deserialize raw status results from a file or
163+
stdin rather than scanning the worktree. If `<path>` is omitted
164+
and `status.deserializePath` is unset, input is read from stdin.
165+
--no-deserialize::
166+
(EXPERIMENTAL) Disable implicit deserialization of status results
167+
from the value of `status.deserializePath`.
168+
154169
<pathspec>...::
155170
See the 'pathspec' entry in linkgit:gitglossary[7].
156171

@@ -424,6 +439,26 @@ quoted as explained for the configuration variable `core.quotePath`
424439
(see linkgit:git-config[1]).
425440

426441

442+
SERIALIZATION and DESERIALIZATION (EXPERIMENTAL)
443+
------------------------------------------------
444+
445+
The `--serialize` option allows git to cache the result of a
446+
possibly time-consuming status scan to a binary file. A local
447+
service/daemon watching file system events could use this to
448+
periodically pre-compute a fresh status result.
449+
450+
Interactive users could then use `--deserialize` to simply
451+
(and immediately) print the last-known-good result without
452+
waiting for the status scan.
453+
454+
The binary serialization file format includes some worktree state
455+
information allowing `--deserialize` to reject the cached data
456+
and force a normal status scan if, for example, the commit, branch,
457+
or status modes/options change. The format cannot, however, indicate
458+
when the cached data is otherwise stale -- that coordination belongs
459+
to the task driving the serializations.
460+
461+
427462
CONFIGURATION
428463
-------------
429464

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Git status serialization format
2+
===============================
3+
4+
Git status serialization enables git to dump the results of a status scan
5+
to a binary file. This file can then be loaded by later status invocations
6+
to print the cached status results.
7+
8+
The file contains the essential fields from:
9+
() the index
10+
() the "struct wt_status" for the overall results
11+
() the contents of "struct wt_status_change_data" for tracked changed files
12+
() the list of untracked and ignored files
13+
14+
Version 1 Format:
15+
=================
16+
17+
The V1 file begins with a required header section followed by optional
18+
sections for each type of item (changed, untracked, ignored). Individual
19+
item sections are only present if necessary. Each item section begins
20+
with an item-type header with the number of items in the section.
21+
22+
Each "line" in the format is encoded using pkt-line with a final LF.
23+
Flush packets are used to terminate sections.
24+
25+
-----------------
26+
PKT-LINE("version" SP "1")
27+
<v1-header-section>
28+
[<v1-changed-item-section>]
29+
[<v1-untracked-item-section>]
30+
[<v1-ignored-item-section>]
31+
-----------------
32+
33+
34+
V1 Header
35+
---------
36+
37+
The v1-header-section fields are taken directly from "struct wt_status".
38+
Each field is printed on a separate pkt-line. Lines for NULL string
39+
values are omitted. All integers are printed with "%d". OIDs are
40+
printed in hex.
41+
42+
v1-header-section = <v1-index-headers>
43+
<v1-wt-status-headers>
44+
PKT-LINE(<flush>)
45+
46+
v1-index-headers = PKT-LINE("index_mtime" SP <sec> SP <nsec> LF)
47+
48+
v1-wt-status-headers = PKT-LINE("is_initial" SP <integer> LF)
49+
[ PKT-LINE("branch" SP <branch-name> LF) ]
50+
[ PKT-LINE("reference" SP <reference-name> LF) ]
51+
PKT-LINE("show_ignored_files" SP <integer> LF)
52+
PKT-LINE("show_untracked_files" SP <integer> LF)
53+
PKT-LINE("show_ignored_directory" SP <integer> LF)
54+
[ PKT-LINE("ignore_submodule_arg" SP <string> LF) ]
55+
PKT-LINE("detect_rename" SP <integer> LF)
56+
PKT-LINE("rename_score" SP <integer> LF)
57+
PKT-LINE("rename_limit" SP <integer> LF)
58+
PKT-LINE("detect_break" SP <integer> LF)
59+
PKT-LINE("sha1_commit" SP <oid> LF)
60+
PKT-LINE("committable" SP <integer> LF)
61+
PKT-LINE("workdir_dirty" SP <integer> LF)
62+
63+
64+
V1 Changed Items
65+
----------------
66+
67+
The v1-changed-item-section lists all of the changed items with one
68+
item per pkt-line. Each pkt-line contains: a binary block of data
69+
from "struct wt_status_serialize_data_fixed" in a fixed header where
70+
integers are in network byte order and OIDs are in raw (non-hex) form.
71+
This is followed by one or two raw pathnames (not c-quoted) with NUL
72+
terminators (both NULs are always present even if there is no rename).
73+
74+
v1-changed-item-section = PKT-LINE("changed" SP <count> LF)
75+
[ PKT-LINE(<changed_item> LF) ]+
76+
PKT-LINE(<flush>)
77+
78+
changed_item = <byte[4] worktree_status>
79+
<byte[4] index_status>
80+
<byte[4] stagemask>
81+
<byte[4] score>
82+
<byte[4] mode_head>
83+
<byte[4] mode_index>
84+
<byte[4] mode_worktree>
85+
<byte[4] dirty_submodule>
86+
<byte[4] new_submodule_commits>
87+
<byte[20] oid_head>
88+
<byte[20] oid_index>
89+
<byte[*] path>
90+
NUL
91+
[ <byte[*] src_path> ]
92+
NUL
93+
94+
95+
V1 Untracked and Ignored Items
96+
------------------------------
97+
98+
These sections are simple lists of pathnames. They ARE NOT
99+
c-quoted.
100+
101+
v1-untracked-item-section = PKT-LINE("untracked" SP <count> LF)
102+
[ PKT-LINE(<pathname> LF) ]+
103+
PKT-LINE(<flush>)
104+
105+
v1-ignored-item-section = PKT-LINE("ignored" SP <count> LF)
106+
[ PKT-LINE(<pathname> LF) ]+
107+
PKT-LINE(<flush>)

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,8 @@ LIB_OBJS += wrapper.o
12051205
LIB_OBJS += write-or-die.o
12061206
LIB_OBJS += ws.o
12071207
LIB_OBJS += wt-status.o
1208+
LIB_OBJS += wt-status-deserialize.o
1209+
LIB_OBJS += wt-status-serialize.o
12081210
LIB_OBJS += xdiff-interface.o
12091211

12101212
BUILTIN_OBJS += builtin/add.o

0 commit comments

Comments
 (0)