Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git hook's stderr is being swallowed #2279

Closed
1 task done
wilbaker opened this issue Aug 1, 2019 · 3 comments
Closed
1 task done

Git hook's stderr is being swallowed #2279

wilbaker opened this issue Aug 1, 2019 · 3 comments

Comments

@wilbaker
Copy link

wilbaker commented Aug 1, 2019

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.22.0.vfs.1.1
cpu: x86_64
built from commit: 58ad01641f80fac5d3468f2b9edd311bfc07f82e
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Windows 10 Preview, 64bit
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
Enable Builtin Interactive Add: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

No

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD

This issue is reproducible with VFS for Git's (https://github.com/Microsoft/VFSForGit) pre and post command hooks. It happens with any git command.

  • What did you expect to occur after running these commands?

I expected that messages written by the hooks to stderr would be visible on the command line.

  • What actually happened instead?

The hook's stderr was swallowed.

@dscho mentioned the following as a possible root cause:

When redirecting stdout to stderr in run_command(), we apparently use dup2(2, 1) (but only on Windows), which AFAICT closes 2 (i.e. stderr).

@rimrul
Copy link
Member

rimrul commented Aug 2, 2019

When redirecting stdout to stderr in run_command(), we apparently use dup2(2, 1) (but only on Windows), which AFAICT closes 2 (i.e. stderr).

That shouldn't happen. The man page says

int dup2(int oldfd, int newfd);

[…]

dup2() makes newfd be the copy of oldfd, closing newfd first if necessary

This should close newfd aka 1 aka stdout.

@dscho
Copy link
Member

dscho commented Oct 13, 2019

@wilbaker I lost track: did we determine in an offline chat that this ticket could be closed, or do I misremember?

@wilbaker
Copy link
Author

@dscho I'm having trouble remember as well, I can close this for now and re-open if I see this issue again (and determine it's something on the git side).

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

No branches or pull requests

3 participants