git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan <git.kernel.org_20@green-sparklet.de>
To: git@vger.kernel.org
Subject: Bug: 'git ls-files' doesn't work on submodule in post-commit hook
Date: Mon, 24 Feb 2020 08:03:15 +0100	[thread overview]
Message-ID: <ede4b653-35bf-d163-c27d-d23602dbd726@green-sparklet.de> (raw)

Hey there,

I think I found a bug in git: I want to use 'git ls-files' onto a git submodule, called in a post-commit hook of main repository, which doesn’t work.
The same call in a post-checkout hook works perfectly.

Example setup to try it out, use a empty (temporary) folder:
--- snipp ---
mkdir git-submodulerepo
cd git-submodulerepo
git init
git config user.email "you@example.com"
git config user.name "Your Name"
echo "nothing" > submodule_file.txt
git add submodule_file.txt
git commit submodule_file.txt -m "Add my file"
cd ..
 
mkdir git-repo
cd git-repo
git init
git config user.email "you@example.com"
git config user.name "Your Name"
echo "nothing" > rubbish.txt
git add rubbish.txt
git commit rubbish.txt -m "Add my rubbish"
 
git submodule add ../git-submodulerepo
 
printf '#!/bin/bash\ncd git-submodulerepo\necho Git says my files are:\ngit ls-files\necho ---------------\necho Filesystem says my files are:\nls -w1\necho ---------------\n' > .git/hooks/post-commit
chmod +x .git/hooks/post-commit
cp .git/hooks/post-commit .git/hooks/post-checkout
chmod +x .git/hooks/post-checkout
--- snapp ---


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(+)
 

This was tested using git version 2.25.0.windows.1
With git version 2.21.0 (cygwin) git ls-files outputs "fatal: .git/index: index file open failed: Not a directory"

I didn’t test other hooks.

Calling "git ls-files" in hook for your main repository (and not a submodule) works for both cases.
I checked for basic things (I'm in submodule directory in both hooks), so I guess this is a bug in git.

Any questions?
Thanks in advance!

Stefan

             reply	other threads:[~2020-02-24  7:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24  7:03 Stefan [this message]
2020-02-25  1:13 ` Bug: 'git ls-files' doesn't work on submodule in post-commit hook brian m. carlson
2020-02-25  7:10   ` Stefan

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=ede4b653-35bf-d163-c27d-d23602dbd726@green-sparklet.de \
    --to=git.kernel.org_20@green-sparklet.de \
    --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).