evilmartians/lefthook

lefthook fails git command when run with GIT_TRACE=1

tdesveaux opened this issue ยท 1 comments

๐Ÿ”ง Summary

When running a git command that invoke a hook handled by lefthook, the command will fail on the mkdir call here

This fails here, but all git calls should have the same issue.

Lefthook version

1.6.12 e87cc77f7d91893d701ae6dece10c65c32974555

Steps to reproduce

run GIT_TRACE=1 git push

Expected results

Lefthook should not break when GIT_TRACE=1 is set.

Actual results

Lefthook does not correctly handle Stderr on git commands.

Possible Solution

I believe the issue is that git rev-parse --git-path info called above captures Stderr in the same buffer that Stdout is expected.

Logs / Screenshots

GIT_TRACE=1 LEFTHOOK_VERBOSE=1 git push
...
โ”‚ [lefthook] cmd: [git rev-parse --git-path info]
โ”‚ [lefthook] dir: 
โ”‚ [lefthook] err: <nil>
โ”‚ [lefthook] out: 13:45:15.686852 git.c:460               trace: built-in: git rev-parse --git-path info
.git/info                                                                                             
                                                                                                      
Error: mkdir 13:45:15.686852 git.c:460               trace: built-in: git rev-parse --git-path info
.git/info: no such file or directory                                                               

Thank you for creating this issue. I am preparing a refactoring that will cover this case: stderr will be redirected to OS' stderr directly.