{"thread":{"id":"59002","subject":"bug report","startedAt":"2022-12-25T17:27:11Z","lastAt":"2022-12-25T18:12:23Z","messageCount":2,"participants":["Eyal Post","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"469528","messageId":"CAL_N1vv1KqojvaS7TSeJ1JnUfO=cSzfUNMhGzgLi2pLUrmMWxQ@mail.gmail.com","threadId":"59002","inReplyTo":null,"subject":"bug report","fromName":"Eyal Post","fromEmail":"eyalpost@gmail.com","sentAt":"2022-12-25T17:26:54Z","receivedAt":"2022-12-25T17:27:11Z","isPatch":false,"sender":{"key":"eyalpost@gmail.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n1. I have a script which creates a git worktree and checks out a few\nfiles from the master branch\n2. When this script runs \"stand alone\" - everything works fine\n3. When this script runs from a \"pre-commit\" hook it fails with an\nerror: \"fatal: Unable to create '/tmp/wt-1/.git/index.lock': Not a\ndirectory\"\n\nThe content of the script is (simplified example):\ngit worktree add /tmp/wt-1 master --no-checkout --detach\ncd /tmp/wt-1\ngit checkout master .\n\n\nWhat did you expect to happen? (Expected behavior)\nI would expect the script to run just fine as part of the pre-commit hook\n\nWhat happened instead? (Actual behavior)\nAn error about .git not being a directory is shown\n\nWhat's different between what you expected and what actually happened?\nAn error instead of completing successfully\n\nAnything else you want to add:\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.39.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27\nPDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64 x86_64\ncompiler info: clang: 14.0.0 (clang-1400.0.29.202)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\npre-commit\n"},{"id":"469530","messageId":"CAPig+cQEC6CAV-Es9Ok96s8Cj=Dj76PRyOt4qKQus+rppswuyA@mail.gmail.com","threadId":"59002","inReplyTo":"CAL_N1vv1KqojvaS7TSeJ1JnUfO=cSzfUNMhGzgLi2pLUrmMWxQ@mail.gmail.com","subject":"Re: bug report","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2022-12-25T18:12:06Z","receivedAt":"2022-12-25T18:12:23Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Dec 25, 2022 at 12:48 PM Eyal Post <eyalpost@gmail.com> wrote:\n> 1. I have a script which creates a git worktree and checks out a few\n> files from the master branch\n> 2. When this script runs \"stand alone\" - everything works fine\n> 3. When this script runs from a \"pre-commit\" hook it fails with an\n> error: \"fatal: Unable to create '/tmp/wt-1/.git/index.lock': Not a\n> directory\"\n>\n> The content of the script is (simplified example):\n> git worktree add /tmp/wt-1 master --no-checkout --detach\n\nThis was previously reported[1]. Based upon a quick scan of that old\nemail thread, I'm not sure we ever came to a final conclusion about\nwhether Git could address this case itself[2] without breaking\nexisting workflows or if it should be the hook's responsibility[3].\nPerhaps try having your hook script unset environment variables as\nexplained in [3], or at minimum unset GIT_INDEX_FILE. Also, perhaps\nthis advice[4] applies and you can take a simpler, less heavyweight\napproach to whatever your hook is doing.\n\n[1]: https://lore.kernel.org/git/CAJFQqN+Z9eX6onaj8vVSqpvf-nOC7-Y0Un4NLUie6x6bGfmvZA@mail.gmail.com/\n[2]: https://lore.kernel.org/git/20190517011941.GA30372@sigill.intra.peff.net/\n[3]: https://lore.kernel.org/git/20190516221702.GA11784@sigill.intra.peff.net/\n[4]: https://lore.kernel.org/git/CAGyf7-GtnCqfqPWVpBAELB4xAE6syn7+DfKXgfhL0UoMfvbn4A@mail.gmail.com/\n"}]}