Skip to content

Restore previous errno after post command hook - #860

Merged
dscho merged 1 commit into
microsoft:vfs-2.53.0from
tyrielv:tyrielv/postcommand-fix-help
Feb 10, 2026
Merged

Restore previous errno after post command hook#860
dscho merged 1 commit into
microsoft:vfs-2.53.0from
tyrielv:tyrielv/postcommand-fix-help

Conversation

@tyrielv

@tyrielv tyrielv commented Feb 10, 2026

Copy link
Copy Markdown
  • [ x ] This change only applies to the virtualization hook and VFS for Git.

Test and fix for #859

derrickstolee
derrickstolee previously approved these changes Feb 10, 2026

@derrickstolee derrickstolee left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for finding and fixing this!

@tyrielv
tyrielv force-pushed the tyrielv/postcommand-fix-help branch from b8706ed to 7c70515 Compare February 10, 2026 18:27
@tyrielv
tyrielv changed the base branch from vfs-2.52.0 to vfs-2.53.0 February 10, 2026 18:28
@tyrielv
tyrielv dismissed derrickstolee’s stale review February 10, 2026 18:28

The base branch was changed.

@dscho
dscho enabled auto-merge February 10, 2026 18:46
@dscho dscho linked an issue Feb 10, 2026 that may be closed by this pull request
@dscho
dscho disabled auto-merge February 10, 2026 20:45
@dscho

dscho commented Feb 10, 2026

Copy link
Copy Markdown
Member
image

sigh Those PR builds have long passed, but apparently there's yet another glitch that prevents webhooks or notifications from being delivered.

@dscho
dscho merged commit 1e32467 into microsoft:vfs-2.53.0 Feb 10, 2026
1 check passed
@dscho

dscho commented Feb 10, 2026

Copy link
Copy Markdown
Member

I had to elevate to admin to "bypass" the "missing" check prerequisite.

dscho added a commit that referenced this pull request Apr 12, 2026
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.
dscho added a commit that referenced this pull request Apr 17, 2026
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.
dscho added a commit that referenced this pull request Apr 17, 2026
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.
dscho added a commit that referenced this pull request Apr 20, 2026
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.
dscho added a commit that referenced this pull request Apr 20, 2026
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.
dscho added a commit that referenced this pull request Apr 20, 2026
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.
dscho added a commit that referenced this pull request Jun 12, 2026
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.
dscho added a commit that referenced this pull request Jun 12, 2026
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.
dscho added a commit that referenced this pull request Jun 17, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Help messages not shown correctly when post command hook is present

3 participants