Re: Bug: 'git ls-files' doesn't work on submodule in post-commit hook
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Feb 25, 2020, 01:13 UTC
- Message-ID
- <20200225011320.GL6462@camp.crustytoothpaste.net>
- In-Reply-To
- <ede4b653-35bf-d163-c27d-d23602dbd726@green-sparklet.de>
On 2020-02-24 at 07:03:15, Stefan wrote:
Show 20 quoted lines
> So 'git ls-files' call in post-checkout hook works: > $ git checkout HEAD > A .gitmodules > A git-submodulerepo > Git says my files are: > submodule_file.txt > --------------- > Filesystem says my files are: > submodule_file.txt > --------------- > > A 'git ls-files' in post-commit doesn’t work: > $ echo nothing >> rubbish.txt && git commit rubbish.txt -m "Add just rubbish" > Git says my files are: > --------------- > Filesystem says my files are: > submodule_file.txt > --------------- > [master e05efb1] just rubbish > 1 file changed, 1 insertion(+)
Can you check to see if the GIT_DIR environment variable is set in your hook? In some cases, Git sets various GIT_* environment variables when calling a hook or command, and if you want another repository, you'd need to unset those values.
-- brian m. carlson: Houston, Texas, US OpenPGP: https://keybase.io/bk2204