I've spent a whole lot of time on stackoverflow/google trying to figure out a solution for this problem. May be the solution is simple and I am missing something.
So I have a pre-commit hook(shell script) which runs few tests on committed files. If a committed file fails a test, it is removed from the stage. I want to printout all the unstated files from inside the script. Here's what I have tried so far from inside the script.
- git diff --name-only --diff-filter=M
- git ls-files -m
- git diff --name-only
All of them throw the same error as shown below:
fatal: This operation must be run in a work tree
P.S. I am running this inside .git folder(since hooks reside there) and hence the error.
Any suggestions would be really helpful.
I asked a colleague of mine and he came up with a solution specifically for shell script. Sometimes you just have to think simple!