You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 'worktree-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 behavior is
_only_ triggered, however, if a part of the index changes that is within
the sparse checkout; If only parts of the index change that are not even
checked out on disk, the hook is still skipped.
I originally planned to put this into the repo-settings, but this caused
the repo settings to load in more cases than they did previously. When
there is an invalid boolean config option, this causes failure in new
places. This was caught by t3007.
This behavior is tested in t0401-post-command-hook.sh.
Signed-off-by: Derrick Stolee <[email protected]>
0 commit comments