{"thread":{"id":"57614","subject":"bug report: pre-push hook","startedAt":"2022-03-24T16:45:18Z","lastAt":"2022-03-24T22:48:16Z","messageCount":4,"participants":["Honza Prokeš","Emily Shaffer","Taylor Blau"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"452129","messageId":"CA+ZGDOUKrNRdf-7+SBoVhPkAmyHEtt==AJ=jBDWGkOUcz=n4BA@mail.gmail.com","threadId":"57614","inReplyTo":null,"subject":"bug report: pre-push hook","fromName":"Honza Prokeš","fromEmail":"proke.j@gmail.com","sentAt":"2022-03-24T16:45:00Z","receivedAt":"2022-03-24T16:45:18Z","isPatch":false,"sender":{"key":"proke.j@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nI did setup pre-push hook to run unit tests.\n\nWhat did you expect to happen? (Expected behavior)\nPre-push executes tests, I can see output, and if tests fail, push\ndoes not happen.\n\nWhat happened instead? (Actual behavior)\nTests seem to execute on the background, but I do not see output and\npush happens when tests fail.\n\nWhat's different between what you expected and what actually happened?\nAs above, so:\nTests seem to execute on the background, but I do not see output and\npush happens when tests fail.\n\nAnything else you want to add:\nWhen I run pre-push script directly from terminal, it executes tests,\nI see output and if I ask for last command exit-code, it is non-zero\nif tests fail, so my script is functional. It was working until\nrecently, noticed today, but this behavior happened at least two days\nago. It was working well in past. My fella has the same issue with\nsimilar script on up-to-date Arch Linux.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.35.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.105-1-MANJARO #1 SMP PREEMPT Fri Mar 11 14:12:33 UTC\n2022 x86_64\ncompiler info: gnuc: 11.1\nlibc info: glibc: 2.35\n$SHELL (typically, interactive shell): /usr/bin/zsh\n\n\n[Enabled Hooks]\npre-push\n\nS pozdravem / Best regards\n\nJan Prokeš\n\nFull stack programátor / Web developer\n"},{"id":"452207","messageId":"CAJoAoZmo4bJgGdYQeM4XtRJHOpm4z7Gvg=qpUc4xa7Ap=v++UA@mail.gmail.com","threadId":"57614","inReplyTo":"CA+ZGDOUKrNRdf-7+SBoVhPkAmyHEtt==AJ=jBDWGkOUcz=n4BA@mail.gmail.com","subject":"Re: bug report: pre-push hook","fromName":"Emily Shaffer","fromEmail":"emilyshaffer@google.com","sentAt":"2022-03-24T18:30:16Z","receivedAt":"2022-03-24T18:30:35Z","isPatch":false,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"On Thu, Mar 24, 2022 at 9:45 AM Honza Prokeš <proke.j@gmail.com> wrote:\n>\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> I did setup pre-push hook to run unit tests.\n>\n> What did you expect to happen? (Expected behavior)\n> Pre-push executes tests, I can see output, and if tests fail, push\n> does not happen.\n>\n> What happened instead? (Actual behavior)\n> Tests seem to execute on the background, but I do not see output\n\nI wonder - are you printing your test output to stdout, or stderr?\nstderr of the hook is printed to stdout of the Git process, so that\nmay be why.\n\n> and\n> push happens when tests fail.\n\nThis part I am a little less sure about, especially without seeing\nyour hook script - but perhaps getting the output thing figured out\nfirst will help figure out this part?\n\n>\n> What's different between what you expected and what actually happened?\n> As above, so:\n> Tests seem to execute on the background, but I do not see output and\n> push happens when tests fail.\n>\n> Anything else you want to add:\n> When I run pre-push script directly from terminal, it executes tests,\n> I see output and if I ask for last command exit-code, it is non-zero\n> if tests fail, so my script is functional. It was working until\n> recently, noticed today, but this behavior happened at least two days\n> ago.\n\nOh, interesting! There has been a bit of hook-handling backend work\ngoing on lately (ccing Ævar who has been more actively working on it\nthan me) so it's possible it's a regression, although we do have tests\ncovering pre-push hook in t/t5571-pre-push-hook.sh; I see that those\ntests cover nonzero exit, but it doesn't look like they cover output\ncapturing (the test hooks are cat-ing to a file, rather than trying to\nprint their own output).\n\nAny chance that you can provide a minified version of your pre-push\nhook that reliably tries to fail and doesn't prevent push from\nhappening? That would help a lot to track down the issue.\n\n> It was working well in past. My fella has the same issue with\n> similar script on up-to-date Arch Linux.\n>\n> [System Info]\n> git version:\n> git version 2.35.1\n\nWould also be nice to know, if you happen to know, what version you\nused before when it worked nicely. But if you don't happen to have\nthat handy then don't worry about it.\n\n - Emily\n"},{"id":"452231","messageId":"Yjziu8nU/SZ7SyH0@nand.local","threadId":"57614","inReplyTo":"CAJoAoZmo4bJgGdYQeM4XtRJHOpm4z7Gvg=qpUc4xa7Ap=v++UA@mail.gmail.com","subject":"Re: bug report: pre-push hook","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-03-24T21:29:31Z","receivedAt":"2022-03-24T21:29:36Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Thu, Mar 24, 2022 at 11:30:16AM -0700, Emily Shaffer wrote:\n> > What happened instead? (Actual behavior)\n> > Tests seem to execute on the background, but I do not see output\n>\n> I wonder - are you printing your test output to stdout, or stderr?\n> stderr of the hook is printed to stdout of the Git process, so that\n> may be why.\n\nI didn't think that we redirected the pre-push (or any) hook's stderr to\nstdout in the parent process. I wrote a small pre-push hook which is\njust:\n\n    $ cat .git/hooks/pre-push\n    #!/bin/sh\n\n    echo >&2 \"hi!\"\n\nand then:\n\n    $ git.compile push ttaylorr --dry-run 2>foo\n    $ grep hi foo\n    hi!\n\nBut I might be holding it wrong, since I am not a frequent user of\nhooks.\n\nThanks,\nTaylor\n"},{"id":"452240","messageId":"CAJoAoZmfLaxTGGQRaR8D0-L3pH563z6_04UUwBo7GY1A14Ebww@mail.gmail.com","threadId":"57614","inReplyTo":"Yjziu8nU/SZ7SyH0@nand.local","subject":"Re: bug report: pre-push hook","fromName":"Emily Shaffer","fromEmail":"emilyshaffer@google.com","sentAt":"2022-03-24T22:47:58Z","receivedAt":"2022-03-24T22:48:16Z","isPatch":false,"sender":{"key":"nasamuffin@google.com","avatar":"https://avatars.githubusercontent.com/u/1606826?v=4"},"body":"On Thu, Mar 24, 2022 at 2:29 PM Taylor Blau <me@ttaylorr.com> wrote:\n>\n> On Thu, Mar 24, 2022 at 11:30:16AM -0700, Emily Shaffer wrote:\n> > > What happened instead? (Actual behavior)\n> > > Tests seem to execute on the background, but I do not see output\n> >\n> > I wonder - are you printing your test output to stdout, or stderr?\n> > stderr of the hook is printed to stdout of the Git process, so that\n> > may be why.\n>\n> I didn't think that we redirected the pre-push (or any) hook's stderr to\n> stdout in the parent process. I wrote a small pre-push hook which is\n> just:\n>\n>     $ cat .git/hooks/pre-push\n>     #!/bin/sh\n>\n>     echo >&2 \"hi!\"\n>\n> and then:\n>\n>     $ git.compile push ttaylorr --dry-run 2>foo\n>     $ grep hi foo\n>     hi!\n>\n> But I might be holding it wrong, since I am not a frequent user of\n> hooks.\n\nAh, it seems I'm completely mistaken :) Sorry for the misinfo. Urk.\n\nHaving a look in 'master', run_pre_push_hook() does not use hook.c\nmachinery yet at all; it also seems like it doesn't try to capture\nstdout from the pre-push child process anyways. That makes me ask \"how\ndid this ever work?\" which brings me back to wanting a small hook we\ncan try to reproduce with from Honza :)\n\n - Emily\n"}]}