Commit c926252
authored
hooks: skip post-command hook more often (#813)
The postCommand.strategy=worktree-change config option allows for
skipping the post-command hook when the Git command doesn't change the
worktree. However, sometimes this config isn't loaded before the
post-command hook is invoked, causing the hook to run in cases where
we'd prefer it to not run.
Examples include: `git version` or `git <typo>`.
The tricky bit is that there are several places where we get here and
standard config mechanisms can't load due to not having a `gitdir` in
the repository struct. We fix this by:
1. Using the "load early config" mechanism also used by
`core.hooksPath`.
2. Skipping the lookup for the sentinel file when there isn't a `gitdir`
since we couldn't have written one without it.
The change is given in two commits: the first expands the tests with the
existing behavior and the second changes the behavior, showing the
impact on those tests.
* [X] This change only applies to microsoft/git specifics (post-command
hook)
See #736 and #748 for prior art in this space.2 files changed
+53
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
225 | 231 | | |
226 | 232 | | |
227 | 233 | | |
| |||
233 | 239 | | |
234 | 240 | | |
235 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
236 | 257 | | |
237 | 258 | | |
238 | 259 | | |
| |||
242 | 263 | | |
243 | 264 | | |
244 | 265 | | |
245 | | - | |
246 | | - | |
247 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
248 | 271 | | |
249 | 272 | | |
250 | 273 | | |
| |||
290 | 313 | | |
291 | 314 | | |
292 | 315 | | |
293 | | - | |
294 | | - | |
| 316 | + | |
295 | 317 | | |
296 | 318 | | |
297 | 319 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
81 | 90 | | |
82 | 91 | | |
| 92 | + | |
| 93 | + | |
83 | 94 | | |
84 | | - | |
| 95 | + | |
85 | 96 | | |
86 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
87 | 110 | | |
88 | 111 | | |
89 | 112 | | |
0 commit comments