From: Piotrek <piotrekkr@o2.pl>
To: git@vger.kernel.org
Subject: Issue with git > 2.36.1 and pre-commit hook on macOS M1
Date: Sun, 11 Dec 2022 22:11:19 +0100 [thread overview]
Message-ID: <51d5993f-a1e0-519e-ffa9-ec5205c5e96d@o2.pl> (raw)
Hello.
On MacOS 12.6.1 with M1 chip, git >=2.37.0 (installed by homebrew) and
pre-commit hook that is calling *make* target, that is calling *docker
compose run* command, we get error:
the input device is not a TTY
All works file with homebrew git version 2.36.1
* DETAILS OF PROBLEM *
There is pre-commit hook in place that is using bash script to call
`make` command which is in turn calling `docker compose run` to run some
check before commit. After upgrading git version from `2.36.1` to
`>=2.37` we constantly get error:
> the input device is not a TTY
Example pre-commit hook output:
> docker compose run --rm --entrypoint "" app /code/test.sh
> the input device is not a TTY
> make: *** [Makefile:6: check] Error 1
> !!! FAILING REGARDLESS OF CHECK RESULT !!!
(the latest error message is just so we don't actually commit anything)
AFAIK `docker compose` command is auto-detecting TTY because no `-t` or
`-T` were set.
By doing some tests we managed to check that it is a problem with `git`
version.
Latest version that it worked was `2.36.1`:
> docker compose run --rm --entrypoint "" app /code/test.sh
> =================== CHECK OK =================
> !!! FAILING REGARDLESS OF CHECK RESULT !!!
Machine and software we were testing on:
> make --version
> GNU Make 3.81
>
> docker compose version
> Docker Compose version v2.12.2
>
> git --version
> git version 2.38.1
>
> which git
> /opt/homebrew/bin/git
Also, we tested with linux Ubuntu and all git versions are working fine
with same pre-commit hook. It seems related to `macOS` and `git` only.
* REPLICATING THIS PROBLEM *
Easiest way top replicate is to just clone sample repo I prepared here:
https://github.com/piotrekkr/git-tty-issue-macos
and go with replicate instructions from README.md.
If this is not okay then below I will copy and paste instruction with
file contents.
* FILES *
* Makefile *
COMPOSE_RUN = docker compose run --rm --entrypoint ""
check:
$(COMPOSE_RUN) app /code/test.sh
* docker-compose.yml *
version: "3.7"
services:
app:
image: php:8.1.3-fpm-bullseye
volumes:
- "${PWD}:/code"
working_dir: /code
* .git/hooks/pre-commit *
#!/usr/bin/env bash
make check
echo "!!! FAILING REGARDLESS OF CHECK RESULT !!!"
exit 1
* test.sh *
#!/usr/bin/env bash
echo "=================== CHECK OK ================="
(sorry for attaching like that, I'm not good with those plain text mail
lists)
* INSTRUCTIONS *
1. have macOS with M1 chip (can be expensive)
2. install `docker`, `docker compose v2`, `make`
3. upgrade git with homebrew to version `>=2.37.0`
4. clone repo or manually create files (in same directory)
- Makefile
- docker-compose.yml
- .git/hooks/pre-commit (with execute permissions)
- test.sh
5. if using repo, copy pre commit script to `.git/hooks` directory
cp pre-commit-hook.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
6. Try to commit and you should get TTY error
7. Switch git to `2.36.1` version (seems to be only possible by `brew
extract`)
brew tap-new --no-git $USER/local-tap
brew extract --version=2.36.1 git $USER/local-tap
brew install git@2.36.1
brew link --overwrite git@2.36.1
8. Try committing again, TTY problem should be fixed
Let me know if you need more details etc.
Regards
Piotrek
next reply other threads:[~2022-12-11 21:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-11 21:11 Piotrek [this message]
2022-12-12 13:29 ` Issue with git > 2.36.1 and pre-commit hook on macOS M1 René Scharfe
2022-12-13 21:02 ` Piotrek
2022-12-14 22:23 ` René Scharfe
2022-12-17 7:50 ` Piotrek
2022-12-17 8:34 ` René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51d5993f-a1e0-519e-ffa9-ec5205c5e96d@o2.pl \
--to=piotrekkr@o2.pl \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).