{"thread":{"id":"64796","subject":"[BUG] push: pre-push hook that waits for stdin is slow","startedAt":"2026-01-13T20:28:49Z","lastAt":"2026-01-13T23:55:16Z","messageCount":4,"participants":["Kristoffer Haugsbakk","Junio C Hamano","Adrian Ratiu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"533771","messageId":"249f08d1-4457-4a41-8dbe-9725c0c392de@app.fastmail.com","threadId":"64796","inReplyTo":null,"subject":"[BUG] push: pre-push hook that waits for stdin is slow","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2026-01-13T20:26:45Z","receivedAt":"2026-01-13T20:28:49Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"  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\nUsed `git push` with a pre-push hook which included a loop over standard\ninput (stdin):\n\n```\n#!/usr/bin/env bash\n\nwhile read -r -a array\ndo\n    # what the loop body does is not important\n    :\ndone\n```\n\nAt first I tested with a loop body. But I got the same behavior with\n`:`.\n\nIt’s just the usual: check if what we are about to push is to some\nblessed branch. If it is it says that the push failed and tells the user\nto use `--no-verify` if they are sure.\n\n  What did you expect to happen? (Expected behavior)\n\nFor the hook to finish quickly and the push to finish within a few\nseconds at most.\n\n  What happened instead? (Actual behavior)\n\nThe push to the remote (Bitbucket cloud) takes over a minute. But not\nwith `git push --no-verify`. Then it takes a few seconds.\n\n  What's different between what you expected and what actually happened?\n\nTime.\n\n  Anything else you want to add:\n\nI bisected using `timeout 3 git push ...` with a local remote to\n857f047e (hook: allow overriding the ungroup option, 2025-12-26). I used\na script on my own $dayjob repository. But I also tested the following\nscript on commit f0f19d01 (fails) and the commit right before\nit (does not fail).\n\nIt uses a pre-push hook which is just `cat`. Apparently it has to do\nwith how stdin is handled. An empty script does not have this problem.\nAnd neither does a script that just uses `echo` (example).\n\n```\n#!/bin/sh\n\nuuid=d0befd7e-efe4-11f0-b6e1-8b95c76aee96\nrepo=\"$HOME\"/\"$uuid\"\n\n# Destroy test stuff\ncleanup () {\n   rm -rf \"$repo\"\n}\n\nsetup () {\n    # I seem to need a realistic/meaty repo\n    git clone . \"$repo\" &&\n    (\n        cd \"$repo\" &&\n        git tag test-tag &&\n        remote=b896ac6c-efe7-11f0-bebc-3bf1b96c1ded\n        git clone . \"$remote\" &&\n        git remote add local \"$remote\" &&\n        # hook setup\n        mkdir hooks &&\n        cat <<-\\EOF >hooks/pre-push &&\n#!/bin/sh\ncat\nEOF\n        chmod +x hooks/pre-push\n    )\n}\n\nif test \"$1\" = cleanup\nthen\n    cleanup\n    echo >&2 \"bisect: cleaned up test data\"\n    exit 128\nfi &&\n\nif ! test -e \"$repo\"\nthen\n    setup\nfi &&\n\nmake || exit 125\n\ntimeout 3 \\\n    ./bin-wrappers/git -C \"$repo\" -c core.hookspath=hooks \\\n    push local test-tag\n\n# exit code 124: timeout(1) timed out\nif test \"$?\" = 124\nthen\n    exit 1\nelse\n    exit 0\nfi\n```\n\nI tested and reproduced the issue on `master`, `next`, and `seen`:\n\n• master: on 8745eae5 (The 17th batch, 2026-01-11)\n• next: 054afa95 (Sync with 'master', 2026-01-12)\n• seen: b351b516 (Merge branch 'bc/sha1-256-interop-02' into seen,\n  2026-01-12)\n\n  Please review the rest of the bug report below.\n  You can delete any lines you don't wish to share.\n\n[System Info]\ngit version:\ngit version 2.52.0.421.gc32ead4fc78\ncpu: x86_64\nbuilt from commit: c32ead4fc78dfd0327f6b2599e4fdca8166afa18\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nrust: disabled\nlibcurl: 7.81.0\nOpenSSL: OpenSSL 3.0.2 15 Mar 2022\nzlib: 1.2.11\nSHA-1: SHA1_DC\nSHA-256: SHA256_BLK\ndefault-ref-format: files\ndefault-hash: sha1\nuname: Linux 6.8.0-90-generic #91~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 15:20:45 UTC 2 x86_64\ncompiler info: gnuc: 11.4\nlibc info: glibc: 2.35\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\ncommit-msg\npost-applypatch\npost-checkout\npost-commit\npost-merge\npost-rewrite\npre-auto-gc\npre-push\nreference-transaction\n\n-- \nKristoffer\n"},{"id":"533772","messageId":"xmqq8qe1i6o7.fsf@gitster.g","threadId":"64796","inReplyTo":"249f08d1-4457-4a41-8dbe-9725c0c392de@app.fastmail.com","subject":"Re: [BUG] push: pre-push hook that waits for stdin is slow","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-01-13T20:44:40Z","receivedAt":"2026-01-13T20:44:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\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>\n> Used `git push` with a pre-push hook which included a loop over standard\n> input (stdin):\n> ...\n> I bisected using `timeout 3 git push ...` with a local remote to\n> 857f047e (hook: allow overriding the ungroup option, 2025-12-26).\n\nA shot in the dark, but it smells somewhat related to what was\ndiscussed in this thread?\n\n    https://lore.kernel.org/git/87h5spimno.fsf@collabora.com/\n"},{"id":"533774","messageId":"87bjixi5hj.fsf@collabora.com","threadId":"64796","inReplyTo":"xmqq8qe1i6o7.fsf@gitster.g","subject":"Re: [BUG] push: pre-push hook that waits for stdin is slow","fromName":"Adrian Ratiu","fromEmail":"adrian.ratiu@collabora.com","sentAt":"2026-01-13T21:10:16Z","receivedAt":"2026-01-13T21:10:27Z","isPatch":false,"sender":{"key":"adrian.ratiu@collabora.com","avatar":"https://avatars.githubusercontent.com/u/12472556?v=4"},"body":"On Tue, 13 Jan 2026, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\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>>\n>> Used `git push` with a pre-push hook which included a loop over standard\n>> input (stdin):\n>> ...\n>> I bisected using `timeout 3 git push ...` with a local remote to\n>> 857f047e (hook: allow overriding the ungroup option, 2025-12-26).\n>\n> A shot in the dark, but it smells somewhat related to what was\n> discussed in this thread?\n>\n>     https://lore.kernel.org/git/87h5spimno.fsf@collabora.com/\n\nI'm 99% certain it's the same bug and root cause.\n\nChris confirmed the v1 fix worked for git-lfs which is great.\n\nI'm very close to sending v2 which includes the regression tests we\ndiscussed.\n\nMany thanks for reporting, sorry for the breakage and thank you for your\npatience!\n"},{"id":"533783","messageId":"87ecntqd9f.fsf@gentoo.mail-host-address-is-not-set","threadId":"64796","inReplyTo":"249f08d1-4457-4a41-8dbe-9725c0c392de@app.fastmail.com","subject":"Re: [BUG] push: pre-push hook that waits for stdin is slow","fromName":"Adrian Ratiu","fromEmail":"adrian.ratiu@collabora.com","sentAt":"2026-01-13T23:55:08Z","receivedAt":"2026-01-13T23:55:16Z","isPatch":false,"sender":{"key":"adrian.ratiu@collabora.com","avatar":"https://avatars.githubusercontent.com/u/12472556?v=4"},"body":"On Tue, 13 Jan 2026, \"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> wrote:\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>\n> Used `git push` with a pre-push hook which included a loop over standard\n> input (stdin):\n\nHi Kristoffer,\n\nWould you be able to test v2 of this patch, to confirm if it fixes your\nreported issue?\n\nhttps://lore.kernel.org/git/87jyxlioup.fsf@collabora.com/T/#ma48af377cb4a8f3932d2502e9662a0847ee6bf9b\n\nMany thanks,\nAdrian\n"}]}