Skip to content

Commit 72210eb

Browse files
committed
hooks: add custom post-command hook config (#736)
The microsoft/git fork includes pre- and post-command hooks, with the initial intention of using these for VFS for Git. In that environment, these are important hooks to avoid concurrent issues when the virtualization is incomplete. However, in the Office monorepo the post-command hook is used in a different way. A custom hook is used to update the sparse-checkout, if necessary. To avoid this hook from being incredibly slow on every Git command, this hook checks for the existence of a "sentinel file" that is written by a custom post-index-change hook and no-ops if that file does not exist. However, even this "no-op" is 200ms due to the use of two scripts (one simple script in .git/hooks/ does some environment checking and then calls a script from the working directory which actually contains the logic). Add a new config option, 'postCommand.strategy', that will allow for multiple possible strategies in the future. For now, the one we are adding is 'post-index-change' which states that we should write a sentinel file instead of running the 'post-index-change' hook and then skip the 'post-command' hook if the proper sentinel file doesn't exist. (If it does exist, then delete it and run the hook.) --- This fork contains changes specific to monorepo scenarios. If you are an external contributor, then please detail your reason for submitting to this fork: * [ ] This is an early version of work already under review upstream. * [ ] This change only applies to interactions with Azure DevOps and the GVFS Protocol. * [ ] This change only applies to the virtualization hook and VFS for Git. * [x] This change only applies to custom bits in the microsoft/git fork.
2 parents 0f953a7 + 62f79d1 commit 72210eb

14 files changed

+200
-30
lines changed

Documentation/config.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ include::config/pack.adoc[]
490490

491491
include::config/pager.adoc[]
492492

493+
include::config/postcommand.adoc[]
494+
493495
include::config/pretty.adoc[]
494496

495497
include::config/promisor.adoc[]

Documentation/config/postcommand.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
postCommand.strategy::
2+
The `post-command` hook is run on every Git process by default. This
3+
config option allows running the hook only conditionally, according
4+
to these values:
5+
+
6+
----
7+
`always`;;
8+
run the `post-command` hook on every process (default).
9+
10+
`worktree-change`;;
11+
run the `post-command` hook only if the current process wrote to
12+
the index and updated the worktree.
13+
----

Documentation/config/protocol.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ protocol.allow::
66
default policy of `never`, and all other protocols (including file)
77
have a default policy of `user`. Supported policies:
88
+
9-
--
9+
----
1010

1111
* `always` - protocol is always able to be used.
1212
@@ -18,15 +18,15 @@ protocol.allow::
1818
execute clone/fetch/push commands without user input, e.g. recursive
1919
submodule initialization.
2020
21-
--
21+
----
2222
2323
protocol.<name>.allow::
2424
Set a policy to be used by protocol `<name>` with clone/fetch/push
2525
commands. See `protocol.allow` above for the available policies.
2626
+
2727
The protocol names currently used by git are:
2828
+
29-
--
29+
----
3030
- `file`: any local file-based path (including `file://` URLs,
3131
or local paths)
3232

@@ -42,7 +42,7 @@ The protocol names currently used by git are:
4242

4343
- any external helpers are named by their protocol (e.g., use
4444
`hg` to allow the `git-remote-hg` helper)
45-
--
45+
----
4646
4747
protocol.version::
4848
If set, clients will attempt to communicate with a server
@@ -51,7 +51,7 @@ protocol.version::
5151
If unset, the default is `2`.
5252
Supported versions:
5353
+
54-
--
54+
----
5555

5656
* `0` - the original wire protocol.
5757

@@ -60,4 +60,4 @@ protocol.version::
6060

6161
* `2` - Wire protocol version 2, see linkgit:gitprotocol-v2[5].
6262

63-
--
63+
----

Documentation/config/push.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ push.default::
1717
(i.e. the fetch source is equal to the push destination),
1818
`upstream` is probably what you want. Possible values are:
1919
+
20-
--
20+
----
2121

2222
* `nothing` - do not push anything (error out) unless a refspec is
2323
given. This is primarily meant for people who want to
@@ -64,7 +64,7 @@ branches outside your control.
6464
This used to be the default, but not since Git 2.0 (`simple` is the
6565
new default).
6666
67-
--
67+
----
6868
6969
push.followTags::
7070
If set to true, enable `--follow-tags` option by default. You

Documentation/config/sendemail.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ the documentation of the email program of the same name. The
5858
differences and limitations from the standard formats are
5959
described below:
6060
+
61-
--
61+
----
6262
sendmail;;
6363
* Quoted aliases and quoted addresses are not supported: lines that
6464
contain a `"` symbol are ignored.
@@ -68,7 +68,7 @@ sendmail;;
6868
* Warnings are printed on the standard error output for any
6969
explicitly unsupported constructs, and any other lines that are not
7070
recognized by the parser.
71-
--
71+
----
7272
sendemail.annotate::
7373
sendemail.bcc::
7474
sendemail.cc::

Documentation/config/sideband.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sideband.allowControlCharacters::
44
unwanted ANSI escape sequences from being sent to the terminal. Use
55
this config setting to override this behavior:
66
+
7-
--
7+
----
88
color::
99
Allow ANSI color sequences, line feeds and horizontal tabs,
1010
but mask all other control characters. This is the default.
@@ -13,4 +13,4 @@ sideband.allowControlCharacters::
1313
horizontal tabs.
1414
true::
1515
Allow all control characters to be sent to the terminal.
16-
--
16+
----

Documentation/config/ssh.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ overridden via the environment variable `GIT_SSH_VARIANT`.
1919
The current command-line parameters used for each variant are as
2020
follows:
2121
+
22-
--
22+
----
2323

2424
* `ssh` - [-p port] [-4] [-6] [-o option] [username@]host command
2525
@@ -29,7 +29,7 @@ follows:
2929
3030
* `tortoiseplink` - [-P port] [-4] [-6] -batch [username@]host command
3131
32-
--
32+
----
3333
+
3434
Except for the `simple` variant, command-line parameters are likely to
3535
change as git gains new features.

Documentation/config/status.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ status.showUntrackedFiles::
5050
systems. So, this variable controls how the commands display
5151
the untracked files. Possible values are:
5252
+
53-
--
53+
----
5454
* `no` - Show no untracked files.
5555
* `normal` - Show untracked files and directories.
5656
* `all` - Show also individual files in untracked directories.
57-
--
57+
----
5858
+
5959
If this variable is not specified, it defaults to 'normal'.
6060
All usual spellings for Boolean value `true` are taken as `normal`
@@ -90,12 +90,12 @@ status.deserializeWait::
9090
fall-back and compute status normally. This will be overridden by
9191
`--deserialize-wait=<value>` on the command line.
9292
+
93-
--
93+
----
9494
* `fail` - cause git to exit with an error when the status cache file
9595
is stale; this is intended for testing and debugging.
9696
* `block` - cause git to spin and periodically retry the cache file
9797
every 100 ms; this is intended to help coordinate with another git
9898
instance concurrently computing the cache file.
9999
* `no` - to immediately fall-back if cache file is stale. This is the default.
100100
* `<timeout>` - time (in tenths of a second) to spin and retry.
101-
--
101+
----

Documentation/config/survey.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ survey.*::
33
command. The intention is that this command could be run in the
44
background with these options.
55
+
6-
--
6+
----
77
survey.namerev::
88
Boolean to show/hide `git name-rev` information for each
99
reported commit and the containing commit of each
@@ -44,4 +44,4 @@ survey.*::
4444
long file or subdirectory entry names. Provides a
4545
default value for `--tree-sizes=<n>` in
4646
linkgit:git-survey[1].
47-
--
47+
----

Documentation/config/trace2.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trace2.eventTarget::
1616
This variable controls the event target destination.
1717
It may be overridden by the `GIT_TRACE2_EVENT` environment variable.
1818
The following table shows possible values.
19-
+
19+
2020
include::../trace2-target-values.adoc[]
2121

2222
trace2.normalBrief::

0 commit comments

Comments
 (0)