Commit 1e32467
authored
Restore previous errno after post command hook (#860)
Test and fix for #859 :
Repro steps:
In a repository where post-command hook is configured (such as a VFSForGit clone)
1. Configure autocorrect:
`git config help.autocorrect=prompt`
2. Run an misspelled command. For example,
`git statuss`
Expected output:
```
WARNING: You called a Git command named 'statuss', which does not exist.
Run 'status' instead [y/N]?
```
Actual output:
```
failed to run command 'statuss': No error
```
I think the problem is that [run_post_command_hook](https://github.com/microsoft/git/blob/9db3c15f497c5d59a20bb2ff4d054ff687d08334/git.c#L503C1-L503C26) needs to save and restore errno, similar to how handle_alias does it. Otherwise, the errno from the failed command is overwritten by the successful errno from postcommand hook before the help autocorrect has a chance to examine it.2 files changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| 507 | + | |
507 | 508 | | |
508 | 509 | | |
509 | 510 | | |
| |||
520 | 521 | | |
521 | 522 | | |
522 | 523 | | |
| 524 | + | |
| 525 | + | |
523 | 526 | | |
524 | 527 | | |
525 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
7 | 22 | | |
8 | 23 | | |
9 | 24 | | |
| |||
0 commit comments