git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: StefanNext: Stefan
Message 2 of 3 in “Bug: 'git ls-files' doesn't work on submodule in post-commit hook”
  1. StefanFeb 24, 2020
  2. brian m. carlsonFeb 25, 2020
  3. StefanFeb 25, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.